开发者

Java: defineClass and inner classes

开发者 https://www.devze.com 2023-02-19 02:53 出处:网络
In my own classloader I get all entries from jar file and use defineClass() to load classes to memory.

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

My 开发者_StackOverflow中文版problem is that if jar has inner classes (e.g. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消