Hi,

On Sat, Nov 03, 2001 at 08:39:49AM -0700, Eric Blake wrote:
> 
> The problem here is that the supplied ClassLoader parameter may be null,
> if you intend for the proxy class to be created by the bootstrap
> loader.
I see. Then you could try to do a ClassLoader.getSystemClassLoader().
The spec says that this method may return null, but we could make it so
that the Classpath version always returns a non-null value.
(I have some code that makes the "systemClassLoader" an instance of
URLClassLoader, but I never had the time to actually finish, test, commit
that code.)

> For example, in javac you can create a proxy Runnable with null
> as its ClassLoader:
>   Proxy.newProxyInstance(null, new Class[]{Runnable.class}, myHandler);
> In order to create this class without a NullPointerException, you must
> defer to the secure VM entry point.
But does VMClassLoader have to be public for that?
(If letting getSystemClassLoader() always return a non-null ClassLoader is
somehow not an option)

Since java.lang.reflect.Proxy is system class is should always have enough
permissions to get at the package private static method of
java.lang.VMClassLoader (through AccessController.doPrivileged).
You could even cache the returned Method somewhere. Creating Proxy classes
already involves a lot of reflection so getting this particular method
also through reflection is not such a big deal (IMHO).

Cheers,

Mark
-- 
Stuff to read:
    <http://www.toad.com/gnu/whatswrong.html>
  What's Wrong with Copy Protection, by John Gilmore

_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to