classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java.util.ResourceBundle bug?


From: Mark Wielaard
Subject: Re: java.util.ResourceBundle bug?
Date: Sat, 3 Nov 2001 16:28:14 +0100
User-agent: Mutt/1.3.23i

Hi,

On Fri, Nov 02, 2001 at 09:30:09PM -0700, Eric Blake wrote:
> > The problem is that VMSecurityManager is in
> > java.lang and package-private, but I don't think it should be, since
> > there are classes in other packages which need access to this
> > functionality.
> >
> > I think we should move it to gnu.java.lang and make it public. Same goes
> > for java.lang.VMClassLoader. Does anyone disagree?
> 
> I agree that java.lang.VMClassLoader should be moved somewhere and made
> public, since java.lang.reflect.Proxy currently has a nasty hack of
> using reflection to call VMClassLoader.defineClass.

I disagree since we should not let "normal" classes give direct access to
the VM interface classes.

I looked at the code and I do not understand why you want to call the
VMClassLoader.defineClass() method. It seems to me that you want to call
the defineClass() method of the supplied loader. I do admit that this is
not possible with the same trick as we could use in java.util with the
SecurityManager. But since java.util.reflect.Proxy is system code it has
enough permissions to get at the defineClass() Method and invoke it on
the supplied loader. Wouldn't something like the following work:

  Class clazz = (Class) AccessController.doPrivileged
  (
    new PrivilegedAction()
    {
      Class[] types = {ClassLoader.class, String.class,
                       byte[].class, int.class, int.class,
                       /* ProtectionDomain.class */ };
      Method m = loader.getDeclaredMethod("defineClass", types);

      Object[] args = {loader, qualName, bytecode, new Integer(0),
                       new Integer(bytecode.length),
                       /* Object.class.getProtectionDomain() */ };
      return m.invoke(loader, args);
    };
  }

Again not actually tested or compiled. (Mostly just copy/paste from the
current Proxy.java code.)

Cheers,

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]