changeset 48745:013f4b05f49a condy-folding

fix bug in the generation of a fake owner for some method references
author vromero
date Tue, 16 Jan 2018 19:35:36 -0500
parents d1b9262fab0e
children 042e625f2311
files src/jdk.compiler/share/classes/com/sun/tools/javac/util/Constables.java
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Constables.java	Mon Jan 15 21:44:17 2018 -0500
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Constables.java	Tue Jan 16 19:35:36 2018 -0500
@@ -405,11 +405,25 @@
     public Class<?> dynamicConstantClass;
     public Class<?> symRefs;
 
+    boolean canHaveInterfaceOwner(int refKind) {
+        switch (refKind) {
+            case ClassFile.REF_invokeStatic:
+            case ClassFile.REF_invokeSpecial:
+            case ClassFile.REF_invokeInterface:
+            case ClassFile.REF_getStatic:
+            case ClassFile.REF_putStatic:
+                return true;
+            default:
+                return false;
+        }
+    }
+
     private Symbol getReferenceSymbol(int refKind, Symbol owner, String name, MethodType methodType) {
         long flags = refKind == ClassFile.REF_getStatic ||
                 refKind == ClassFile.REF_putStatic ||
                 refKind == ClassFile.REF_invokeStatic ? STATIC : 0;
         Name symbolName = refKind == ClassFile.REF_newInvokeSpecial ? names.init : names.fromString(name);
+        boolean canHaveInterfaceOwner = canHaveInterfaceOwner(refKind);
         switch (refKind) {
             case ClassFile.REF_newInvokeSpecial :
             case ClassFile.REF_invokeVirtual:
@@ -419,10 +433,7 @@
                 if (refKind == ClassFile.REF_invokeInterface && (owner.flags_field & INTERFACE) == 0) {
                     return generateMethodSymbolHelper(owner, symbolName, methodType, flags, true);
                 }
-                if (refKind != ClassFile.REF_invokeInterface && (owner.flags_field & INTERFACE) != 0) {
-                    return generateMethodSymbolHelper(owner, symbolName, methodType, flags, false);
-                }
-                if (refKind == ClassFile.REF_newInvokeSpecial && (owner.flags_field & INTERFACE) != 0) {
+                if (!canHaveInterfaceOwner && (owner.flags_field & INTERFACE) != 0) {
                     return generateMethodSymbolHelper(owner, symbolName, methodType, flags, false);
                 }
                 return new MethodSymbol(flags, symbolName, methodType, owner);