implement Class.getEnumConstants

This commit is contained in:
Joel Dice 2007-11-17 11:39:29 -07:00
parent 4f047ded8c
commit 80f23a5040

View File

@ -345,6 +345,18 @@ public final class Class <T> {
}
}
public T[] getEnumConstants() {
if (isAssignableFrom(Enum.class)) {
try {
return (T[]) getMethod("values").invoke(null);
} catch (Exception e) {
throw new Error();
}
} else {
return null;
}
}
public ClassLoader getClassLoader() {
return loader;
}