classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: FYI: reflection updates


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: FYI: reflection updates
Date: 26 Aug 2004 17:44:51 -0600

This adds a bunch of new interfaces and some other things to
java.lang.reflect.  There is still more generics work to be done in
reflection, this is just the easiest bits.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>
        * java/lang/reflect/AnnotatedElement.java: New file.
        * vm/reference/java/lang/reflect/Constructor.java (Constructor):
        Now generic.  Implements GenericDeclaration.
        (clazz): Now generic.
        (getDeclaringClass): Likewise.
        (getExceptionTypes): Likewise.
        (getParameterTypes): Likewise.
        (newInstance): Likewise.
        (constructNative): Likewise.
        * java/lang/reflect/GenericDeclaration.java: New file.
        * java/lang/reflect/GenericSignatureFormatError.java: New file.
        * java/lang/reflect/WildcardType.java: New file.
        * java/lang/reflect/TypeVariable.java: New file.
        * java/lang/reflect/ParameterizedType.java: New file.
        * java/lang/MalformedParameterizedTypeException.java: New file.
        * java/lang/TypeNotPresentException.java: New file.
        * java/lang/reflect/GenericArrayType.java: New file.
        * java/lang/reflect/Type.java: New file.

Index: java/lang/MalformedParameterizedTypeException.java
===================================================================
RCS file: java/lang/MalformedParameterizedTypeException.java
diff -N java/lang/MalformedParameterizedTypeException.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/MalformedParameterizedTypeException.java 27 Aug 2004 00:01:03 
-0000
@@ -0,0 +1,46 @@
+/* MalformedParameterizedTypeException.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+public class MalformedParameterizedTypeException extends RuntimeException
+{
+  public MalformedParameterizedTypeException()
+  {
+  }
+}
Index: java/lang/TypeNotPresentException.java
===================================================================
RCS file: java/lang/TypeNotPresentException.java
diff -N java/lang/TypeNotPresentException.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/TypeNotPresentException.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,56 @@
+/* TypeNotPresentException.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+public class TypeNotPresentException extends RuntimeException
+{
+  public TypeNotPresentException(String typeName, Throwable cause)
+  {
+    super("type \"" + typeName + "\" not found", cause);
+    this.typeName = typeName;
+  }
+
+  public String typeName()
+  {
+    return typeName;
+  }
+
+  // Name fixed by serialization.
+  private String typeName;
+}
Index: java/lang/reflect/AnnotatedElement.java
===================================================================
RCS file: java/lang/reflect/AnnotatedElement.java
diff -N java/lang/reflect/AnnotatedElement.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/AnnotatedElement.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,47 @@
+/* AnnotatedElement.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface AnnotatedElement
+{
+  <T extends Annotation> T getAnnotation(Class<T> annoType);
+  Annotation[] getAnnotations();
+  Annotation[] getDeclaredAnnotation();
+  boolean isAnnotationPresent(Class<? extends Annotation> annoType);
+}
Index: java/lang/reflect/GenericArrayType.java
===================================================================
RCS file: java/lang/reflect/GenericArrayType.java
diff -N java/lang/reflect/GenericArrayType.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/GenericArrayType.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,44 @@
+/* GenericArrayType.java - Represent an array type with generic componet
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface GenericArrayType extends Type
+{
+  Type getGenericComponentType();
+}
Index: java/lang/reflect/GenericDeclaration.java
===================================================================
RCS file: java/lang/reflect/GenericDeclaration.java
diff -N java/lang/reflect/GenericDeclaration.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/GenericDeclaration.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,44 @@
+/* GenericDeclaration.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface GenericDeclaration
+{
+  TypeVariable<?>[] getTypeParameters();
+}
Index: java/lang/reflect/GenericSignatureFormatError.java
===================================================================
RCS file: java/lang/reflect/GenericSignatureFormatError.java
diff -N java/lang/reflect/GenericSignatureFormatError.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/GenericSignatureFormatError.java 27 Aug 2004 00:01:03 
-0000
@@ -0,0 +1,46 @@
+/* GenericSignatureFormatError.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public class GenericSignatureFormatError extends ClassFormatError
+{
+  public GenericSignatureFormatError()
+  {
+  }
+}
Index: java/lang/reflect/ParameterizedType.java
===================================================================
RCS file: java/lang/reflect/ParameterizedType.java
diff -N java/lang/reflect/ParameterizedType.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/ParameterizedType.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,46 @@
+/* ParameterizedType.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface ParameterizedType extends Type
+{
+  Type[] getActualTypeArguments();
+  Type getOwnerType();
+  Type getRawType();
+}
Index: java/lang/reflect/Type.java
===================================================================
RCS file: java/lang/reflect/Type.java
diff -N java/lang/reflect/Type.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/Type.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,43 @@
+/* Type.java - Superinterface for all types.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface Type
+{
+}
Index: java/lang/reflect/TypeVariable.java
===================================================================
RCS file: java/lang/reflect/TypeVariable.java
diff -N java/lang/reflect/TypeVariable.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/TypeVariable.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,46 @@
+/* TypeVariable.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface TypeVariable<T extends GenericDeclaration> extends Type
+{
+  Type[] getBounds();
+  T getGenericDeclaration();
+  String getName();
+}
Index: java/lang/reflect/WildcardType.java
===================================================================
RCS file: java/lang/reflect/WildcardType.java
diff -N java/lang/reflect/WildcardType.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/reflect/WildcardType.java 27 Aug 2004 00:01:03 -0000
@@ -0,0 +1,45 @@
+/* WildcardType.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+public interface WildcardType extends Type
+{
+  Type[] getLowerBounds();
+  Type[] getUpperBounds();
+}
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
diff -u -r1.11 Constructor.java
--- vm/reference/java/lang/reflect/Constructor.java 29 Mar 2004 07:07:40 -0000 
1.11
+++ vm/reference/java/lang/reflect/Constructor.java 27 Aug 2004 00:01:04 -0000
@@ -1,5 +1,5 @@
 /* java.lang.reflect.Constructor - reflection of Java constructors
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -73,10 +73,11 @@
  * @since 1.1
  * @status updated to 1.4
  */
