Hi, I removed the VMPackage class, because Package.getDeclaredAnnotations can easily be implemented without VM specific code. Implementing Package.getDeclaredAnnotations required access to the class loader that defined the package, so I added a ClassLoader argument to the Package constructor. If you're a VM maintainer and you use a custom version of VMClassLoader, this is a breaking change and your version of VMClassLoader will have to be updated as well.
I will shortly merge these changes with the trunk. Regards, Jeroen 2006-04-21 Jeroen Frijters <[EMAIL PROTECTED]> * 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.
Index: java/lang/ClassLoader.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/lang/ClassLoader.java,v retrieving revision 1.31.2.15 diff -u -r1.31.2.15 ClassLoader.java --- java/lang/ClassLoader.java 14 Dec 2005 09:30:45 -0000 1.31.2.15 +++ java/lang/ClassLoader.java 23 Apr 2006 08:50:49 -0000 @@ -836,7 +836,7 @@ 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); Index: java/lang/Package.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/lang/Package.java,v retrieving revision 1.11.2.4 diff -u -r1.11.2.4 Package.java --- java/lang/Package.java 2 Aug 2005 20:12:23 -0000 1.11.2.4 +++ java/lang/Package.java 23 Apr 2006 08:51:26 -0000 @@ -101,6 +101,9 @@ /** 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 @@ */ 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 @@ this.specVendor = specVendor; this.specVersion = specVersion; this.sealed = sealed; + this.loader = loader; } /** @@ -368,7 +373,15 @@ */ 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]; + } } /** Index: vm/reference/java/lang/VMClassLoader.java =================================================================== RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMClassLoader.java,v retrieving revision 1.16.2.14 diff -u -r1.16.2.14 VMClassLoader.java --- vm/reference/java/lang/VMClassLoader.java 17 Apr 2006 09:32:39 -0000 1.16.2.14 +++ vm/reference/java/lang/VMClassLoader.java 23 Apr 2006 08:52:53 -0000 @@ -101,6 +101,7 @@ "GNU Classpath", "GNU", Configuration.CLASSPATH_VERSION, + null, null); definedPackages.put(packages[i], p); Index: vm/reference/java/lang/VMPackage.java =================================================================== RCS file: vm/reference/java/lang/VMPackage.java diff -N vm/reference/java/lang/VMPackage.java --- vm/reference/java/lang/VMPackage.java 21 Sep 2005 21:32:40 -0000 1.1.2.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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 ([EMAIL PROTECTED]) - */ -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