Hi,

Here is the first part of my proposed VM interface changes to make the
VM interface more compatible with HEAD.

Please comment.

Regards,
Jeroen
Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.22.2.15
diff -u -r1.22.2.15 Class.java
--- java/lang/Class.java        8 Jun 2005 23:24:52 -0000       1.22.2.15
+++ java/lang/Class.java        17 Jun 2005 13:03:59 -0000
@@ -124,7 +124,7 @@
   final transient Object vmdata;
 
   /** newInstance() caches the default constructor */
-  private transient Constructor constructor;
+  private transient Constructor<T> constructor;
 
   /**
    * Class is non-instantiable from Java code; only the VM can create
@@ -1318,7 +1318,7 @@
    */
   public T cast(Object obj)
   {
-    return VMClass.cast(obj, this);
+    return (T)VMClass.cast(obj, this);
   }
 
   /**
@@ -1388,7 +1388,7 @@
    */
   public T[] getEnumConstants()
   {
-    return VMClass.getEnumConstants(this);
+    return (T[])VMClass.getEnumConstants(this);
   }
 
   /**
@@ -1622,7 +1622,15 @@
    */
   public Type[] getGenericInterfaces()
   {
-    return VMClass.getGenericInterfaces(this);
+    if (isPrimitive())
+      return new Type[0];
+
+    String sig = VMClass.getClassSignature(this);
+    if (sig == null)
+      return getInterfaces();
+
+    // XXX
+    throw new Error("Not implemented");
   }
 
   /**
@@ -1656,7 +1664,18 @@
    */
   public Type getGenericSuperclass()
   {
-    return VMClass.getGenericSuperclass(this);
+    if (isArray())
+      return Object.class;
+
+    if (isPrimitive() || isInterface() || this == Object.class)
+      return null;
+
+    String sig = VMClass.getClassSignature(this);
+    if (sig == null)
+      return getSuperclass();
+
+    // XXX
+    throw new Error("Not implemented");
   }
 
   /**
@@ -1673,7 +1692,12 @@
    */
   public TypeVariable<Class<T>>[] getTypeParameters()
   {
-    return VMClass.getTypeParameters(this);
+    String sig = VMClass.getClassSignature(this);
+    if (sig == null)
+      return (TypeVariable<Class<T>>[])new TypeVariable[0];
+
+    // XXX
+    throw new Error("Not implemented");
   }
 
   /**
Index: java/lang/System.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/System.java,v
retrieving revision 1.38.2.11
diff -u -r1.38.2.11 System.java
--- java/lang/System.java       4 Apr 2005 00:24:48 -0000       1.38.2.11
+++ java/lang/System.java       17 Jun 2005 13:03:59 -0000
@@ -495,7 +495,7 @@
       sm.checkPermission(new RuntimePermission("getenv.*"));
     if (environmentMap == null)
       {
-       List<String> environ = VMSystem.environ();
+       List<String> environ = (List<String>)VMSystem.environ();
        Map<String,String> variables = new EnvironmentMap();
        for (String pair : environ)
          {
Index: vm/reference/java/lang/VMClass.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMClass.java,v
retrieving revision 1.10.2.7
diff -u -r1.10.2.7 VMClass.java
--- vm/reference/java/lang/VMClass.java 8 Jun 2005 23:24:52 -0000       1.10.2.7
+++ vm/reference/java/lang/VMClass.java 17 Jun 2005 13:04:07 -0000
@@ -341,7 +341,7 @@
    * @param klass the class whose simple name should be returned. 
    * @return the simple name for this class.
    */
