changeset 25:29ac1d38dde1

Fix incorrect handling of some CPX2 constant pool entries by JDIS, contributed by: mdegtyarev@gmail.com, reviewed by: leonid.kuskov@oracle.com
author lkuskov
date Thu, 22 Mar 2018 11:43:37 -0700
parents 2931522b78a4
children edbdc1bf3211
files src/org/openjdk/asmtools/jdis/ConstantPool.java
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/openjdk/asmtools/jdis/ConstantPool.java	Tue Mar 13 15:40:28 2018 -0700
+++ b/src/org/openjdk/asmtools/jdis/ConstantPool.java	Thu Mar 22 11:43:37 2018 -0700
@@ -598,6 +598,10 @@
                     break;
             }
         }
+
+        public boolean refersClassMember() {
+            return tag == TAG.CONSTANT_FIELD || tag == TAG.CONSTANT_METHOD || tag == TAG.CONSTANT_INTERFACEMETHOD;
+        }
     }
 
     /* -------------------------------------------------------- */
@@ -998,17 +1002,10 @@
         if (cns == null) {
             return "#" + cpx;
         }
-        switch (cns.tag) {
-            case CONSTANT_METHODHANDLE:
-            case CONSTANT_DYNAMIC:
-            case CONSTANT_INVOKEDYNAMIC:
-            case CONSTANT_METHOD:
-            case CONSTANT_INTERFACEMETHOD:
-            case CONSTANT_FIELD: {
-                CPX2 cns2 = (CPX2) cns;
-                if (cns2.value1 == cd.this_cpx) {
-                    cpx = cns2.value2;
-                }
+        if (cns instanceof CPX2) {
+            CPX2 cns2 = (CPX2) cns;
+            if (cns2.value1 == cd.this_cpx && cns2.refersClassMember()) {
+                cpx = cns2.value2;
             }
         }
         return cns.tag.tagname + " " + StringValue(cpx);