summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@sumatra.nl>2006-04-23 10:13:17 +0000
committerJeroen Frijters <jeroen@sumatra.nl>2006-04-23 10:13:17 +0000
commit2c65ecb9933d810fd553d84ce938e921e907b6e2 (patch)
tree8b6fe198ebf8a73403650c8ce93124b72577fcfa
parent7705dee3500ff4f9a1b41a817d2225abc295f3e9 (diff)
downloadclasspath-2c65ecb9933d810fd553d84ce938e921e907b6e2.tar.gz
2006-04-23 Jeroen Frijters <jeroen@frijters.net>
* java/lang/Class.java (getEnumConstants): Implemented without delegating to VMClass. * vm/reference/java/lang/VMClass.java (getEnumConstants): Removed.
-rw-r--r--ChangeLog6
-rw-r--r--java/lang/Class.java26
-rw-r--r--vm/reference/java/lang/VMClass.java43
3 files changed, 32 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 69ef416cf..c5da83e67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-04-23 Jeroen Frijters <jeroen@frijters.net>
+ * java/lang/Class.java (getEnumConstants): Implemented without
+ delegating to VMClass.
+ * vm/reference/java/lang/VMClass.java (getEnumConstants): Removed.
+
+2006-04-23 Jeroen Frijters <jeroen@frijters.net>
+
* java/lang/ClassLoader.java (definePackage): Added argument to
Package constructor.
* java/lang/Package.java (Package): Added ClassLoader argument.
diff --git a/java/lang/Class.java b/java/lang/Class.java
index 2152accf3..c5ec1536d 100644
--- a/java/lang/Class.java
+++ b/java/lang/Class.java
@@ -1374,7 +1374,31 @@ public final class Class<T>
*/
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;
+ }
}
/**
diff --git a/vm/reference/java/lang/VMClass.java b/vm/reference/java/lang/VMClass.java
index b68a4818e..47a91da8c 100644
--- a/vm/reference/java/lang/VMClass.java
+++ b/vm/reference/java/lang/VMClass.java
@@ -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.annotation.Annotation;
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 @@ final class VMClass
}
/**
- * 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