changeset 72:1568fda1153b

meth-edrfix: remove double casts (requires meth-cast-6979683.patch)
author jrose
date Thu, 26 Aug 2010 15:35:54 -0700
parents 8a875638e902
children 1b67f18d903f
files meth-edrfix-6979327.patch
diffstat 1 files changed, 77 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/meth-edrfix-6979327.patch	Thu Aug 26 15:30:00 2010 -0700
+++ b/meth-edrfix-6979327.patch	Thu Aug 26 15:35:54 2010 -0700
@@ -14,7 +14,7 @@
 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
-@@ -171,10 +171,6 @@
+@@ -174,10 +174,6 @@
      public boolean allowStringsInSwitch() {
          return compareTo(JDK1_7) >= 0;
      }
@@ -28,7 +28,7 @@
 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
-@@ -1121,6 +1121,7 @@
+@@ -1162,6 +1162,7 @@
  
      public void visitExec(JCExpressionStatement tree) {
          attribExpr(tree.expr, env);
@@ -36,7 +36,7 @@
          result = null;
      }
  
-@@ -1378,23 +1379,22 @@
+@@ -1419,23 +1420,22 @@
                                restype.tsym);
              }
  
@@ -74,7 +74,7 @@
                  chk.checkRefTypes(tree.typeargs, typeargtypes);
              }
  
-@@ -1949,12 +1949,48 @@
+@@ -2004,12 +2004,36 @@
          Type clazztype = attribType(tree.clazz, env);
          chk.validate(tree.clazz, env);
          Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly);
@@ -88,17 +88,6 @@
 +    // A cast or occurrence as an expression statement can affect the linkage of some method calls.
 +    JCExpression pushTargetType(Type targetType, JCExpression expr) {
 +        // JSR 292:  Link some calls according to return type as indicated by a cast.
-+        JCExpression transformedExpr = expr;
-+        JCTypeCast enclosingCast = null;
-+        if (targetType.isPrimitive() && expr.getTag() == JCTree.TYPECAST) {
-+            enclosingCast = (JCTypeCast)expr;
-+            if (types.boxedClass(targetType) == enclosingCast.type.tsym) {
-+                expr = enclosingCast.expr;
-+                // If the expr in turn is a MH.invoke expression,
-+                // we will change (int)(Integer)MH.invoke(...) to (int)MH.invoke(...),
-+                // with a linkage change to return the int directly.
-+            }
-+        }
 +        if (expr.getTag() == JCTree.APPLY) {
 +            JCExpression meth = ((JCMethodInvocation)expr).meth;
 +            if (meth.getTag() == JCTree.SELECT) {
@@ -113,11 +102,10 @@
 +                        throw new AssertionError("can't split poly sym: "+sym);
 +                    methsel.sym = newSym;
 +                    expr.type = targetType;
-+                    transformedExpr = expr;
 +                }
 +            }
 +        }
