use of gate.util.asm.ClassVisitor in project gate-core by GateNLP.
the class Plugin method fillInResInfos.
protected void fillInResInfos(List<ResourceInfo> incompleteResInfos, List<String> allJars) throws IOException {
// now create a temporary class loader with all the JARs (scanned or
// not), so we can look up all the referenced classes in the normal
// way and read their CreoleResource annotations (if any).
URL[] jarUrls = new URL[allJars.size()];
for (int i = 0; i < jarUrls.length; i++) {
jarUrls[i] = new URL(getBaseURL(), allJars.get(i));
}
// can then throw away?
try (URLClassLoader tempClassLoader = new URLClassLoader(jarUrls, Gate.class.getClassLoader())) {
for (ResourceInfo ri : incompleteResInfos) {
String classFile = ri.getResourceClassName().replace('.', '/') + ".class";
InputStream classStream = tempClassLoader.getResourceAsStream(classFile);
if (classStream != null) {
ClassReader classReader = new ClassReader(classStream);
ClassVisitor visitor = new ResourceInfoVisitor(ri);
classReader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
classStream.close();
}
}
}
}
Aggregations