-  static String getSimpleName(Class<?> klass)
+  static String getSimpleName(Class klass)
   {
     if (isArray(klass))
       {
@@ -403,7 +403,7 @@
    * @return the annotations directly defined by the specified class.
    * @since 1.5
    */
-  static native Annotation[] getDeclaredAnnotations(Class<?> klass);
+  static native Annotation[] getDeclaredAnnotations(Class klass);
 
   /**
    * <p>
@@ -440,7 +440,7 @@
    *         class doesn't have a canonical name.
    * @since 1.5
    */
-  static String getCanonicalName(Class<?> klass)
+  static String getCanonicalName(Class klass)
   {
     if (isArray(klass))
       {
@@ -468,7 +468,7 @@
    *         a top-level class.
    * @since 1.5
    */
-  static native Class<?> getEnclosingClass(Class<?> klass);
+  static native Class getEnclosingClass(Class klass);
 
   /**
    * Returns the constructor which immediately encloses the specified class.
@@ -482,7 +482,7 @@
    *         is returned.
    * @since 1.5
    */
-  static native Constructor<?> getEnclosingConstructor(Class<?> klass);
+  static native Constructor getEnclosingConstructor(Class klass);
 
   /**
    * Returns the method which immediately encloses the specified class.  If
@@ -496,92 +496,18 @@
    *         is returned.
    * @since 1.5
    */
-  static native Method getEnclosingMethod(Class<?> klass);
+  static native Method getEnclosingMethod(Class klass);
 
   /**
-   * <p>
-   * Returns an array of <code>Type</code> objects which represent the
-   * interfaces directly implemented by the specified class or extended by the
-   * specified interface.
-   * </p>
-   * <p>
-   * If one of the superinterfaces is a parameterized type, then the
-   * object returned for this interface reflects the actual type
-   * parameters used in the source code.  Type parameters are created
-   * using the semantics specified by the <code>ParameterizedType</code>
-   * interface, and only if an instance has not already been created.
-   * </p>
-   * <p>
-   * The order of the interfaces in the array matches the order in which
-   * the interfaces are declared.  For classes which represent an array,
-   * an array of two interfaces, <code>Cloneable</code> and
-   * <code>Serializable</code>, is always returned, with the objects in
-   * that order.  A class representing a primitive type or void always
-   * returns an array of zero size.
-   * </p>
+   * Returns the class signature as specified in Class File Format
+   * chapter in the VM specification, or null if the class is not
+   * generic.
    *
-   * @param klass the class whose generic interfaces should be retrieved.
-   * @return an array of interfaces implemented or extended by the specified
-   *         class.
-   * @throws GenericSignatureFormatError if the generic signature of one
-   *         of the interfaces does not comply with that specified by the Java
-   *         Virtual Machine specification, 3rd edition.
-   * @throws TypeNotPresentException if any of the superinterfaces refers
-   *         to a non-existant type.
-   * @throws MalformedParameterizedTypeException if any of the interfaces
-   *         refer to a parameterized type that can not be instantiated for
-   *         some reason.
-   * @since 1.5
-   * @see java.lang.reflect.ParameterizedType
-   */
-  static native Type[] getGenericInterfaces(Class<?> klass);
-
-  /**
-   * <p>
-   * Returns a <code>Type</code> object representing the direct superclass,
-   * whether class, interface, primitive type or void, of the specified class.
-   * If the class is an array class, then a class instance representing
-   * the <code>Object</code> class is returned.  If the class is primitive,
-   * an interface, or a representation of either the <code>Object</code>
-   * class or void, then <code>null</code> is returned.
-   * </p>
-   * <p>
-   * If the superclass is a parameterized type, then the
-   * object returned for this interface reflects the actual type
-   * parameters used in the source code.  Type parameters are created
-   * using the semantics specified by the <code>ParameterizedType</code>
-   * interface, and only if an instance has not already been created.
-   * </p>
-   *
-   * @param klass the class whose generic superclass should be obtained.
-   * @return the superclass of the specified class.
-   * @throws GenericSignatureFormatError if the generic signature of the
-   *         class does not comply with that specified by the Java
-   *         Virtual Machine specification, 3rd edition.
-   * @throws TypeNotPresentException if the superclass refers
-   *         to a non-existant type.
-   * @throws MalformedParameterizedTypeException if the superclass
-   *         refers to a parameterized type that can not be instantiated for
-   *         some reason.
-   * @since 1.5
-   * @see java.lang.reflect.ParameterizedType
-   */
-  static native Type getGenericSuperclass(Class<?> klass);
-
-  /**
-   * Returns an array of <code>TypeVariable</code> objects that represents
-   * the type variables declared by the specified class, in declaration order.
-   * An array of size zero is returned if the specified class has no type
-   * variables.
-   *
-   * @param klass the class whose type variables should be returned.
-   * @return the type variables associated with this class. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
+   * @param klass the klass to test.
+   * @return a ClassSignature string.
    * @since 1.5
    */
-  static native <T> TypeVariable<Class<T>>[] getTypeParameters(Class<T> klass);
+  static native String getClassSignature(Class klass);
 
   /**
    * Returns true if the specified class represents an anonymous class.
@@ -590,7 +516,7 @@
    * @return true if the specified class represents an anonymous class.
    * @since 1.5
    */
-  static native boolean isAnonymousClass(Class<?> klass);
+  static native boolean isAnonymousClass(Class klass);
 
   /**
    * Returns true if the specified class represents an local class.
@@ -599,7 +525,7 @@
    * @return true if the specified class represents an local class.
    * @since 1.5
    */
-  static native boolean isLocalClass(Class<?> klass);
+  static native boolean isLocalClass(Class klass);
 
   /**
    * Returns true if the specified class represents an member class.
@@ -608,6 +534,6 @@
    * @return true if the specified class represents an member class.
    * @since 1.5
    */
-  static native boolean isMemberClass(Class<?> klass);
+  static native boolean isMemberClass(Class klass);
 
 } // class VMClass
Index: vm/reference/java/lang/VMSystem.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMSystem.java,v
retrieving revision 1.10.2.5
diff -u -r1.10.2.5 VMSystem.java
--- vm/reference/java/lang/VMSystem.java        8 Jun 2005 23:24:52 -0000       
1.10.2.5
+++ vm/reference/java/lang/VMSystem.java        17 Jun 2005 13:04:07 -0000
@@ -143,7 +143,7 @@
    *
    * @return a list of 'name=value' pairs.
    */
-  static native List<String> environ();
+  static native List environ();
 
   /**
    * Gets the value of an environment variable from the current
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to