1.1 --- a/rt/emul/mini/src/main/java/java/lang/Enum.java Tue Feb 26 16:54:16 2013 +0100
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/Enum.java Tue Apr 09 10:06:19 2013 +0200
1.3 @@ -27,6 +27,7 @@
1.4
1.5 import java.io.Serializable;
1.6 import java.io.IOException;
1.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.8
1.9 /**
1.10 * This is the common base class of all Java language enumeration types.
1.11 @@ -225,15 +226,17 @@
1.12 */
1.13 public static <T extends Enum<T>> T valueOf(Class<T> enumType,
1.14 String name) {
1.15 - throw new UnsupportedOperationException();
1.16 -// T result = enumType.enumConstantDirectory().get(name);
1.17 -// if (result != null)
1.18 -// return result;
1.19 -// if (name == null)
1.20 -// throw new NullPointerException("Name is null");
1.21 -// throw new IllegalArgumentException(
1.22 -// "No enum constant " + enumType.getCanonicalName() + "." + name);
1.23 + for (Object o : values(enumType)) {
1.24 + T t = enumType.cast(o);
1.25 + if (name.equals(((Enum)t).name)) {
1.26 + return t;
1.27 + }
1.28 + }
1.29 + throw new IllegalArgumentException();
1.30 }
1.31 +
1.32 + @JavaScriptBody(args = { "enumType" }, body = "return enumType.cnstr.$VALUES;")
1.33 + private static native Object[] values(Class<?> enumType);
1.34
1.35 /**
1.36 * enum classes cannot have finalize methods.