In the documentation I found:
Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.
I checked the source code, but didn't find the place defineClass
to be called e.g. from loadClass method.
Could you show me, please, who and when call defineClass
method according to this scheme:
Picture source
The defineClass()
method is called during the invocation of ClassLoader#loadClass()
. However, this is not directly done within the java.lang.ClassLoader
class but in one of its subclasses, e.g. in URLClassLoader#findClass()
.
The call to ClassLoader#defineClass()
ends up in a call to one of the native methods defineClass1()
or defineClass2()
. The C implementations of these methods can be found in OpenJDK in src/share/native/java/lang/ClassLoader.c
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With