I have this method (in my own classloader) that loads classes from zip:
ZipInputStream in = new ZipInputStream(new FileInputStream(zip)); ZipEntry entry; while ((entry = in.getNextEntry()) != null) { if (!entry.isDirectory()) { byte[] buffer = new byte[(int) entry.getSize()]; in.read(buffer); if (!entry.getName().endsWith(".class")) continue; String name = entry.getName().replace(".class", "").replace("/", "."); Class<?> cls = this.defineClass(name, buffer, 0, buffer.length); this.resolveClass(cls); } }
The zip that im trying to load looks like this:
My problem is that defineClass() fails to load the TestClass$SomeOtherInnerClass. If this class is loaded before the actual TestClass i get this:TestClass.class
TestClass$SomeOtherInnerClass.class
I also tried to load the TestClass.class first but then im getting this error:java.lang.NoClassDefFoundError: TestClass
Please help mejava.lang.ClassFormatError: Wrong InnerClasses attribute length in class file TestClass