You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/05/29 07:24:34 UTC
svn commit: r410023 - in /incubator/harmony/enhanced/classlib/trunk/modules:
luni-kernel/src/main/java/java/lang/reflect/ luni/META-INF/
luni/src/main/java/java/lang/reflect/
Author: mloenko
Date: Sun May 28 22:24:33 2006
New Revision: 410023
URL: http://svn.apache.org/viewvc?rev=410023&view=rev
Log:
HARMONY-520 patch applied
([classlib][luni] java.lang.refleft Java 5 updates)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/AccessibleObject.java
incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Array.java
incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Field.java
incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Method.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/META-INF/MANIFEST.MF
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericDeclaration.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Type.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/TypeVariable.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/AccessibleObject.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/AccessibleObject.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/AccessibleObject.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/AccessibleObject.java Sun May 28 22:24:33 2006
@@ -15,8 +15,10 @@
package java.lang.reflect;
+import java.lang.annotation.Annotation;
+
/**
- * This class must be implemented by the vm vendor. This class is the superclass
+ * This class must be implemented by the VM vendor. This class is the superclass
* of all member reflect classes (Field, Constructor, Method). AccessibleObject
* provides the ability to toggle access checks for these objects. By default
* accessing a member (for example, setting a field or invoking a method) checks
@@ -31,8 +33,9 @@
* @see Constructor
* @see Method
* @see ReflectPermission
+ * @since 1.2
*/
-public class AccessibleObject {
+public class AccessibleObject implements AnnotatedElement {
static final Object[] emptyArgs = new Object[0];
/**
@@ -89,6 +92,22 @@
public void setAccessible(boolean flag) throws SecurityException {
return;
}
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+ return false;
+ }
+
+ public Annotation[] getDeclaredAnnotations() {
+ return new Annotation[0];
+ }
+
+ public Annotation[] getAnnotations() {
+ return new Annotation[0];
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ return null;
+ }
static Object[] marshallArguments(Class[] parameterTypes, Object[] args)
throws IllegalArgumentException {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Array.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Array.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Array.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Array.java Sun May 28 22:24:33 2006
@@ -230,10 +230,10 @@
public static native short getShort(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
- private static native Object multiNewArrayImpl(Class componentType,
+ private static native Object multiNewArrayImpl(Class<?> componentType,
int dimensions, int[] dimensionsArray);
- private static native Object newArrayImpl(Class componentType, int dimension);
+ private static native Object newArrayImpl(Class<?> componentType, int dimension);
/**
* Return a new multidimensional array of the specified component type and
@@ -255,7 +255,7 @@
* limit of the number of dimension for an array (currently
* 255)
*/
- public static Object newInstance(Class componentType, int[] dimensions)
+ public static Object newInstance(Class<?> componentType, int[] dimensions)
throws NegativeArraySizeException, IllegalArgumentException {
return null;
}
@@ -274,7 +274,7 @@
* @exception java.lang.NegativeArraySizeException
* if the size if negative
*/
- public static Object newInstance(Class componentType, int size)
+ public static Object newInstance(Class<?> componentType, int size)
throws NegativeArraySizeException {
return null;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java Sun May 28 22:24:33 2006
@@ -15,48 +15,138 @@
package java.lang.reflect;
+import java.lang.annotation.Annotation;
+
/**
- * This class must be implemented by the vm vendor. This class models a
+ * This class must be implemented by the VM vendor. This class models a
* constructor. Information about the constructor can be accessed, and the
* constructor can be invoked dynamically.
*
*/
-public final class Constructor<T> extends AccessibleObject implements Member {
+public final class Constructor<T> extends AccessibleObject implements GenericDeclaration, Member {
- /**
- * Compares the specified object to this Constructor and answer if they are
- * equal. The object must be an instance of Constructor with the same
- * defining class and parameter types.
- *
- * @param object
- * the object to compare
- * @return true if the specified object is equal to this Constructor, false
- * otherwise
- * @see #hashCode
- */
+ public TypeVariable<Constructor<T>>[] getTypeParameters() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Returns the String representation of the constructor's declaration,
+ * including the type parameters.
+ * </p>
+ *
+ * @return An instance of String.
+ * @since 1.5
+ */
+ public String toGenericString() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets the parameter types as an array of {@link Type} instances, in
+ * declaration order. If the constructor has no parameters, then an empty
+ * array is returned.
+ * </p>
+ *
+ * @return An array of {@link Type} instances.
+ * @throws GenericSignatureFormatError if the generic method signature is
+ * invalid.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ * @since 1.5
+ */
+ public Type[] getGenericParameterTypes() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets the exception types as an array of {@link Type} instances. If the
+ * constructor has no declared exceptions, then an empty array is returned.
+ * </p>
+ *
+ * @return An array of {@link Type} instances.
+ * @throws GenericSignatureFormatError if the generic method signature is
+ * invalid.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ * @since 1.5
+ */
+ public Type[] getGenericExceptionTypes() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets an array of arrays that represent the annotations of the formal
+ * parameters of this constructor. If there are no parameters on this
+ * constructor, then an empty array is returned. If there are no annotations
+ * set, then and array of empty arrays is returned.
+ * </p>
+ *
+ * @return An array of arrays of {@link Annotation} instances.
+ * @since 1.5
+ */
+ public Annotation[][] getParameterAnnotations() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Indicates whether or not this constructor takes a variable number
+ * argument.
+ * </p>
+ *
+ * @return A value of <code>true</code> if a vararg is declare, otherwise
+ * <code>false</code>.
+ * @since 1.5
+ */
+ public boolean isVarArgs() {
+ return false;
+ }
+
+ public boolean isSynthetic() {
+ return false;
+ }
+
+ /**
+ * Compares the specified object to this Constructor and answer if they are
+ * equal. The object must be an instance of Constructor with the same
+ * defining class and parameter types.
+ *
+ * @param object the object to compare
+ * @return true if the specified object is equal to this Constructor, false
+ * otherwise
+ * @see #hashCode
+ */
public boolean equals(Object object) {
return false;
}
/**
- * Return the java.lang.Class associated with the class that defined this
+ * Return the {@link Class} associated with the class that defined this
* constructor.
*
* @return the declaring class
*/
- public Class getDeclaringClass() {
+ public Class<T> getDeclaringClass() {
return null;
}
/**
- * Return an array of the java.lang.Class objects associated with the
+ * Return an array of the {@link Class} objects associated with the
* exceptions declared to be thrown by this constructor. If the constructor
* was not declared to throw any exceptions, the array returned will be
* empty.
*
* @return the declared exception classes
*/
- public Class[] getExceptionTypes() {
+ public Class<?>[] getExceptionTypes() {
return null;
}
@@ -82,13 +172,13 @@
}
/**
- * Return an array of the java.lang.Class objects associated with the
+ * Return an array of the {@link Class} objects associated with the
* parameter types of this constructor. If the constructor was declared with
* no parameters, the array returned will be empty.
*
* @return the parameter types
*/
- public Class[] getParameterTypes() {
+ public Class<?>[] getParameterTypes() {
return null;
}
@@ -146,7 +236,7 @@
* if an exception was thrown by the invoked constructor
* @see java.lang.reflect.AccessibleObject
*/
- public Object newInstance(Object args[]) throws InstantiationException,
+ public T newInstance(Object... args) throws InstantiationException,
IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
return null;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Field.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Field.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Field.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Field.java Sun May 28 22:24:33 2006
@@ -16,24 +16,71 @@
package java.lang.reflect;
/**
- * This class must be implemented by the vm vendor. This class models a field.
+ * This class must be implemented by the VM vendor. This class models a field.
* Information about the field can be accessed, and the field's value can be
* accessed dynamically.
*
*/
public final class Field extends AccessibleObject implements Member {
+ public boolean isSynthetic() {
+ return false;
+ }
+
+ /**
+ * <p>
+ * Returns the String representation of the field's declaration, including
+ * the type parameters.
+ * </p>
+ *
+ * @return An instance of String.
+ * @since 1.5
+ */
+ public String toGenericString() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Indicates whether or not this field is an enumeration constant.
+ * </p>
+ *
+ * @return A value of <code>true</code> if this field is an enumeration
+ * constant, otherwise <code>false</code>.
+ * @since 1.5
+ */
+ public boolean isEnumConstant() {
+ return false;
+ }
+
+ /**
+ * <p>
+ * Gets the declared type of this field.
+ * </p>
+ *
+ * @return An instance of {@link Type}.
+ * @throws GenericSignatureFormatError if the generic method signature is
+ * invalid.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ * @since 1.5
+ */
+ public Type getGenericType() {
+ return null;
+ }
+
/**
- * Compares the specified object to this Field and answer if they are equal.
- * The object must be an instance of Field with the same defining class and
- * name.
- *
- * @param object
- * the object to compare
- * @return true if the specified object is equal to this Field, false
- * otherwise
- * @see #hashCode
- */
+ * Compares the specified object to this Field and answer if they are equal.
+ * The object must be an instance of Field with the same defining class and
+ * name.
+ *
+ * @param object the object to compare
+ * @return true if the specified object is equal to this Field, false
+ * otherwise
+ * @see #hashCode
+ */
public boolean equals(Object object) {
return false;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Method.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Method.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Method.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Method.java Sun May 28 22:24:33 2006
@@ -15,13 +15,147 @@
package java.lang.reflect;
+import java.lang.annotation.Annotation;
+
/**
- * This class must be implemented by the vm vendor. This class models a method.
+ * This class must be implemented by the VM vendor. This class models a method.
* Information about the method can be accessed, and the method can be invoked
* dynamically.
*
*/
-public final class Method extends AccessibleObject implements Member {
+public final class Method extends AccessibleObject implements GenericDeclaration, Member {
+
+ public TypeVariable<Method>[] getTypeParameters() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Returns the String representation of the method's declaration, including
+ * the type parameters.
+ * </p>
+ *
+ * @return An instance of String.
+ * @since 1.5
+ */
+ public String toGenericString() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets the parameter types as an array of {@link Type} instances, in
+ * declaration order. If the method has no parameters, then an empty array
+ * is returned.
+ * </p>
+ *
+ * @return An array of {@link Type} instances.
+ * @throws GenericSignatureFormatError if the generic method signature is
+ * invalid.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ * @since 1.5
+ */
+ public Type[] getGenericParameterTypes() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets the exception types as an array of {@link Type} instances. If the
+ * method has no declared exceptions, then an empty array is returned.
+ * </p>
+ *
+ * @return An array of {@link Type} instances.
+ * @throws GenericSignatureFormatError if the generic method signature is
+ * invalid.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ * @since 1.5
+ */
+ public Type[] getGenericExceptionTypes() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets the return type as a {@link Type} instance.
+ * </p>
+ *
+ * @return A {@link Type} instance.
+ * @throws GenericSignatureFormatError if the generic method signature is
+ * invalid.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ * @since 1.5
+ */
+ public Type getGenericReturnType() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Gets an array of arrays that represent the annotations of the formal
+ * parameters of this method. If there are no parameters on this method,
+ * then an empty array is returned. If there are no annotations set, then
+ * and array of empty arrays is returned.
+ * </p>
+ *
+ * @return An array of arrays of {@link Annotation} instances.
+ * @since 1.5
+ */
+ public Annotation[][] getParameterAnnotations() {
+ return null;
+ }
+
+ /**
+ * <p>
+ * Indicates whether or not this method takes a variable number argument.
+ * </p>
+ *
+ * @return A value of <code>true</code> if a vararg is declare, otherwise
+ * <code>false</code>.
+ * @since 1.5
+ */
+ public boolean isVarArgs() {
+ return false;
+ }
+
+ /**
+ * <p>
+ * Indicates whether or not this method is a bridge.
+ * </p>
+ *
+ * @return A value of <code>true</code> if this method's a bridge,
+ * otherwise <code>false</code>.
+ * @since 1.5
+ */
+ public boolean isBridge() {
+ return false;
+ }
+
+ public boolean isSynthetic() {
+ return false;
+ }
+
+ /**
+ * <p>Gets the default value for the annotation member represented by
+ * this method.</p>
+ * @return The default value or <code>null</code> if none.
+ * @throws TypeNotPresentException if the annotation is of type {@link Class}
+ * and no definition can be found.
+ * @since 1.5
+ */
+ public Object getDefaultValue() {
+ return null;
+ }
+
/**
* Compares the specified object to this Method and answer if they are
* equal. The object must be an instance of Method with the same defining
@@ -39,7 +173,7 @@
/**
* Return the java.lang.Class associated with the class that defined this
- * constructor.
+ * method.
*
* @return the declaring class
*/
@@ -59,7 +193,7 @@
}
/**
- * Return the modifiers for the modelled constructor. The Modifier class
+ * Return the modifiers for the modelled method. The Modifier class
* should be used to decode the result.
*
* @return the modifiers
@@ -152,7 +286,7 @@
* @param receiver
* The object on which to call the modelled method
* @param args
- * the arguments to the constructor
+ * the arguments to the method
* @return the new, initialized, object
* @exception java.lang.NullPointerException
* if the receiver is null for a non-static method
@@ -163,7 +297,7 @@
* receiver is incompatible with the declaring class, or an
* argument could not be converted by a widening conversion
* @exception java.lang.reflect.InvocationTargetException
- * if an exception was thrown by the invoked constructor
+ * if an exception was thrown by the invoked method
* @see java.lang.reflect.AccessibleObject
*/
public Object invoke(Object receiver, Object args[])
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/META-INF/MANIFEST.MF?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/META-INF/MANIFEST.MF (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/META-INF/MANIFEST.MF Sun May 28 22:24:33 2006
@@ -6,7 +6,8 @@
Bundle-ClassPath: .
Eclipse-JREBundle: true
Eclipse-ExtensibleAPI: true
-Import-Package: java.math,
+Import-Package: java.lang.annotation,
+ java.math,
java.nio,
java.nio.channels,
java.nio.channels.spi,
@@ -19,9 +20,9 @@
java.util.zip,
javax.net.ssl,
org.apache.harmony.nio,
- tests.support;resolution:=optional;hy_usage=test,
- tests.support.resource;resolution:=optional;hy_usage=test,
- tests.util;resolution:=optional;hy_usage=test
+ tests.support;hy_usage=test;resolution:=optional,
+ tests.support.resource;hy_usage=test;resolution:=optional,
+ tests.util;hy_usage=test;resolution:=optional
Export-Package: java.io,
java.lang,
java.lang.ref,
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericDeclaration.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericDeclaration.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericDeclaration.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericDeclaration.java Sun May 28 22:24:33 2006
@@ -16,7 +16,8 @@
package java.lang.reflect;
/**
- * Common interface for entities that have type variables.
+ * Common interface for entities that have type variables.
+ * @since 1.5
*/
public interface GenericDeclaration {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java Sun May 28 22:24:33 2006
@@ -30,12 +30,12 @@
public static final int DECLARED = 1;
/**
- * Return the java.lang.Class associated with the class that defined this
+ * Return the {@link Class} associated with the class that defined this
* member.
*
* @return the declaring class
*/
- public abstract Class getDeclaringClass();
+ Class getDeclaringClass();
/**
* Return the modifiers for the member. The Modifier class should be used to
@@ -44,12 +44,19 @@
* @return the modifiers
* @see java.lang.reflect.Modifier
*/
- public abstract int getModifiers();
+ int getModifiers();
/**
* Return the name of the member.
*
* @return the name
*/
- public abstract String getName();
+ String getName();
+
+ /**
+ * <p>Indicates whether or not this member is synthetic (artificially introduced by
+ * the compiler).</p>
+ * @return A value of <code>true</code> if synthetic, otherwise <code>false</code>.
+ */
+ boolean isSynthetic();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java Sun May 28 22:24:33 2006
@@ -15,7 +15,7 @@
package java.lang.reflect;
-
+import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
@@ -29,16 +29,17 @@
* This class provides methods to creating dynamic proxy classes and instances.
*
* @see java.lang.reflect.InvocationHandler
+ * @since 1.3
*/
-public class Proxy implements java.io.Serializable {
+public class Proxy implements Serializable {
private static final long serialVersionUID = -2222568056686623797L;
// maps class loaders to created classes by interface names
- private static Map loaderCache = new WeakHashMap();
+ private static final Map<ClassLoader, Map<String, WeakReference<Class<?>>>> loaderCache = new WeakHashMap<ClassLoader, Map<String, WeakReference<Class<?>>>>();
// to find previously created types
- private static Map proxyCache = new WeakHashMap();
+ private static final Map<Class<?>, String> proxyCache = new WeakHashMap<Class<?>, String>();
private static int NextClassNameIndex = 0;
@@ -71,7 +72,7 @@
* if either <code>interfaces</code> or any of its elements
* are <code>null</code>.
*/
- public static Class getProxyClass(ClassLoader loader, Class[] interfaces)
+ public static Class<?> getProxyClass(ClassLoader loader, Class<?>[] interfaces)
throws IllegalArgumentException {
// check that interfaces are a valid array of visible interfaces
if (interfaces == null)
@@ -110,15 +111,15 @@
// search cache for matching proxy class using the class loader
synchronized (loaderCache) {
- Map interfaceCache = (Map) loaderCache.get(loader);
+ Map<String, WeakReference<Class<?>>> interfaceCache = loaderCache.get(loader);
if (interfaceCache == null)
- loaderCache.put(loader, (interfaceCache = new HashMap()));
+ loaderCache.put(loader, (interfaceCache = new HashMap<String, WeakReference<Class<?>>>()));
String interfaceKey = "";
if (interfaces.length == 1) {
interfaceKey = interfaces[0].getName();
} else {
- StringBuffer names = new StringBuffer();
+ StringBuilder names = new StringBuilder();
for (int i = 0, length = interfaces.length; i < length; i++) {
names.append(interfaces[i].getName());
names.append(' ');
@@ -126,9 +127,8 @@
interfaceKey = names.toString();
}
- Class newClass;
- WeakReference ref = (WeakReference) interfaceCache
- .get(interfaceKey);
+ Class<?> newClass;
+ WeakReference<Class<?>> ref = interfaceCache.get(interfaceKey);
if (ref == null) {
String nextClassName = "$Proxy" + NextClassNameIndex++;
if (commonPackageName != null)
@@ -141,12 +141,12 @@
'/'), classFileBytes);
// Need a weak reference to the class so it can
// be unloaded if the class loader is discarded
- interfaceCache.put(interfaceKey, new WeakReference(newClass));
+ interfaceCache.put(interfaceKey, new WeakReference<Class<?>>(newClass));
synchronized (proxyCache) {
proxyCache.put(newClass, ""); // the value is unused
}
} else {
- newClass = (Class) ref.get();
+ newClass = ref.get();
}
return newClass;
}
@@ -172,21 +172,22 @@
* if the interfaces or any of its elements are null.
*/
public static Object newProxyInstance(ClassLoader loader,
- Class[] interfaces, InvocationHandler h)
+ Class<?>[] interfaces, InvocationHandler h)
throws IllegalArgumentException {
if (h != null) {
try {
return getProxyClass(loader, interfaces).getConstructor(
- new Class[] { InvocationHandler.class }).newInstance(
+ new Class<?>[] { InvocationHandler.class }).newInstance(
new Object[] { h });
} catch (NoSuchMethodException ex) {
- throw new InternalError(ex.toString());
+ throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
} catch (IllegalAccessException ex) {
- throw new InternalError(ex.toString());
+ throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
} catch (InstantiationException ex) {
- throw new InternalError(ex.toString());
+ throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
} catch (InvocationTargetException ex) {
- throw new InternalError(ex.getTargetException().toString());
+ Throwable target = ex.getTargetException();
+ throw (InternalError)(new InternalError(target.toString()).initCause(target));
}
}
throw new NullPointerException();
@@ -201,7 +202,7 @@
* @exception NullPointerException
* if the class is null.
*/
- public static boolean isProxyClass(Class cl) {
+ public static boolean isProxyClass(Class<?> cl) {
if (cl != null) {
synchronized (proxyCache) {
return proxyCache.containsKey(cl);
@@ -228,7 +229,7 @@
throw new IllegalArgumentException(Msg.getString("K00f1"));
}
- private static native Class defineClassImpl(ClassLoader classLoader,
+ private static native Class<?> defineClassImpl(ClassLoader classLoader,
String className, byte[] classFileBytes);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Type.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Type.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Type.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Type.java Sun May 28 22:24:33 2006
@@ -17,6 +17,7 @@
/**
* Common interface for all Java types.
+ * @since 1.5
*/
public interface Type {
// Empty
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/TypeVariable.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/TypeVariable.java?rev=410023&r1=410022&r2=410023&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/TypeVariable.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/TypeVariable.java Sun May 28 22:24:33 2006
@@ -15,14 +15,22 @@
package java.lang.reflect;
+/**
+ * <p>Represents a type variable.</p>
+ *
+ * @param <D>
+ * @since 1.5
+ */
public interface TypeVariable<D extends GenericDeclaration> extends Type {
/**
* Answers the upper bounds of the type variable.
*
* @return array of type variable's upper bounds.
- * @throws MalformedParameterizedTypeException
- * @throws TypeNotPresentException
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
*/
Type[] getBounds();