java.lang.ClassLoader
is such a big class. Using your GrepCode link (which is for java 6-b14 version) you can find at line 267 the public loadClass
method.
This method, calls a protected loadClass
method at line 308 and this method try to load a previosly loaded class using:
findLoadedClass
which in the ends calls Native methods,
- Calling
parent.loadClass
,
findBootstrapClass0
(a native method also) if there is no parent
,
- And finally
findClass
if no class is found.
This is important to say, because ClassLoader
tries to reuse already loaded clases, keep in mind.
But, where is defineClass
invoked? No place from this abstract class, but if you use reference tool from GrepCode and search where it is used defineClass
(see here results) you will find a lot of concrete classes which in the end calls definClass
.
It is not straightforward, some of these classes, override defineClass
while others calls its own loadClass
which then calls ... and so on, but finally it calls defineClass
.
Don't forget that defineClass
of ClassLoader
ends in one of three native methods that are responsible of JVM magic: defineClass0
, defineClass1
and/or defineClass2
Edit
Native function defineClass0
calls Java_java_lang_ClassLoader_defineClass0
from ClassLoader.c
and the same for 1 and 2 functions.
This functions creates the required class using JVM_DefineClassWithSource
defined in jvm.h
and implemented in openjdk\hotspot\src\share\vm\prims\jvm.cpp
.
This last file defines jvm_define_class_common
function which in the end is the function that creates the required class. Finally, this function calls JNIHandles::make_local
to allocate the class. You can see the code of this last function in openjdk\hotspot\src\share\vm\runtime\jniHandles.cpp
Hope it answer your question.