harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Varlamov" <alexey.v.varla...@gmail.com>
Subject Re: [drlvm] What should return org.apache...VMStack.getClassLoader(j.l.Class) method for native frames?
Date Fri, 22 Sep 2006 10:56:23 GMT
2006/9/22, Evgueni Brevnov <evgueni.brevnov@gmail.com>:
> 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: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message