changeset 56:d5f083ee4032

meth: patch for javac/jdk version skew, if needed
author jrose
date Tue, 29 Jun 2010 18:57:07 -0700
parents edbc97c550e4
children e1dc6d53bb96
files meth-edrfix.patch series
diffstat 2 files changed, 114 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/meth-edrfix.patch	Tue Jun 29 18:57:07 2010 -0700
@@ -0,0 +1,107 @@
+Allow new versions of javac to compile old versions of JSR 292 code.
+This patch can go away when the old versions of JSR 292 code have gone away.
+Hopefully, it won't be needed at all.
+
+Local definitions:
+ "new version of javac" = version which requires @PolymorphicSignature annotations in java.dyn.MethodHandle.
+ "old version of JSR 292 code" = version in which java.dyn.MethodHandle lacks @PolymorphicSignature annotations.
+
+diff --git a/src/share/classes/com/sun/tools/javac/code/Source.java b/src/share/classes/com/sun/tools/javac/code/Source.java
+--- a/src/share/classes/com/sun/tools/javac/code/Source.java
++++ b/src/share/classes/com/sun/tools/javac/code/Source.java
+@@ -172,6 +172,10 @@
+     public boolean allowPolymorphicSignature() {
+         return compareTo(JDK1_7) >= 0;
+     }
++    public boolean allowTransitionalJSR292() {
++        // FIXME: Get rid of this after spec. is finalized and transitional code is gone.
++        return allowPolymorphicSignature();
++    }
+     public static SourceVersion toSourceVersion(Source source) {
+         switch(source) {
+         case JDK1_2:
+diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java
+--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java
++++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java
+@@ -118,6 +118,7 @@
+         allowCovariantReturns = source.allowCovariantReturns();
+         allowAnonOuterThis = source.allowAnonOuterThis();
+         allowStringsInSwitch = source.allowStringsInSwitch();
++        allowTransitionalJSR292 = source.allowTransitionalJSR292();
+         sourceName = source.name;
+         relax = (options.get("-retrofit") != null ||
+                  options.get("-relax") != null);
+@@ -171,6 +172,9 @@
+      */
+     boolean allowStringsInSwitch;
+ 
++    /** Transitional before JSR 292 final. */
++    boolean allowTransitionalJSR292;
++
+     /**
+      * Switch: name of source level; used for error reporting.
+      */
+@@ -1376,6 +1380,10 @@
+               if ((mfield.selected.type.tsym != null &&
+                    (mfield.selected.type.tsym.flags() & POLYMORPHIC_SIGNATURE) != 0)
+                   ||
++                  (allowTransitionalJSR292 &&  // old logic that doesn't use annotations
++                   ((mfield.selected.type == syms.methodHandleType && methName == names.invoke)
++                    || mfield.selected.type == syms.invokeDynamicType))
++                  ||
+                   (mfield.sym != null &&
+                    (mfield.sym.flags() & POLYMORPHIC_SIGNATURE) != 0)) {
+                   assert types.isSameType(restype, typeargtypes.head) : mtype;
+diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java
++++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+@@ -68,6 +68,7 @@
+     public final boolean boxingEnabled; // = source.allowBoxing();
+     public final boolean varargsEnabled; // = source.allowVarargs();
+     public final boolean allowPolymorphicSignature;
++    public final boolean allowTransitionalJSR292;
+     private final boolean debugResolve;
+ 
+     public static Resolve instance(Context context) {
+@@ -106,6 +107,7 @@
+         Options options = Options.instance(context);
+         debugResolve = options.get("debugresolve") != null;
+         allowPolymorphicSignature = source.allowPolymorphicSignature() || options.get("invokedynamic") != null;
++        allowTransitionalJSR292 = source.allowTransitionalJSR292();
+     }
+ 
+     /** error symbols, which are returned when resolution fails
+@@ -1365,6 +1367,14 @@
+             methodResolutionCache.put(steps.head, sym);
+             steps = steps.tail;
+         }
++        if (allowTransitionalJSR292 &&  // old logic that doesn't use annotations
++            sym.kind >= AMBIGUOUS &&
++            (site == syms.invokeDynamicType ||
++             site == syms.methodHandleType && name == names.invoke)) {
++            // lookup failed; supply an exactly-typed implicit method
++            sym = findPolymorphicSignatureInstance(env, site, name, null, argtypes, typeargtypes);
++            env.info.varArgs = false;
++        }
+         if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
+             MethodResolutionPhase errPhase =
+                     firstErroneousResolutionPhase();
+diff --git a/src/share/classes/com/sun/tools/javac/util/Names.java b/src/share/classes/com/sun/tools/javac/util/Names.java
+--- a/src/share/classes/com/sun/tools/javac/util/Names.java
++++ b/src/share/classes/com/sun/tools/javac/util/Names.java
+@@ -116,6 +116,7 @@
+     public final Name value;
+     public final Name getMessage;
+     public final Name getClass;
++    public final Name invoke;  //allowTransitionalJSR292 only
+     public final Name TYPE;
+     public final Name TYPE_USE;
+     public final Name TYPE_PARAMETER;
+@@ -228,6 +229,7 @@
+         value = fromString("value");
+         getMessage = fromString("getMessage");
+         getClass = fromString("getClass");
++        invoke = fromString("invoke");  //allowTransitionalJSR292 only
+ 
+         TYPE = fromString("TYPE");
+         TYPE_USE = fromString("TYPE_USE");
--- a/series	Tue May 11 17:49:05 2010 -0700
+++ b/series	Tue Jun 29 18:57:07 2010 -0700
@@ -4,11 +4,15 @@
 netbeans-project.patch          #+netbeans-project
 dump-stack-on-error.patch       #+dump-stack-on-error
 
+# pushed to jdk7/hotspot-comp; will be deleted when they get to bsd-port:
+meth-ing-6939134.patch          #-/meth #+6c9fc54a9389
+
+# non-pushed files are under review or development, or merely experimental:
 meth.patch                      #-/meth #+6c9fc54a9389
-meth-ing-6939134.patch          #-/meth #+6c9fc54a9389
+meth-edrfix.patch               #-/meth #+6c9fc54a9389
+meth-ldc-6939203.patch          #-/meth #+6c9fc54a9389 #-/experimental
 meth-ver-6949040.patch          #-/meth #+6c9fc54a9389 #-testable
-meth-ldc-6939203.patch          #-/meth #+6c9fc54a9389
-meth-anno.patch                 #-/meth #+6c9fc54a9389 #-testable
+meth-anno.patch                 #-/meth #+6c9fc54a9389 #-/experimental #-testable
 
 # Keep these separate, for debugging and review:
 dyncast.patch   #+dyncast       #-/dyncast