Hi,

I committed the attached patch.

Regards,
Jeroen

2005-10-01  Jeroen Frijters  <[EMAIL PROTECTED]>

        * vm/reference/java/lang/reflect/Constructor.java
        (getSignature): New method.
        (getGenericExceptionTypes): New method.
        (getGenericParameterTypes): New method.
        * vm/reference/java/lang/reflect/Field.java
        (getGenericType): New method.
        (getSignature): New method.
        * vm/reference/java/lang/reflect/Method.java
        (getSignature): New method.
        (getGenericExceptionTypes): New method.
        (getGenericParameterTypes): New method.
        (getGenericReturnType): New method.
Index: vm/reference/java/lang/reflect/Constructor.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/vm/reference/java/lang/reflect/Constructor.java,v
retrieving revision 1.11.2.8
diff -u -r1.11.2.8 Constructor.java
--- vm/reference/java/lang/reflect/Constructor.java     28 Sep 2005 17:50:21 
-0000      1.11.2.8
+++ vm/reference/java/lang/reflect/Constructor.java     1 Oct 2005 09:56:40 
-0000
@@ -252,10 +252,10 @@
   /**
    * Returns an array of <code>TypeVariable</code> objects that represents
    * the type variables declared by this constructor, in declaration order.
-   * An array of size zero is returned if this class has no type
+   * An array of size zero is returned if this constructor has no type
    * variables.
    *
-   * @return the type variables associated with this class. 
+   * @return the type variables associated with this constructor.
    * @throws GenericSignatureFormatError if the generic signature does
    *         not conform to the format specified in the Virtual Machine
    *         specification, version 3.
@@ -268,5 +268,51 @@
     return p.getTypeParameters();
   }
 
+  /**
+   * Return the String in the Signature attribute for this constructor. If 
there
+   * is no Signature attribute, return null.
+   */
   private native String getSignature();
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the exception types declared by this constructor, in declaration order.
+   * An array of size zero is returned if this constructor declares no
+   * exceptions.
+   *
+   * @return the exception types declared by this constructor. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericExceptionTypes()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getExceptionTypes();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericExceptionTypes();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the parameter list for this constructor, in declaration order.
+   * An array of size zero is returned if this constructor takes no
+   * parameters.
+   *
+   * @return a list of the types of the constructor's parameters
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericParameterTypes()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getParameterTypes();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericParameterTypes();
+  }
 }
Index: vm/reference/java/lang/reflect/Field.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/vm/reference/java/lang/reflect/Field.java,v
retrieving revision 1.9.2.3
diff -u -r1.9.2.3 Field.java
--- vm/reference/java/lang/reflect/Field.java   28 Sep 2005 17:50:22 -0000      
1.9.2.3
+++ vm/reference/java/lang/reflect/Field.java   1 Oct 2005 09:56:49 -0000
@@ -1,5 +1,5 @@
 /* java.lang.reflect.Field - reflection of Java fields
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,6 +38,8 @@
 
 package java.lang.reflect;
 
+import gnu.java.lang.reflect.FieldSignatureParser;
+
 /**
  * The Field class represents a member variable of a class. It also allows
  * dynamic access to a member, via reflection. This works for both
@@ -586,4 +588,29 @@
    */
   public native void setDouble(Object o, double value)
     throws IllegalAccessException;
+
+  /**
+   * Return the generic type of the field. If the field type is not a generic
+   * type, the method returns the same as <code>getType()</code>.
+   *
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type getGenericType()
+  {
+    String signature = getSignature();
+    if (signature == null)
+      return getType();
+    FieldSignatureParser p = new FieldSignatureParser(getDeclaringClass(),
+                                                      signature);
+    return p.getFieldType();
+  }
+
+  /**
+   * Return the String in the Signature attribute for this field. If there
+   * is no Signature attribute, return null.
+   */
+  private native String getSignature();
 }
Index: vm/reference/java/lang/reflect/Method.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/vm/reference/java/lang/reflect/Method.java,v
retrieving revision 1.12.2.5
diff -u -r1.12.2.5 Method.java
--- vm/reference/java/lang/reflect/Method.java  28 Sep 2005 17:50:22 -0000      
1.12.2.5
+++ vm/reference/java/lang/reflect/Method.java  1 Oct 2005 09:56:22 -0000
@@ -353,5 +353,69 @@
     return p.getTypeParameters();
   }
 
+  /**
+   * Return the String in the Signature attribute for this method. If there
+   * is no Signature attribute, return null.
+   */
   private native String getSignature();
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the exception types declared by this method, in declaration order.
+   * An array of size zero is returned if this method declares no
+   * exceptions.
+   *
+   * @return the exception types declared by this method. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericExceptionTypes()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getExceptionTypes();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericExceptionTypes();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the parameter list for this method, in declaration order.
+   * An array of size zero is returned if this method takes no
+   * parameters.
+   *
+   * @return a list of the types of the method's parameters
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericParameterTypes()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getParameterTypes();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericParameterTypes();
+  }
+
+  /**
+   * Returns the return type of this method.
+   *
+   * @return the return type of this method
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type getGenericReturnType()
+  {
+    String sig = getSignature();
+    if (sig == null)
+      return getReturnType();
+    MethodSignatureParser p = new MethodSignatureParser(this, sig);
+    return p.getGenericReturnType();
+  }
 }
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to