Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* Package.java -- information about a package
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -39,6 +40,8 @@ package java.lang;
|
||||
|
||||
import gnu.classpath.VMStackWalker;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.net.URL;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
@@ -70,9 +73,10 @@ import java.util.StringTokenizer;
|
||||
* @see ClassLoader#definePackage(String, String, String, String, String,
|
||||
* String, String, URL)
|
||||
* @since 1.2
|
||||
* @status updated to 1.4
|
||||
* @status updated to 1.5
|
||||
*/
|
||||
public class Package
|
||||
implements AnnotatedElement
|
||||
{
|
||||
/** The name of the Package */
|
||||
private final String name;
|
||||
@@ -98,6 +102,20 @@ 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;
|
||||
|
||||
/** @deprecated Please use the other constructor that takes the class loader
|
||||
* that defines the Package.
|
||||
*/
|
||||
Package(String name,
|
||||
String specTitle, String specVendor, String specVersion,
|
||||
String implTitle, String implVendor, String implVersion, URL sealed)
|
||||
{
|
||||
this(name, specTitle, specVendor, specVersion, implTitle, implVendor,
|
||||
implVersion, sealed, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A package local constructor for the Package class. All parameters except
|
||||
* the <code>name</code> of the package may be <code>null</code>.
|
||||
@@ -115,7 +133,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");
|
||||
@@ -128,6 +147,7 @@ public class Package
|
||||
this.specVendor = specVendor;
|
||||
this.specVersion = specVersion;
|
||||
this.sealed = sealed;
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +253,7 @@ public class Package
|
||||
*
|
||||
* @return true if the version is compatible, false otherwise
|
||||
*
|
||||
* @Throws NumberFormatException if either version string is invalid
|
||||
* @throws NumberFormatException if either version string is invalid
|
||||
* @throws NullPointerException if either version string is null
|
||||
*/
|
||||
public boolean isCompatibleWith(String version)
|
||||
@@ -315,4 +335,82 @@ public class Package
|
||||
return ("package " + name + (specTitle == null ? "" : ", " + specTitle)
|
||||
+ (specVersion == null ? "" : ", version " + specVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this package's annotation for the specified annotation type,
|
||||
* or <code>null</code> if no such annotation exists.
|
||||
*
|
||||
* @param annotationClass the type of annotation to look for.
|
||||
* @return this package's annotation for the specified type, or
|
||||
* <code>null</code> if no such annotation exists.
|
||||
* @since 1.5
|
||||
*/
|
||||
/* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
|
||||
public Annotation getAnnotation(Class annotationClass)
|
||||
{
|
||||
Annotation foundAnnotation = null;
|
||||
Annotation[] annotations = getAnnotations();
|
||||
for (int i = 0; i < annotations.length; i++)
|
||||
if (annotations[i].annotationType() == annotationClass)
|
||||
foundAnnotation = annotations[i];
|
||||
return foundAnnotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all annotations associated with this 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
|
||||
* package, and hence no effect on the return value of this method for
|
||||
* future callers.
|
||||
*
|
||||
* @return this package' annotations.
|
||||
* @since 1.5
|
||||
*/
|
||||
public Annotation[] getAnnotations()
|
||||
{
|
||||
/** All a package's annotations are declared within it. */
|
||||
return getDeclaredAnnotations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all annotations directly defined by this 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
|
||||
* package, and hence no effect on the return value of this method for
|
||||
* future callers.
|
||||
*
|
||||
* @return the annotations directly defined by this package.
|
||||
* @since 1.5
|
||||
*/
|
||||
public Annotation[] getDeclaredAnnotations()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class pkgInfo = Class.forName(name + ".package-info", false, loader);
|
||||
return pkgInfo.getDeclaredAnnotations();
|
||||
}
|
||||
catch (ClassNotFoundException _)
|
||||
{
|
||||
return new Annotation[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an annotation for the specified type is associated
|
||||
* with this package. This is primarily a short-hand for using marker
|
||||
* annotations.
|
||||
*
|
||||
* @param annotationClass the type of annotation to look for.
|
||||
* @return true if an annotation exists for the specified type.
|
||||
* @since 1.5
|
||||
*/
|
||||
/* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
|
||||
public boolean isAnnotationPresent(Class
|
||||
annotationClass)
|
||||
{
|
||||
return getAnnotation(annotationClass) != null;
|
||||
}
|
||||
|
||||
} // class Package
|
||||
|
||||
Reference in New Issue
Block a user