-public final class Constructor
-extends AccessibleObject implements Member
+public final class Constructor<T>
+  extends AccessibleObject
+  implements GenericDeclaration, Member
 {
-  private Class clazz;
+  private Class<T> clazz;
   private int slot;
   private Class[] parameterTypes;
   private Class[] exceptionTypes;
@@ -98,7 +99,7 @@
    * Gets the class that declared this constructor.
    * @return the class that declared this member
    */
-  public Class getDeclaringClass()
+  public Class<T> getDeclaringClass()
   {
     return clazz;
   }
@@ -129,7 +130,7 @@
    *
    * @return a list of the types of the constructor's parameters
    */
-  public Class[] getParameterTypes()
+  public Class<?>[] getParameterTypes()
   {
     if (parameterTypes == null)
       return new Class[0];
@@ -143,7 +144,7 @@
    *
    * @return a list of the types in the constructor's throws clause
    */
-  public Class[] getExceptionTypes()
+  public Class<?>[] getExceptionTypes()
   {
     if (exceptionTypes == null)
       return new Class[0];
@@ -247,15 +248,15 @@
    * @throws ExceptionInInitializerError if construction triggered class
    *         initialization, which then failed
    */
-  public Object newInstance(Object args[])
+  public T newInstance(Object args[])
     throws InstantiationException, IllegalAccessException,
            InvocationTargetException
   {
     return constructNative(args, clazz, slot);
   }
 
-  private native Object constructNative(Object[] args, Class declaringClass,
-                                        int slot)
+  private native T constructNative(Object[] args, Class declaringClass,
+                                  int slot)
     throws InstantiationException, IllegalAccessException,
            InvocationTargetException;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]