ClassLoader
clMain -> URLClassLoader
clA (class A, $B). $B is a inner class B of the class A.
ClassLoader
, execute a method of the object A via interface without problems.NoClassDefFoundError
.this.getClass().getClassLoader().loadClass("A$B");
So, the cuestion is: "Why the definition of the class $B cannot be found for step 3 and Can be solved this porblem in another way?"
Checking the ClassLoader
used in the method ( this.getClass().getClassLoader()
) and comparing it with the ClassLoader
used in the constructor - is the same and contains the necessary url. Java 8 and 14 tried to run, jdk 8 to build.
NoClassDefFoundError invariably means the $inner class file (in this specific case) itself could not be found . packaging or copying problem or a url referencing problem (? JNDI naming problem) but whatever, the file was not located where stated. (sometimes the filename is a typo somewhere and the location to it is correct).
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.