classpath
[Top][All Lists]
Advanced

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

Re: currentClassLoader problem


From: Tom Tromey
Subject: Re: currentClassLoader problem
Date: 17 Mar 2004 12:48:38 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

On the subject of VMClassLoader, I had to make some changes to
VMClassLoader.getSystemClassLoader to make it more correct.  At least, 
according to my reading of the spec.

In particular, I think a class loader specified by
java.system.class.loader has to be loaded with the default system
class loader, but Classpath doesn't do this.

I've appended my version of VMClassLoader.getSystemClassLoader.
It has some gcj-specific bits in it.  I'd be curious to hear what
other people think...

Tom

  static native ClassLoader getSystemClassLoaderInternal();

  static ClassLoader getSystemClassLoader()
  {
    // This method is called as the initialization of systemClassLoader,
    // so if there is a null value, this is the first call and we must check
    // for java.system.class.loader.
    String loader = System.getProperty("java.system.class.loader");
    ClassLoader default_sys = getSystemClassLoaderInternal();
    if (loader != null)
      {
        try
          {
            Class load_class = Class.forName(loader, true, default_sys);
            Constructor c
              = load_class.getConstructor(new Class[] { ClassLoader.class });
            default_sys
              = (ClassLoader) c.newInstance(new Object[] { default_sys });
          }
        catch (Exception e)
          {
            System.err.println("Requested system classloader "
                               + loader + " failed, using "
                               + "gnu.gcj.runtime.VMClassLoader");
            e.printStackTrace();
          }
      }
    return default_sys;
  }




reply via email to

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