-+        return transformedExpr;
++        return expr;
 +    }
 +
      public void visitTypeTest(JCInstanceOf tree) {
@@ -126,8 +114,12 @@
 diff --git a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
-@@ -772,8 +772,14 @@
-             // translates to a classfile attribute.
+@@ -769,11 +769,17 @@
+                 && types.isSameType(c.type, syms.deprecatedType))
+                 s.flags_field |= Flags.DEPRECATED;
+             // Internally to java.dyn, a @PolymorphicSignature annotation
+-            // translates to a classfile attribute.
++            // acts like a classfile attribute.
              if (!c.type.isErroneous()
                  && types.isSameType(c.type, syms.polymorphicSignatureType)) {
 +                if (!target.hasMethodHandles()) {
@@ -168,7 +160,15 @@
      }
  
      /** error symbols, which are returned when resolution fails
-@@ -301,7 +306,6 @@
+@@ -252,6 +257,7 @@
+         else {
+             Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true);
+             return (s2 == null || s2 == sym ||
++                    isPolymorphicSignatureGeneric(s2) ||  // sym=invokeExact(Object[]) s2=invokeExact(Object...)
+                     !types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym)));
+         }
+     }
+@@ -301,7 +307,6 @@
                          boolean useVarargs,
                          Warner warn)
          throws Infer.InferenceException {
@@ -176,7 +176,7 @@
          if (useVarargs && (m.flags() & VARARGS) == 0) return null;
          Type mt = types.memberType(site, m);
  
-@@ -578,13 +582,15 @@
+@@ -578,13 +583,15 @@
          if (sym.kind == ERR) return bestSoFar;
          if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
          assert sym.kind < AMBIGUOUS;
@@ -194,7 +194,7 @@
          }
          try {
              if (rawInstantiate(env, site, sym, argtypes, typeargtypes,
-@@ -757,12 +763,13 @@
+@@ -757,12 +764,13 @@
                        boolean useVarargs,
                        boolean operator) {
          Symbol bestSoFar = methodNotFound;
@@ -211,7 +211,7 @@
          }
          return findMethod(env,
                            site,
-@@ -908,43 +915,35 @@
+@@ -908,43 +916,35 @@
      /** Find or create an implicit method of exactly the given type (after erasure).
       *  Searches in a side table, not the main scope of the site.
       *  This emulates the lookup process required by JSR 292 in JVM.
@@ -266,7 +266,7 @@
              exType = List.of(syms.throwableType);
              flags = PUBLIC | STATIC;
          }
-@@ -972,7 +971,7 @@
+@@ -972,7 +972,7 @@
          }
          assert argumentsAcceptable(argtypes, types.memberType(site, m).getParameterTypes(),
                                     false, false, Warner.noWarnings);
@@ -275,7 +275,7 @@
          return m;
      }
      //where
-@@ -989,6 +988,29 @@
+@@ -989,6 +989,29 @@
              return argType;
          }
  
@@ -305,7 +305,7 @@
      /** Load toplevel or member class with given fully qualified name and
       *  verify that it is accessible.
       *  @param env       The current environment.
-@@ -1367,6 +1389,14 @@
+@@ -1367,6 +1390,14 @@
              methodResolutionCache.put(steps.head, sym);
              steps = steps.tail;
          }
@@ -320,7 +320,7 @@
          if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
              MethodResolutionPhase errPhase =
                      firstErroneousResolutionPhase();
-@@ -1374,6 +1404,12 @@
+@@ -1374,6 +1405,12 @@
                      pos, site, name, true, argtypes, typeargtypes);
              env.info.varArgs = errPhase.isVarargsRequired;
          }
@@ -333,27 +333,49 @@
          return sym;
      }
  
+diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
++++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+@@ -1098,12 +1098,6 @@
+                 }
+             },
+ 
+-            new AttributeReader(names.PolymorphicSignature, V45_3/*S.B.V51*/, CLASS_OR_MEMBER_ATTRIBUTE) {
+-                void read(Symbol sym, int attrLen) {
+-                    sym.flags_field |= POLYMORPHIC_SIGNATURE;
+-                }
+-            },
+-
+ 
+             // The following attributes for a Code attribute are not currently handled
+             // StackMapTable
+@@ -1289,6 +1283,9 @@
+                     sym.flags_field |= PROPRIETARY;
+                 else
+                     proxies.append(proxy);
++                if (majorVersion >= V51.major && proxy.type.tsym == syms.polymorphicSignatureType.tsym) {
++                    sym.flags_field |= POLYMORPHIC_SIGNATURE;
++                }
+             }
+             annotate.later(new AnnotationCompleter(sym, proxies.toList()));
+         }
 diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
-@@ -652,11 +652,12 @@
+@@ -651,13 +651,6 @@
+             endAttr(alenIdx);
              acount++;
          }
-         if ((flags & POLYMORPHIC_SIGNATURE) != 0) {
+-        if ((flags & POLYMORPHIC_SIGNATURE) != 0) {
 -            if (target.majorVersion < 51)
 -                throw new AssertionError("PolymorphicSignature attributes in java/dyn must be written with -target 7 (required major version is 51, current is"+target.majorVersion+")");
 -            int alenIdx = writeAttr(names.PolymorphicSignature);
 -            endAttr(alenIdx);
 -            acount++;
-+            // Emit the attribute only if the target expects it.
-+            if (target.hasMethodHandles()) {
-+                int alenIdx = writeAttr(names.PolymorphicSignature);
-+                endAttr(alenIdx);
-+                acount++;
-+            }
-         }
+-        }
          return acount;
      }
+ 
 diff --git a/src/share/classes/com/sun/tools/javac/jvm/Target.java b/src/share/classes/com/sun/tools/javac/jvm/Target.java
 --- a/src/share/classes/com/sun/tools/javac/jvm/Target.java
 +++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java
@@ -392,7 +414,7 @@
 diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/share/classes/com/sun/tools/javac/resources/compiler.properties
 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties
 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties
-@@ -124,6 +124,13 @@
+@@ -126,6 +126,13 @@
  compiler.err.no.superclass=\
      {0} has no superclass
  
@@ -409,7 +431,15 @@
 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 @@
+@@ -103,7 +103,6 @@
+     public final Name RuntimeInvisibleTypeAnnotations;
+     public final Name RuntimeVisibleParameterAnnotations;
+     public final Name RuntimeInvisibleParameterAnnotations;
+-    public final Name PolymorphicSignature;
+     public final Name Value;
+     public final Name EnclosingMethod;
+     public final Name desiredAssertionStatus;
+@@ -116,6 +115,7 @@
      public final Name value;
      public final Name getMessage;
      public final Name getClass;
@@ -417,7 +447,15 @@
      public final Name TYPE;
      public final Name TYPE_USE;
      public final Name TYPE_PARAMETER;
-@@ -228,6 +229,7 @@
+@@ -215,7 +215,6 @@
+         RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
+         RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
+         RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
+-        PolymorphicSignature = fromString("PolymorphicSignature");
+         Value = fromString("Value");
+         EnclosingMethod = fromString("EnclosingMethod");
+ 
+@@ -230,6 +229,7 @@
          value = fromString("value");
          getMessage = fromString("getMessage");
          getClass = fromString("getClass");