2006/9/22, Evgueni Brevnov <[EMAIL PROTECTED]>:
HI All,
While implementing Invocation API for DRLVM I ran into interesting
situation. Assume we are in native code and just created VM by
JNI_CreateJavaVM(). The next step is to call Class.forName(name)
method through JNI. If you look at forName method implementation you
will find it calls org.apache....VMStack.getCallerClass(0). Which
means it wants to get the caller's class of the forName() method. In
that case we get null since forName was called from native code. Later
Class.forName(name) method passes obtained class to
org.apache...VMStack.getClassLoader(j.l.Class) method to get caller's
class loader.
The question is: What class loader should be returned in that case?
I think we need to return current thread's context class loader in
that case. So it will be bootstrap class loader for any thread
attached through AttachCurrentThread except main thread which has
system class loader as its context class loader.
Sounds very reasonable and is aligned with the API specification:
"The context ClassLoader is provided by the creator of the thread for
use by code running in this thread when loading classes and resources.
If not set, the default is the ClassLoader context of the parent
Thread. The context ClassLoader of the primordial thread is typically
set to the class loader used to load the application."
Actually I see no alternatives anyway - so just go ahead!
--
Alexey
Any ideas?
Evgueni
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]