OSDN Git Service

* java/lang/Class.h (_Jv_FindInterpreterMethod): Change return type
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / Package.java
index f09814b..0bf4315 100644 (file)
@@ -1,5 +1,5 @@
 /* Package.java -- information about a package
-   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -15,8 +15,8 @@ General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
 
 Linking this library statically or dynamically with other modules is
 making a combined work based on this library.  Thus, the terms and
@@ -41,6 +41,7 @@ import java.net.URL;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 
+
 /**
  * Everything you ever wanted to know about a package. This class makes it
  * possible to attach specification and implementation information to a
@@ -63,7 +64,7 @@ import java.util.StringTokenizer;
  * then the other version, etc. (If a version has no minor, micro, etc numbers
  * then they are considered the be 0.)
  *
- * @author Mark Wielaard <mark@klomp.org>
+ * @author Mark Wielaard (mark@klomp.org)
  * @see ClassLoader#definePackage(String, String, String, String, String,
  *      String, String, URL)
  * @since 1.2
@@ -72,28 +73,28 @@ import java.util.StringTokenizer;
 public class Package
 {
   /** The name of the Package */
-  final private String name;
+  private final String name;
 
   /** The name if the implementation */
-  final private String implTitle;
+  private final String implTitle;
 
   /** The vendor that wrote this implementation */
-  final private String implVendor;
+  private final String implVendor;
 
   /** The version of this implementation */
-  final private String implVersion;
+  private final String implVersion;
 
   /** The name of the specification */
-  final private String specTitle;
+  private final String specTitle;
 
   /** The name of the specification designer */
-  final private String specVendor;
+  private final String specVendor;
 
   /** The version of this specification */
-  final private String specVersion;
+  private final String specVersion;
 
   /** If sealed the origin of the package classes, otherwise null */
-  final private URL sealed;
+  private final URL sealed;
 
   /**
    * A package local constructor for the Package class. All parameters except
@@ -227,7 +228,10 @@ public class Package
    * <code>getSpecificationVersion</code>.
    *
    * @param version the (minimal) desired version of the specification
-   * @throws NumberFormatException if either version string is invalid
+   *
+   * @return true if the version is compatible, false otherwise
+   *
+   * @Throws NumberFormatException if either version string is invalid
    * @throws NullPointerException if either version string is null
    */
   public boolean isCompatibleWith(String version)
@@ -269,9 +273,8 @@ public class Package
   public static Package getPackage(String name)
   {
     // Get the caller's classloader
-    Class c = VMSecurityManager.getClassContext()[1];
-    ClassLoader cl = c.getClassLoader();
-    return cl != null ? cl.getPackage(name) : null;
+    ClassLoader cl = VMSecurityManager.currentClassLoader(Package.class);
+    return cl != null ? cl.getPackage(name) : VMClassLoader.getPackage(name);
   }
 
   /**
@@ -283,12 +286,9 @@ public class Package
   public static Package[] getPackages()
   {
     // Get the caller's classloader
-    Class c = VMSecurityManager.getClassContext()[1];
+    Class c = VMSecurityManager.getClassContext(Package.class)[1];
     ClassLoader cl = c.getClassLoader();
-    // Sun's implementation returns the packages loaded by the bootstrap
-    // classloader if cl is null, but right now our bootstrap classloader
-    // does not create any Packages.
-    return cl != null ? cl.getPackages() : new Package[0];
+    return cl != null ? cl.getPackages() : VMClassLoader.getPackages();
   }
 
   /**