use of org.codehaus.groovy.ast.decompiled.AsmReferenceResolver in project groovy-core by groovy.
the class ClassNodeResolver method findDecompiled.
/**
* Search for classes using ASM decompiler
*/
private LookupResult findDecompiled(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) {
ClassNode node = ClassHelper.make(name);
if (node.isResolved()) {
return new LookupResult(null, node);
}
DecompiledClassNode asmClass = null;
String fileName = name.replace('.', '/') + ".class";
URL resource = loader.getResource(fileName);
if (resource != null) {
try {
asmClass = new DecompiledClassNode(AsmDecompiler.parseClass(resource), new AsmReferenceResolver(this, compilationUnit));
if (!asmClass.getName().equals(name)) {
// this may happen under Windows because getResource is case insensitive under that OS!
asmClass = null;
}
} catch (IOException e) {
// fall through and attempt other search strategies
}
}
if (asmClass != null) {
if (isFromAnotherClassLoader(loader, fileName)) {
return tryAsScript(name, compilationUnit, asmClass);
}
return new LookupResult(null, asmClass);
}
return null;
}
use of org.codehaus.groovy.ast.decompiled.AsmReferenceResolver in project groovy by apache.
the class ClassNodeResolver method findDecompiled.
/**
* Search for classes using ASM decompiler
*/
private LookupResult findDecompiled(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) {
ClassNode node = ClassHelper.make(name);
if (node.isResolved()) {
return new LookupResult(null, node);
}
DecompiledClassNode asmClass = null;
String fileName = name.replace('.', '/') + ".class";
URL resource = loader.getResource(fileName);
if (resource != null) {
try {
asmClass = new DecompiledClassNode(AsmDecompiler.parseClass(resource), new AsmReferenceResolver(this, compilationUnit));
if (!asmClass.getName().equals(name)) {
// this may happen under Windows because getResource is case insensitive under that OS!
asmClass = null;
}
} catch (IOException e) {
// fall through and attempt other search strategies
}
}
if (asmClass != null) {
if (isFromAnotherClassLoader(loader, fileName)) {
return tryAsScript(name, compilationUnit, asmClass);
}
return new LookupResult(null, asmClass);
}
return null;
}
Aggregations