jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java
changeset 40962 2c005ed3d294
parent 36511 9d0388c6b336
child 45714 1820d351198d
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java	Fri Sep 02 11:20:33 2016 -0400
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java	Tue Sep 06 20:27:47 2016 -0700
@@ -993,32 +993,39 @@
         return minorVersion;
     }
 
-    private void getConstantPoolInfo() {
+    private byte[] getConstantPoolInfo() {
         JDWP.ReferenceType.ConstantPool jdwpCPool;
         if (!vm.canGetConstantPool()) {
             throw new UnsupportedOperationException();
         }
         if (constantPoolInfoGotten) {
-            return;
-        } else {
-            try {
-                jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this);
-            } catch (JDWPException exc) {
-                if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
-                    constanPoolCount = 0;
-                    constantPoolBytesRef = null;
-                    constantPoolInfoGotten = true;
-                    return;
-                } else {
-                    throw exc.toJDIException();
-                }
+            if (constantPoolBytesRef == null) {
+                return null;
+            }
+            byte[] cpbytes = constantPoolBytesRef.get();
+            if (cpbytes != null) {
+                return cpbytes;
             }
-            byte[] cpbytes;
-            constanPoolCount = jdwpCPool.count;
-            cpbytes = jdwpCPool.bytes;
-            constantPoolBytesRef = new SoftReference<byte[]>(cpbytes);
-            constantPoolInfoGotten = true;
         }
+
+        try {
+            jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this);
+        } catch (JDWPException exc) {
+            if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
+                constanPoolCount = 0;
+                constantPoolBytesRef = null;
+                constantPoolInfoGotten = true;
+                return null;
+            } else {
+                throw exc.toJDIException();
+            }
+        }
+        byte[] cpbytes;
+        constanPoolCount = jdwpCPool.count;
+        cpbytes = jdwpCPool.bytes;
+        constantPoolBytesRef = new SoftReference<byte[]>(cpbytes);
+        constantPoolInfoGotten = true;
+        return cpbytes;
     }
 
     public int constantPoolCount() {
@@ -1031,13 +1038,13 @@
     }
 
     public byte[] constantPool() {
+        byte[] cpbytes;
         try {
-            getConstantPoolInfo();
+            cpbytes = getConstantPoolInfo();
         } catch (RuntimeException exc) {
             throw exc;
         }
-        if (constantPoolBytesRef != null) {
-            byte[] cpbytes = constantPoolBytesRef.get();
+        if (cpbytes != null) {
             /*
              * Arrays are always modifiable, so it is a little unsafe
              * to return the cached bytecodes directly; instead, we