Hi,

Since I'm shortly going to commit my change to trunk, I've committed
this to the generics branch to make the VM interfaces the same.

Regards,
Jeroen

2006-04-23  Jeroen Frijters  <[EMAIL PROTECTED]>

        * java/lang/Class.java (getEnumConstants): Implemented without
        delegating to VMClass.
        * vm/reference/java/lang/VMClass.java (getEnumConstants):
Removed.
Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.22.2.23
diff -u -r1.22.2.23 Class.java
--- java/lang/Class.java        14 Apr 2006 06:50:29 -0000      1.22.2.23
+++ java/lang/Class.java        23 Apr 2006 10:08:23 -0000
@@ -1374,7 +1374,31 @@
    */
   public T[] getEnumConstants()
   {
-    return (T[])VMClass.getEnumConstants(this);
+    if (isEnum())
+      {
+       try
+         {
+           return (T[]) getMethod("values").invoke(null);
+         }
+       catch (NoSuchMethodException exception)
+         {
+           throw new Error("Enum lacks values() method");
+         }
+       catch (IllegalAccessException exception)
+         {
+           throw new Error("Unable to access Enum class");
+         }
+       catch (InvocationTargetException exception)
+         {
+           throw new
+             RuntimeException("The values method threw an exception",
+                              exception);
+         }
+      }
+    else
+      {
+       return null;
+      }
   }
 
   /**
Index: vm/reference/java/lang/VMClass.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMClass.java,v
retrieving revision 1.10.2.12
diff -u -r1.10.2.12 VMClass.java
--- vm/reference/java/lang/VMClass.java 14 Apr 2006 06:50:38 -0000      
1.10.2.12
+++ vm/reference/java/lang/VMClass.java 23 Apr 2006 10:07:22 -0000
@@ -1,5 +1,5 @@
 /* VMClass.java -- VM Specific Class methods
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation
+   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,6 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
@@ -333,46 +332,6 @@
   }
 
   /**
-   * Returns the enumeration constants of this class, or
-   * null if this class is not an <code>Enum</code>.
-   *
-   * @param klass the class whose enumeration constants should be returned.
-   * @return an array of <code>Enum</code> constants
-   *         associated with this class, or null if this
-   *         class is not an <code>enum</code>.
-   * @since 1.5
-   */
-  static <T> T[] getEnumConstants(Class<T> klass)
-  {
-    if (isEnum(klass))
-      {
-       try
-         {
-           return (T[])
-             klass.getMethod("values").invoke(null);
-         }
-       catch (NoSuchMethodException exception)
-         {
-           throw new Error("Enum lacks values() method");
-         }
-       catch (IllegalAccessException exception)
-         {
-           throw new Error("Unable to access Enum class");
-         }
-       catch (InvocationTargetException exception)
-         {
-           throw new
-             RuntimeException("The values method threw an exception",
-                              exception);
-         }
-      }
-    else
-      {
-       return null;
-      }
-  }
-
-  /**
    * Returns all annotations directly defined by the specified class.  If
    * there are no annotations associated with this class, then a zero-length
    * array will be returned.  The returned array may be modified by the client

Reply via email to