jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
changeset 32762 253adb0f4301
parent 26481 c5b74a88a3c0
child 32986 ea54ac8672e7
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Tue Sep 22 11:01:54 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Wed Sep 23 08:43:51 2015 +0200
@@ -404,6 +404,14 @@
             d = lookupCache(types);
             // Class loading must have upgraded the cache.
             assert(d != null && !d.isPlaceholder());
+            if (OBSERVE_BMH_SPECIES_CREATION) {
+                if (d == null) {
+                    throw new IllegalStateException("d == null");
+                }
+                if (d.isPlaceholder()) {
+                    throw new IllegalStateException("d is place holder");
+                }
+            }
             return d;
         }
         static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) {
@@ -415,6 +423,9 @@
             if (d != null)  return d;
             d = new SpeciesData(types);
             assert(d.isPlaceholder());
+            if (OBSERVE_BMH_SPECIES_CREATION && !d.isPlaceholder()) {
+                throw new IllegalStateException("d is not place holder");
+            }
             CACHE.put(types, d);
             return d;
         }
@@ -422,6 +433,15 @@
             SpeciesData d2;
             assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder());
             assert(!d.isPlaceholder());
+            if (OBSERVE_BMH_SPECIES_CREATION) {
+                d2 = CACHE.get(types);
+                if (d2 != null && !d2.isPlaceholder()) {
+                    throw new IllegalStateException("non-null d2 is not place holder");
+                }
+                if (d.isPlaceholder()) {
+                    throw new IllegalStateException("d is place holder");
+                }
+            }
             CACHE.put(types, d);
             return d;
         }