Patch: FYI: fix getPackage for bootstrap loader

Tom Tromey tromey@redhat.com
Fri Dec 16 21:38:00 GMT 2005


I'm checking this in on the 4.1 branch and the trunk.

This fixes getPackage() on a class loaded by the bootstrap loader.
It is essentially a Classpath merge -- another lesson about the
difficulties of divergence.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* java/lang/Class.java (getPackage): Get package from
	VMClassLoader if needed.

Index: java/lang/Class.java
===================================================================
--- java/lang/Class.java	(revision 108588)
+++ java/lang/Class.java	(working copy)
@@ -455,8 +455,7 @@
   /**
    * Returns the <code>Package</code> in which this class is defined
    * Returns null when this information is not available from the
-   * classloader of this class or when the classloader of this class
-   * is null.
+   * classloader of this class.
    *
    * @return the package for this class, if it is available
    * @since 1.2
@@ -466,7 +465,8 @@
     ClassLoader cl = getClassLoader();
     if (cl != null)
       return cl.getPackage(getPackagePortion(getName()));
-    return null;
+    else
+      return VMClassLoader.getPackage(getPackagePortion(getName()));
   }
 
   /**



More information about the Java-patches mailing list