harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r405370 - in /incubator/harmony/enhanced/classlib/trunk/modules: luni-kernel/src/main/java/java/lang/ luni-kernel/src/main/java/java/lang/reflect/ luni/src/main/java/java/lang/
Date Tue, 09 May 2006 10:21:21 GMT
Author: tellison
Date: Tue May  9 03:21:16 2006
New Revision: 405370

URL: http://svn.apache.org/viewcvs?rev=405370&view=rev
Log:
Bringing java.lang.Class stubs closer to 1.5 spec, and fixing associated downstream effects.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Class.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Class.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Class.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Class.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Class.java
Tue May  9 03:21:16 2006
@@ -16,9 +16,13 @@
 package java.lang;
 
 import java.io.InputStream;
+import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
+import java.lang.reflect.GenericDeclaration;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.net.URL;
 import java.security.ProtectionDomain;
 
@@ -65,7 +69,8 @@
  * </dl>
  * 
  */
-public final class Class<T> implements java.io.Serializable {
+public final class Class<T> implements Serializable, GenericDeclaration, Type {
+
 	private static final long serialVersionUID = 3206093459760846163L;
 
 	/**
@@ -81,7 +86,7 @@
 	 *             If the class could not be found
 	 * @see java.lang.Class
 	 */
-	public static Class forName(String className) throws ClassNotFoundException {
+	public static Class<?> forName(String className) throws ClassNotFoundException {
 		return null;
 	}
 
@@ -102,7 +107,7 @@
 	 *             If the class could not be found
 	 * @see java.lang.Class
 	 */
-	public static Class forName(String className, boolean initializeBoolean,
+	public static Class<?> forName(String className, boolean initializeBoolean,
 			ClassLoader classLoader) throws ClassNotFoundException {
 		return null;
 	}
@@ -129,6 +134,41 @@
 		return;
 	}
 
+    /**
+     * Answers the annotation of the given type.
+     * If there is no annotation the method returns <code>null</code>.
+     * 
+     * @param annotationClass the annotation type.
+     * @return the annotation of the given type, or <code>null</code>
+     * if none.
+     */
+    // TODO: awaiting Annotation defn.
+//    public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
{
+//        return null;
+//    }
+
+    /**
+     * Answers all the annotations of the receiver.
+     * If there are no annotations then answers an empty array.
+     * 
+     * @return a copy of the array containing the receiver's annotations. 
+     */
+    // TODO: awaiting Annotation defn.
+//    public Annotation[] getAnnotations() {
+//        return null;
+//    }
+
+    /**
+     * Answers the canonical name of the receiver.
+     * If the receiver does not have a canonical name, as defined in
+     * the Java Language Spec, then the method returns <code>null</code>.
+     * 
+     * @return the receiver cannonical name, or <code>null</code>.
+     */
+    public String getCanonicalName() {
+        return null;
+    }
+
 	/**
 	 * Answers the classloader which was used to load the class represented by
 	 * the receiver. Answer null if the class was loaded by the system class
@@ -165,7 +205,7 @@
 	 * @return the component type of the receiver.
 	 * @see java.lang.Class
 	 */
-	public Class getComponentType() {
+	public Class<?> getComponentType() {
 		return null;
 	};
 
@@ -182,8 +222,8 @@
 	 *             if member access is not allowed
 	 * @see #getConstructors
 	 */
-	public Constructor getConstructor(Class parameterTypes[])
-			throws NoSuchMethodException, SecurityException {
+    public Constructor<T> getConstructor(Class... parameterTypes)
+        throws NoSuchMethodException, SecurityException {
 		return null;
 	}
 
@@ -200,6 +240,18 @@
 		return null;
 	}
 
+    /**
+     * Answers the annotations that are directly defined on this type.
+     * Annoations that are inherited are not included in the result.
+     * If there are no annotations, returns an empty array.
+     * 
+     * @return a copy of the array containing the receiver's defined annotaions.
+     */
+    // TODO Awaiting defn of Annotation
+//    public Annotation[] getDeclaredAnnotations() {
+//        return null;
+//    }
+
 	/**
 	 * Answers an array containing all class members of the class which the
 	 * receiver represents. Note that some of the fields which are returned may
@@ -227,10 +279,10 @@
 	 *             if member access is not allowed
 	 * @see #getConstructors
 	 */
-	public Constructor getDeclaredConstructor(Class parameterTypes[])
-			throws NoSuchMethodException, SecurityException {
-		return null;
-	}
+    public Constructor<T> getDeclaredConstructor(Class... parameterTypes)
+            throws NoSuchMethodException, SecurityException {
+        return null;
+    }
 
 	/**
 	 * Answers an array containing Constructor objects describing all
@@ -294,23 +346,24 @@
 	 *             if the method could not be found.
 	 * @throws SecurityException
 	 *             If member access is not allowed
+     * @throws NullPointerException if the name parameter is <code>null</code>.
 	 * @see #getMethods
 	 */
-	public Method getDeclaredMethod(String name, Class parameterTypes[])
-			throws NoSuchMethodException, SecurityException {
-		return null;
-	}
+    public Method getDeclaredMethod(String name, Class... parameterTypes)
+            throws NoSuchMethodException, SecurityException {
+        return null;
+    }
 
 	/**
-	 * Answers an array containing Method objects describing all methods which
-	 * are defined by the receiver. Note that some of the methods which are
-	 * returned may not be visible in the current execution context.
-	 * 
-	 * @throws SecurityException
-	 *             if member access is not allowed
-	 * @return the receiver's methods.
-	 * @see #getMethods
-	 */
+     * Answers an array containing Method objects describing all methods which
+     * are defined by the receiver. Note that some of the methods which are
+     * returned may not be visible in the current execution context.
+     * 
+     * @throws SecurityException
+     *             if member access is not allowed
+     * @return the receiver's methods.
+     * @see #getMethods
+     */
 	public Method[] getDeclaredMethods() throws SecurityException {
 		return null;
 	}
@@ -321,9 +374,44 @@
 	 * 
 	 * @return the declaring class of the receiver.
 	 */
-	public Class getDeclaringClass() {
+	public Class<?> getDeclaringClass() {
 		return null;
 	}
+    
+    /**
+     * Answers the class that directly encloses the receiver.  If there is no
+     * enclosing class the method returns <code>null</code>.
+     * 
+     * @return the enclosing class or <code>null</code>.
+     */
+    public Class<?> getEnclosingClass() {
+        return null;
+    }
+
+    /**
+     * TODO javadoc
+     * 
+     * @return
+     */
+    public Constructor<?> getEnclosingConstructor() {
+        return null;
+    }
+
+    /**
+     * TODO javadoc
+     * 
+     * @return
+     */
+    public Method getEnclosingMethod() {
+        return null;
+    }
+    
+    /**
+     * TODO javadoc
+     */
+    public T[] getEnumConstants() {
+        return null;
+    }
 
 	/**
 	 * Answers a Field object describing the field in the receiver named by the
@@ -356,6 +444,22 @@
 		return null;
 	}
 
+    /**
+     * TODO javadoc
+     * 
+     * @return
+     */
+    public Type[] getGenericInterfaces() {
+        return null;
+    }
+
+    /**
+     * TODO javadoc
+     */
+    public Type getGenericSuperclass() {
+        return null;
+    }
+    
 	/**
 	 * Answers an array of Class objects which match the interfaces specified in
 	 * the receiver classes <code>implements</code> declaration
@@ -381,20 +485,20 @@
 	 *             if member access is not allowed
 	 * @see #getMethods
 	 */
-	public Method getMethod(String name, Class parameterTypes[])
-			throws NoSuchMethodException, SecurityException {
-		return null;
-	}
+    public Method getMethod(String name, Class... parameterTypes)
+            throws NoSuchMethodException, SecurityException {
+        return null;
+    }
 
 	/**
-	 * Answers an array containing Method objects describing all methods which
-	 * are visible from the current execution context.
-	 * 
-	 * @return Method[] all visible methods starting from the receiver.
-	 * @throws SecurityException
-	 *             if member access is not allowed
-	 * @see #getDeclaredMethods
-	 */
+     * Answers an array containing Method objects describing all methods which
+     * are visible from the current execution context.
+     * 
+     * @return Method[] all visible methods starting from the receiver.
+     * @throws SecurityException
+     *             if member access is not allowed
+     * @see #getDeclaredMethods
+     */
 	public Method[] getMethods() throws SecurityException {
 		return null;
 	}
@@ -423,6 +527,18 @@
 		return null;
 	};
 
+    /**
+     * Answers the simple name of the receiver as defined in the source code.
+     * If there is no name (the class is anonymous) returns an empty string, and
+     * if the receiver is an array returns the name of the underlying type with
+     * square braces appended (e.g. <code>&quot;Integer[]&quot;</code>).
+     * 
+     * @return the simple name of the receiver.
+     */
+    public String getSimpleName() {
+        return null;
+    }
+
 	/**
 	 * Answers the ProtectionDomain of the receiver.
 	 * <p>
@@ -497,10 +613,44 @@
 	 * 
 	 * @return the receiver's superclass.
 	 */
-	public Class getSuperclass() {
+    public Class<? super T> getSuperclass() {
 		return null;
 	};
 
+    /**
+     * TODO javadoc
+     */
+    public TypeVariable<Class<T>>[] getTypeParameters() {
+        return null;
+    }
+
+    /**
+     * TODO javadoc
+     * 
+     * @return
+     */
+    public boolean isAnnotation() {
+        return false;
+    }
+
+    /**
+     * TODO javadoc
+     * 
+     * @param annotationClass
+     * @return
+     */
+    // TODO awaiting defn of annotation
+//    public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
{
+//        return false;
+//    }
+
+    /**
+     * TODO javadoc
+     */
+    public boolean isAnonymousClass() {
+        return false;
+    }
+    
 	/**
 	 * Answers true if the receiver represents an array class.
 	 * 
@@ -525,10 +675,17 @@
 	 * @throws NullPointerException
 	 *             if the parameter is null
 	 */
-	public boolean isAssignableFrom(Class cls) {
+	public boolean isAssignableFrom(Class<?> cls) {
 		return false;
 	};
 
+    /**
+     * TODO javadoc
+     */
+    public boolean isEnum() {
+        return false;
+    }
+
 	/**
 	 * Answers true if the argument is non-null and can be cast to the type of
 	 * the receiver. This is the runtime version of the <code>instanceof</code>
@@ -554,6 +711,26 @@
 		return false;
 	}
 
+    /**
+     * Answers whether the receiver is defined locally.
+     * 
+     * @return <code>true</code> if the class is local,
+     * otherwise <code>false</code>.
+     */
+    public boolean isLocalClass() {
+        return false;
+    }
+    
+    /**
+     * Answers whether the receiver is a member class.
+     * 
+     * @return <code>true</code> if the class is a member class,
+     * otherwise <code>false</code>.
+     */
+    public boolean isMemberClass() {
+        return false;
+    }
+    
 	/**
 	 * Answers true if the receiver represents a base type.
 	 * 
@@ -564,6 +741,16 @@
 		return false;
 	};
 
+    /**
+     * Answers whether the receiver is a synthetic type.
+     * 
+     * @return <code>true</code> if the receiver is a synthetic type
+     *         and <code>false</code> otherwise.
+     */
+    public boolean isSynthetic() {
+        return false;
+    }
+    
 	/**
 	 * Answers a new instance of the class represented by the receiver, created
 	 * by invoking the default (i.e. zero-argument) constructor. If there is no
@@ -579,7 +766,7 @@
 	 * @throws InstantiationException
 	 *             if the instance could not be created.
 	 */
-	public Object newInstance() throws IllegalAccessException,
+	public T newInstance() throws IllegalAccessException,
 			InstantiationException {
 		return null;
 	}
@@ -614,6 +801,32 @@
 	public boolean desiredAssertionStatus() {
 		return false;
 	}
+
+    /**
+     * Casts the receiver to a subclass of the given class.  If successful
+     * answers the receiver, otherwise if the cast cannot be made throws a
+     * <code>ClassCastException</code>.
+     * 
+     * @param clazz the required type.
+     * @return this class cast as a subclass of the given type.
+     * @throws ClassCastException if the class cannot be cast to the given type.
+     */
+    public <U> Class<? extends U> asSubclass(Class<U> clazz) {
+        return null;
+    }
+
+    /**
+     * Cast the given object to the type <code>T</code>.
+     * If the object is <code>null</code> the result is also
+     * <code>null</code>.
+     * 
+     * @param obj the object to cast
+     * @return The object that has been cast.
+     * @throws ClassCastException if the object cannot be cast to the given type.
+     */
+    public T cast(Object obj) {
+        return null;
+    }
 
 	/**
 	 * This must be provided by the vm vendor, as it is used by other provided

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/reflect/Constructor.java?rev=405370&r1=405369&r2=405370&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
Tue May  9 03:21:16 2006
@@ -21,7 +21,7 @@
  * constructor can be invoked dynamically.
  * 
  */
-public final class Constructor extends AccessibleObject implements Member {
+public final class Constructor<T> extends AccessibleObject implements Member {
 
 	/**
 	 * Compares the specified object to this Constructor and answer if they are

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
Tue May  9 03:21:16 2006
@@ -33,7 +33,7 @@
 	/**
      * The java.lang.Class that represents this class.
      */
-    public static final Class<Boolean> TYPE = new boolean[0].getClass()
+    public static final Class<Boolean> TYPE = (Class<Boolean>)new boolean[0].getClass()
             .getComponentType();
 
 	// Note: This can't be set to "boolean.class", since *that* is

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
Tue May  9 03:21:16 2006
@@ -54,7 +54,8 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class<Byte> TYPE = new byte[0].getClass().getComponentType();
+	public static final Class<Byte> TYPE = (Class<Byte>) new byte[0].getClass()
+            .getComponentType();
 
 	// Note: This can't be set to "byte.class", since *that* is
 	// defined to be "java.lang.Byte.TYPE";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
Tue May  9 03:21:16 2006
@@ -83,7 +83,8 @@
 	 * The maximum possible radix used for conversions between Characters and
 	 * integers.
 	 */
-	public static final Class<Character> TYPE = new char[0].getClass().getComponentType();
+	public static final Class<Character> TYPE = (Class<Character>) new char[0]
+            .getClass().getComponentType();
 
 	// Note: This can't be set to "char.class", since *that* is
 	// defined to be "java.lang.Character.TYPE";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
Tue May  9 03:21:16 2006
@@ -73,7 +73,7 @@
 	 * The java.lang.Class that represents this class.
      * @since 1.1
 	 */
-	public static final Class<Double> TYPE = new double[0].getClass()
+	public static final Class<Double> TYPE = (Class<Double>) new double[0].getClass()
 			.getComponentType();
 
 	// Note: This can't be set to "double.class", since *that* is

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
Tue May  9 03:21:16 2006
@@ -72,7 +72,8 @@
 	 * The java.lang.Class that represents this class.
      * @since 1.1
 	 */
-	public static final Class<Float> TYPE = new float[0].getClass().getComponentType();
+	public static final Class<Float> TYPE = (Class<Float>) new float[0]
+            .getClass().getComponentType();
 
 	// Note: This can't be set to "float.class", since *that* is
 	// defined to be "java.lang.Float.TYPE";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
Tue May  9 03:21:16 2006
@@ -66,7 +66,8 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class<Integer> TYPE = new int[0].getClass().getComponentType();
+	public static final Class<Integer> TYPE = (Class<Integer>) new int[0]
+            .getClass().getComponentType();
 
 	// Note: This can't be set to "int.class", since *that* is
 	// defined to be "java.lang.Integer.TYPE";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
Tue May  9 03:21:16 2006
@@ -56,7 +56,8 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class<Long> TYPE = new long[0].getClass().getComponentType();
+	public static final Class<Long> TYPE = (Class<Long>) new long[0].getClass()
+            .getComponentType();
 
 	// Note: This can't be set to "long.class", since *that* is
 	// defined to be "java.lang.Long.TYPE";

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java?rev=405370&r1=405369&r2=405370&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
Tue May  9 03:21:16 2006
@@ -59,7 +59,8 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class<Short> TYPE = new short[0].getClass().getComponentType();
+	public static final Class<Short> TYPE = (Class<Short>) new short[0]
+            .getClass().getComponentType();
 
 	// Note: This can't be set to "short.class", since *that* is
 	// defined to be "java.lang.Short.TYPE";



Mime
View raw message