@@ -253,6 +253,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>, Clone
253253 static final int MIN_TREEIFY_CAPACITY = 64 ;
254254
255255 Map <String , Object > 秘m ;
256+ boolean 秘allowJS = false ;
256257
257258 /**
258259 * Basic hash bin node, used for most entries. (See below for TreeNode subclass,
@@ -421,6 +422,13 @@ static final int tableSizeFor(int cap) {
421422 */
422423 final float loadFactor ;
423424
425+ /**
426+ * flag developers can use to switch off all use of simple JavaScript Map objects
427+ *
428+ * not final, so that it can be managed on the fly in SwingJS
429+ */
430+ public static boolean USE_SIMPLE = true ;
431+
424432 /* ---------------- Public operations -------------- */
425433
426434 /**
@@ -456,6 +464,7 @@ public HashMap(int initialCapacity, float loadFactor) {
456464 */
457465 public HashMap (int initialCapacity ) {
458466 this (initialCapacity , DEFAULT_LOAD_FACTOR );
467+ 秘allowJS = true ;
459468 秘setJS ();
460469 }
461470
@@ -466,6 +475,7 @@ public HashMap(int initialCapacity) {
466475 * and the default load factor (0.75).
467476 */
468477 public HashMap () {
478+ 秘allowJS = true ;
469479 秘setJS ();
470480 this .loadFactor = DEFAULT_LOAD_FACTOR ; // all other fields defaulted
471481 }
@@ -480,6 +490,7 @@ public HashMap() {
480490 * @throws NullPointerException if the specified map is null
481491 */
482492 public HashMap (Map <? extends K , ? extends V > m ) {
493+ 秘allowJS = (/** @j2sNative m.allowJS ||*/ false );
483494 秘setJS ();
484495 this .loadFactor = DEFAULT_LOAD_FACTOR ;
485496 putMapEntries (m , false );
@@ -3067,7 +3078,7 @@ static <K, V> boolean checkInvariants(TreeNode<K, V> t) {
30673078
30683079 protected void 秘setJS () {
30693080
3070- 秘m = (Map .USE_SIMPLE ? /** @j2sNative new Map() || */
3081+ 秘m = (秘allowJS && HashMap .USE_SIMPLE ? /** @j2sNative new Map() || */
30713082 null : null );
30723083 }
30733084
0 commit comments