< prev index next >

test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BytePoolHelper.java

Print this page
rev 47761 : 8186209: Tool support for ConstantDynamic
8186046: Minimal ConstantDynamic support
Reviewed-by: acorn
Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
* * *
Minor Hotspot code cleanup changes resulting from condy review
Summary: Addressed missing DynamicInError condition, removed unused TraceDynamicConstants
Reviewed-by: acorn, psandoz
rev 47762 : 8187742: Minimal set of bootstrap methods for constant dynamic
Contributed-by: brian.goetz@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Reviewed-by: forax

@@ -488,11 +488,12 @@
         List<Integer> static_idxs = staticArgsBuilder.indexes;
         bsmKey.set(bsmClass, bsmName, bsmType, static_idxs);
         BsmKey poolKey = bootstraps.lookup(bsmKey);
         if (poolKey == null) {
             poolKey = bsmKey.dup();
-            int bsm_ref = putHandleInternal(MethodHandleInfo.REF_invokeStatic, bsmClass, bsmName, bsmType);
+            // TODO the BSM could be a static method on an interface
+            int bsm_ref = putHandleInternal(MethodHandleInfo.REF_invokeStatic, bsmClass, bsmName, bsmType, false);
             poolKey.at(currentBsmIndex++);
             bootstraps.enter(poolKey);
             bsm_attr.writeChar(bsm_ref);
             bsm_attr.writeChar(static_idxs.size());
             for (int i : static_idxs) {

@@ -560,42 +561,46 @@
         return poolKey.index;
     }
 
     @Override
     public int putHandle(int refKind, S owner, CharSequence name, T type) {
-        return putHandleInternal(refKind, symbolToString.apply(owner), name, typeToString.apply(type));
+        return putHandleInternal(refKind, symbolToString.apply(owner), name, typeToString.apply(type), false);
     }
 
-    private int putHandleInternal(int refKind, String owner, CharSequence name, String type) {
+    @Override
+    public int putHandle(int refKind, S owner, CharSequence name, T type, boolean isInterface) {
+        return putHandleInternal(refKind, symbolToString.apply(owner), name, typeToString.apply(type), isInterface);
+    }
+
+    private int putHandleInternal(int refKind, String owner, CharSequence name, String type, boolean isInterface) {
         key.setMethodHandle(refKind, owner, name, type);
         PoolKey poolKey = entries.lookup(key);
         if (poolKey == null) {
             poolKey = key.dup();
-            int ref_idx = putMemberRefInternal(fromKind(refKind), owner, name, type);
+            int ref_idx = putMemberRefInternal(fromKind(refKind, isInterface), owner, name, type);
             poolKey.at(currentIndex++);
             entries.enter(poolKey);
             pool.writeByte(PoolTag.CONSTANT_METHODHANDLE.tag);
             pool.writeByte(refKind);
             pool.writeChar(ref_idx);
         }
         return poolKey.index;
     }
 
-    PoolTag fromKind(int bsmKind) {
+    PoolTag fromKind(int bsmKind, boolean isInterface) {
         switch (bsmKind) {
             case 1: // REF_getField
             case 2: // REF_getStatic
             case 3: // REF_putField
             case 4: // REF_putStatic
                 return PoolTag.CONSTANT_FIELDREF;
             case 5: // REF_invokeVirtual
             case 6: // REF_invokeStatic
             case 7: // REF_invokeSpecial
             case 8: // REF_newInvokeSpecial
-                return PoolTag.CONSTANT_METHODREF;
             case 9: // REF_invokeInterface
-                return PoolTag.CONSTANT_INTERFACEMETHODREF;
+                return isInterface ? PoolTag.CONSTANT_INTERFACEMETHODREF : PoolTag.CONSTANT_METHODREF;
             default:
                 throw new IllegalStateException();
         }
     }
 
< prev index next >