简体   繁体   中英

Java: defineClass and inner classes

In my own classloader I get all entries from jar file and use defineClass() to load classes to memory.

My problem is that if jar has inner classes (eg MyClass$1.class) the defineClass method fails with java.lang.NoClassDefFoundError: IllegalName exception.

Obviously java needs all files from jar to make it work but how the inner classes can be loaded?

MyClass$1.class should match an anonymous inner class. If your inner class is named, it should be MyClass$InnerClass.class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM