1.1 --- a/rt/emul/compact/src/main/java/java/util/EnumMap.java Sun Sep 22 21:51:56 2013 +0200
1.2 +++ b/rt/emul/compact/src/main/java/java/util/EnumMap.java Sun Sep 22 21:56:49 2013 +0200
1.3 @@ -26,7 +26,7 @@
1.4 package java.util;
1.5
1.6 import java.util.Map.Entry;
1.7 -import sun.misc.SharedSecrets;
1.8 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.9
1.10 /**
1.11 * A specialized {@link Map} implementation for use with enum type keys. All
1.12 @@ -737,10 +737,8 @@
1.13 * Returns all of the values comprising K.
1.14 * The result is uncloned, cached, and shared by all callers.
1.15 */
1.16 - private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
1.17 - return SharedSecrets.getJavaLangAccess()
1.18 - .getEnumConstantsShared(keyType);
1.19 - }
1.20 + @JavaScriptBody(args = { "enumType" }, body = "return enumType.cnstr.$VALUES;")
1.21 + private static native <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType);
1.22
1.23 private static final long serialVersionUID = 458661240069192865L;
1.24
2.1 --- a/rt/emul/compact/src/main/java/java/util/EnumSet.java Sun Sep 22 21:51:56 2013 +0200
2.2 +++ b/rt/emul/compact/src/main/java/java/util/EnumSet.java Sun Sep 22 21:56:49 2013 +0200
2.3 @@ -25,7 +25,7 @@
2.4
2.5 package java.util;
2.6
2.7 -import sun.misc.SharedSecrets;
2.8 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
2.9
2.10 /**
2.11 * A specialized {@link Set} implementation for use with enum types. All of
2.12 @@ -384,10 +384,8 @@
2.13 * Returns all of the values comprising E.
2.14 * The result is uncloned, cached, and shared by all callers.
2.15 */
2.16 - private static <E extends Enum<E>> E[] getUniverse(Class<E> elementType) {
2.17 - return SharedSecrets.getJavaLangAccess()
2.18 - .getEnumConstantsShared(elementType);
2.19 - }
2.20 + @JavaScriptBody(args = { "enumType" }, body = "return enumType.cnstr.$VALUES;")
2.21 + private static native <E extends Enum<E>> E[] getUniverse(Class<E> elementType);
2.22
2.23 /**
2.24 * This class is used to serialize all EnumSet instances, regardless of
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java Sun Sep 22 21:56:49 2013 +0200
3.3 @@ -0,0 +1,61 @@
3.4 +package org.apidesign.bck2brwsr.tck;
3.5 +
3.6 +import java.util.EnumMap;
3.7 +import java.util.EnumSet;
3.8 +import org.apidesign.bck2brwsr.vmtest.Compare;
3.9 +import org.apidesign.bck2brwsr.vmtest.VMTest;
3.10 +import org.testng.annotations.Factory;
3.11 +
3.12 +/**
3.13 + *
3.14 + * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
3.15 + */
3.16 +public class EnumsTest {
3.17 + enum Color {
3.18 + B, W;
3.19 + }
3.20 +
3.21 + /*
3.22 + @Compare public String enumSet() {
3.23 + try { throw new Exception(); } catch (Exception ex) {}
3.24 + EnumSet<Color> c = EnumSet.allOf(Color.class);
3.25 + return c.toString();
3.26 + }
3.27 +
3.28 + @Compare public String enumSetOneByOne() {
3.29 + EnumSet<Color> c = EnumSet.of(Color.B, Color.W);
3.30 + return c.toString();
3.31 + }
3.32 + */
3.33 +
3.34 + @Compare public boolean enumFirstContains() {
3.35 + EnumSet<Color> c = EnumSet.of(Color.B);
3.36 + return c.contains(Color.B);
3.37 + }
3.38 +
3.39 + @Compare public boolean enumFirstDoesNotContains() {
3.40 + EnumSet<Color> c = EnumSet.of(Color.B);
3.41 + return c.contains(Color.W);
3.42 + }
3.43 +
3.44 + @Compare public boolean enumSndContains() {
3.45 + EnumSet<Color> c = EnumSet.of(Color.W);
3.46 + return c.contains(Color.W);
3.47 + }
3.48 +
3.49 + @Compare public boolean enumSecondDoesNotContains() {
3.50 + EnumSet<Color> c = EnumSet.of(Color.W);
3.51 + return c.contains(Color.B);
3.52 + }
3.53 +
3.54 + @Compare public String enumMap() {
3.55 + EnumMap<Color,String> c = new EnumMap(Color.class);
3.56 + c.put(Color.B, "Black");
3.57 + c.put(Color.W, "White");
3.58 + return c.toString();
3.59 + }
3.60 +
3.61 + @Factory public static Object[] create() {
3.62 + return VMTest.create(EnumsTest.class);
3.63 + }
3.64 +}