use of org.eclipse.ceylon.langtools.classfile.ConstantPoolException in project ceylon by eclipse.
the class BytecodeUtils method readModuleInfo.
private static ClassFile readModuleInfo(String moduleName, final File jarFile) {
// default module has no module descriptor
if (Module.DEFAULT_MODULE_NAME.equals(moduleName))
return null;
try {
try (JarFile jar = new JarFile(jarFile)) {
String modulePath = getModulePath(moduleName);
String name1 = modulePath + "/$module_.class";
JarEntry entry = jar.getJarEntry(name1);
if (entry == null) {
String name2 = modulePath + "/module_.class";
entry = jar.getJarEntry(name2);
}
if (entry != null) {
try (InputStream stream = jar.getInputStream(entry)) {
return ClassFile.read(stream);
} catch (ConstantPoolException e) {
throw new RuntimeException(e);
}
}
return null;
}
} catch (IOException e) {
throw new RuntimeException("Failed to read class file for module " + jarFile.getPath(), e);
}
}
use of org.eclipse.ceylon.langtools.classfile.ConstantPoolException in project ceylon by eclipse.
the class BytecodeUtils method readClassFiles.
private static List<ClassFile> readClassFiles(final File jarFile) {
try {
try (JarFile jar = new JarFile(jarFile)) {
List<ClassFile> ret = new ArrayList<ClassFile>(jar.size());
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String name = entry.getName().toLowerCase();
if (name.endsWith(".class")) {
try (InputStream stream = jar.getInputStream(entry)) {
try {
ret.add(ClassFile.read(stream));
} catch (ConstantPoolException e) {
throw new RuntimeException(e);
}
}
}
}
return ret;
}
} catch (IOException e) {
throw new RuntimeException("Failed to read class file for module " + jarFile.getPath(), e);
}
}
use of org.eclipse.ceylon.langtools.classfile.ConstantPoolException in project ceylon by eclipse.
the class ClassFileScanner method scan.
public void scan(ModuleInfo moduleInfo) throws IOException {
PathFilter pathFilter = null;
if (moduleInfo != null && moduleInfo.getFilter() != null) {
pathFilter = PathFilterParser.parse(moduleInfo.getFilter());
}
try (ZipFile zf = new ZipFile(jarFile)) {
Enumeration<? extends ZipEntry> entries = zf.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.isDirectory() || !entry.getName().toLowerCase().endsWith(".class"))
continue;
if (pathFilter != null && !pathFilter.accept(entry.getName()))
continue;
try (InputStream is = zf.getInputStream(entry)) {
try {
ClassFile classFile = ClassFile.read(is);
isPublicApi = false;
checkPublicApi(classFile);
} catch (ConstantPoolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidDescriptor e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
Aggregations