summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@sumatra.nl>2006-04-23 09:32:28 +0000
committerJeroen Frijters <jeroen@sumatra.nl>2006-04-23 09:32:28 +0000
commit8b87df8b7b68779ae88c6f40f5e07c86183ed0fa (patch)
treec006662eaf4e328bcf6d385033f8956feaca24cc
parent429627ad923c4ad26031679827c0cfc8f49c0801 (diff)
downloadclasspath-8b87df8b7b68779ae88c6f40f5e07c86183ed0fa.tar.gz
2006-04-21 Jeroen Frijters <jeroen@frijters.net>
* java/lang/ClassLoader.java (definePackage): Added argument to Package constructor. * java/lang/Package.java (Package): Added ClassLoader argument. (loader): New field. (getDeclaredAnnotations): Implemented without help from VMPackage. * vm/reference/java/lang/VMClassLoader.java (static): Added argument to Package constructor. * vm/reference/java/lang/VMPackage.java: Removed.
-rw-r--r--ChangeLog11
-rw-r--r--java/lang/ClassLoader.java2
-rw-r--r--java/lang/Package.java17
-rw-r--r--vm/reference/java/lang/VMClassLoader.java1
-rw-r--r--vm/reference/java/lang/VMPackage.java76
5 files changed, 28 insertions, 79 deletions
diff --git a/ChangeLog b/ChangeLog
index a7adb0379..dcf043fae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2006-04-21 Jeroen Frijters <jeroen@frijters.net>
+ * java/lang/ClassLoader.java (definePackage): Added argument to
+ Package constructor.
+ * java/lang/Package.java (Package): Added ClassLoader argument.
+ (loader): New field.
+ (getDeclaredAnnotations): Implemented without help from VMPackage.
+ * vm/reference/java/lang/VMClassLoader.java (static): Added argument
+ to Package constructor.
+ * vm/reference/java/lang/VMPackage.java: Removed.
+
+2006-04-21 Jeroen Frijters <jeroen@frijters.net>
+
* java/lang/reflect/AccessibleObject.java:
Implemented AnnotatedElement.
(getAnnotation, getAnnotations, getDeclaredAnnotations,
diff --git a/java/lang/ClassLoader.java b/java/lang/ClassLoader.java
index d0f6ac42a..4cdfe9299 100644
--- a/java/lang/ClassLoader.java
+++ b/java/lang/ClassLoader.java
@@ -836,7 +836,7 @@ public abstract class ClassLoader
throw new IllegalArgumentException("Package " + name
+ " already defined");
Package p = new Package(name, specTitle, specVendor, specVersion,
- implTitle, implVendor, implVersion, sealed);
+ implTitle, implVendor, implVersion, sealed, this);
synchronized (definedPackages)
{
definedPackages.put(name, p);
diff --git a/java/lang/Package.java b/java/lang/Package.java
index 0b436fe81..8e95f84a6 100644
--- a/java/lang/Package.java
+++ b/java/lang/Package.java
@@ -101,6 +101,9 @@ public class Package
/** If sealed the origin of the package classes, otherwise null */
private final URL sealed;
+ /** The class loader that defined this package */
+ private ClassLoader loader;
+
/**
* A package local constructor for the Package class. All parameters except
* the <code>name</code> of the package may be <code>null</code>.
@@ -118,7 +121,8 @@ public class Package
*/
Package(String name,
String specTitle, String specVendor, String specVersion,
- String implTitle, String implVendor, String implVersion, URL sealed)
+ String implTitle, String implVendor, String implVersion, URL sealed,
+ ClassLoader loader)
{
if (name == null)
throw new IllegalArgumentException("null Package name");
@@ -131,6 +135,7 @@ public class Package
this.specVendor = specVendor;
this.specVersion = specVersion;
this.sealed = sealed;
+ this.loader = loader;
}
/**
@@ -368,7 +373,15 @@ public class Package
*/
public Annotation[] getDeclaredAnnotations()
{
- return VMPackage.getDeclaredAnnotations(this);
+ try
+ {
+ Class pkgInfo = Class.forName(name + ".package-info", false, loader);
+ return pkgInfo.getDeclaredAnnotations();
+ }
+ catch (ClassNotFoundException _)
+ {
+ return new Annotation[0];
+ }
}
/**
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java
index 218d60971..48652c879 100644
--- a/vm/reference/java/lang/VMClassLoader.java
+++ b/vm/reference/java/lang/VMClassLoader.java
@@ -101,6 +101,7 @@ final class VMClassLoader
"GNU Classpath",
"GNU",
Configuration.CLASSPATH_VERSION,
+ null,
null);
definedPackages.put(packages[i], p);
diff --git a/vm/reference/java/lang/VMPackage.java b/vm/reference/java/lang/VMPackage.java
deleted file mode 100644
index 45e3cd924..000000000
--- a/vm/reference/java/lang/VMPackage.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* VMPackage.java -- VM Specific Package methods
- Copyright (C) 2005 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-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., 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
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-import java.lang.annotation.Annotation;
-
-/*
- * This class is a reference version, mainly for compiling a class library
- * jar. It is likely that VM implementers replace this with their own
- * version that can communicate effectively with the VM.
- */
-
-/**
- * This class provides static methods to be implemented by a VM in order
- * to support the full functionality of the <code>Package</code> class.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- */
-final class VMPackage
-{
-
- // Only static methods. Cannot be instantiated.
- private VMPackage()
- {
- }
-
- /**
- * Returns all annotations directly defined by the specified package. If
- * there are no annotations associated with this package, then a zero-length
- * array will be returned. The returned array may be modified by the client
- * code, but this will have no effect on the annotation content of this
- * class, and hence no effect on the return value of this method for
- * future callers.
- *
- * @param pack the package whose annotations should be returned.
- * @return the annotations directly defined by the specified package.
- * @since 1.5
- */
- static native Annotation[] getDeclaredAnnotations(Package pack);
-
-} // class VMPackage