changeset 34:9dca9ca5771e tip

CODETOOLS-7902333 jasm produces inconsistent constant pool data for bootstrap methods of interfaces if cfv >= 52
author lkuskov
date Tue, 16 Oct 2018 11:16:09 -0700
parents ed446c8485ec
children
files src/org/openjdk/asmtools/jasm/Parser.java
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/openjdk/asmtools/jasm/Parser.java	Mon Oct 15 15:48:11 2018 -0700
+++ b/src/org/openjdk/asmtools/jasm/Parser.java	Tue Oct 16 11:16:09 2018 -0700
@@ -352,10 +352,27 @@
                 refCell = pool.FindCell(cpParser.parseConstValue(ConstType.CONSTANT_FIELD));
                 break;
             case REF_INVOKEVIRTUAL:
+            case REF_NEWINVOKESPECIAL:
+                refCell = pool.FindCell(cpParser.parseConstValue(ConstType.CONSTANT_METHOD));
+                break;
             case REF_INVOKESTATIC:
             case REF_INVOKESPECIAL:
-            case REF_NEWINVOKESPECIAL:
-                refCell = pool.FindCell(cpParser.parseConstValue(ConstType.CONSTANT_METHOD));
+                // CODETOOLS-7902333
+                // 4.4.8. The CONSTANT_MethodHandle_info Structure
+                // reference_index
+                // The value of the reference_index item must be a valid index into the constant_pool table.
+                // The constant_pool entry at that index must be as follows:
+                // If the value of the reference_kind item is 6 (REF_invokeStatic) or 7 (REF_invokeSpecial),
+                // then if the class file version number is less than 52.0, the constant_pool entry at that index must be
+                // a CONSTANT_Methodref_info structure representing a class's method for which a method handle is to be created;
+                // if the class file version number is 52.0 or above, the constant_pool entry at that index must be
+                // either a CONSTANT_Methodref_info structure or a CONSTANT_InterfaceMethodref_info structure (ยง4.4.2)
+                // representing a class's or interface's method for which a method handle is to be created.
+                ConstType ctype = ConstType.CONSTANT_METHOD;
+                if ( this.cd.cfv.major_version() >= 52 && Modifiers.isInterface(this.cd.access) ) {
+                    ctype = ConstType.CONSTANT_INTERFACEMETHOD;
+                }
+                refCell = pool.FindCell(cpParser.parseConstValue(ctype));
                 break;
             case REF_INVOKEINTERFACE:
                 refCell = pool.FindCell(cpParser.parseConstValue(ConstType.CONSTANT_INTERFACEMETHOD));