6992698: JSR 292: remove support for transient syntax in polymorphic signature calls

Fri, 14 Jan 2011 09:45:04 +0000

author
mcimadamore
date
Fri, 14 Jan 2011 09:45:04 +0000
changeset 820
2d5aff89aaa3
parent 819
a466f00c5cd2
child 821
c8d312dd17bc

6992698: JSR 292: remove support for transient syntax in polymorphic signature calls
Summary: special syntax to denote indy return type through type parameters should be removed (and cast shall be used instead)
Reviewed-by: jjg, jrose

src/share/classes/com/sun/tools/javac/code/Symtab.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Attr.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Flow.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Resolve.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/jvm/Gen.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/jvm/Items.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/main/Main.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/resources/compiler.properties file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/Names.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java file | annotate | diff | comparison | revisions
test/tools/javac/meth/InvokeDynTrans.out file | annotate | diff | comparison | revisions
test/tools/javac/meth/InvokeMHTrans.java file | annotate | diff | comparison | revisions
test/tools/javac/meth/InvokeMHTrans.out file | annotate | diff | comparison | revisions
test/tools/javac/meth/TestCP.java file | annotate | diff | comparison | revisions
test/tools/javac/meth/XlintWarn.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Jan 13 21:28:38 2011 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Jan 14 09:45:04 2011 +0000
     1.3 @@ -126,7 +126,6 @@
     1.4      public final Type serializableType;
     1.5      public final Type methodHandleType;
     1.6      public final Type polymorphicSignatureType;
     1.7 -    public final Type invokeDynamicType;
     1.8      public final Type throwableType;
     1.9      public final Type errorType;
    1.10      public final Type illegalArgumentExceptionType;
    1.11 @@ -422,7 +421,6 @@
    1.12          serializableType = enterClass("java.io.Serializable");
    1.13          methodHandleType = enterClass("java.dyn.MethodHandle");
    1.14          polymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature");
    1.15 -        invokeDynamicType = enterClass("java.dyn.InvokeDynamic");
    1.16          errorType = enterClass("java.lang.Error");
    1.17          illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
    1.18          exceptionType = enterClass("java.lang.Exception");
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jan 13 21:28:38 2011 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Jan 14 09:45:04 2011 +0000
     2.3 @@ -1334,7 +1334,6 @@
     2.4  
     2.5          // The types of the actual method type arguments.
     2.6          List<Type> typeargtypes = null;
     2.7 -        boolean typeargtypesNonRefOK = false;
     2.8  
     2.9          Name methName = TreeInfo.name(tree.meth);
    2.10  
    2.11 @@ -1463,21 +1462,7 @@
    2.12                                restype.tsym);
    2.13              }
    2.14  
    2.15 -            // Special case logic for JSR 292 types.
    2.16 -            if (rs.allowTransitionalJSR292 &&
    2.17 -                    tree.meth.getTag() == JCTree.SELECT &&
    2.18 -                    !typeargtypes.isEmpty()) {
    2.19 -                JCFieldAccess mfield = (JCFieldAccess) tree.meth;
    2.20 -                // MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
    2.21 -                // has type <T>, and T can be a primitive type.
    2.22 -                if (mfield.sym != null &&
    2.23 -                        mfield.sym.isPolymorphicSignatureInstance())
    2.24 -                    typeargtypesNonRefOK = true;
    2.25 -            }
    2.26 -
    2.27 -            if (!(rs.allowTransitionalJSR292 && typeargtypesNonRefOK)) {
    2.28 -                chk.checkRefTypes(tree.typeargs, typeargtypes);
    2.29 -            }
    2.30 +            chk.checkRefTypes(tree.typeargs, typeargtypes);
    2.31  
    2.32              // Check that value of resulting type is admissible in the
    2.33              // current context.  Also, capture the return type
     3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Jan 13 21:28:38 2011 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Jan 14 09:45:04 2011 +0000
     3.3 @@ -1375,8 +1375,9 @@
     3.4      //where
     3.5          private boolean is292targetTypeCast(JCTypeCast tree) {
     3.6              boolean is292targetTypeCast = false;
     3.7 -            if (tree.expr.getTag() == JCTree.APPLY) {
     3.8 -                JCMethodInvocation apply = (JCMethodInvocation)tree.expr;
     3.9 +            JCExpression expr = TreeInfo.skipParens(tree.expr);
    3.10 +            if (expr.getTag() == JCTree.APPLY) {
    3.11 +                JCMethodInvocation apply = (JCMethodInvocation)expr;
    3.12                  Symbol sym = TreeInfo.symbol(apply.meth);
    3.13                  is292targetTypeCast = sym != null &&
    3.14                      sym.kind == MTH &&
     4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Jan 13 21:28:38 2011 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jan 14 09:45:04 2011 +0000
     4.3 @@ -27,6 +27,7 @@
     4.4  
     4.5  import com.sun.tools.javac.tree.JCTree;
     4.6  import com.sun.tools.javac.tree.JCTree.JCTypeCast;
     4.7 +import com.sun.tools.javac.tree.TreeInfo;
     4.8  import com.sun.tools.javac.util.*;
     4.9  import com.sun.tools.javac.util.List;
    4.10  import com.sun.tools.javac.code.*;
    4.11 @@ -538,43 +539,39 @@
    4.12  
    4.13      /**
    4.14       * Compute a synthetic method type corresponding to the requested polymorphic
    4.15 -     * method signature. If no explicit return type is supplied, a provisional
    4.16 -     * return type is computed (just Object in case of non-transitional 292)
    4.17 +     * method signature. The target return type is computed from the immediately
    4.18 +     * enclosing scope surrounding the polymorphic-signature call.
    4.19       */
    4.20      Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site,
    4.21                                              Name name,
    4.22                                              MethodSymbol spMethod,  // sig. poly. method or null if none
    4.23 -                                            List<Type> argtypes,
    4.24 -                                            List<Type> typeargtypes) {
    4.25 +                                            List<Type> argtypes) {
    4.26          final Type restype;
    4.27 -        if (rs.allowTransitionalJSR292 && typeargtypes.nonEmpty()) {
    4.28 -            restype = typeargtypes.head;
    4.29 -        } else {
    4.30 -            //The return type for a polymorphic signature call is computed from
    4.31 -            //the enclosing tree E, as follows: if E is a cast, then use the
    4.32 -            //target type of the cast expression as a return type; if E is an
    4.33 -            //expression statement, the return type is 'void' - otherwise the
    4.34 -            //return type is simply 'Object'. A correctness check ensures that
    4.35 -            //env.next refers to the lexically enclosing environment in which
    4.36 -            //the polymorphic signature call environment is nested.
    4.37  
    4.38 -            switch (env.next.tree.getTag()) {
    4.39 -                case JCTree.TYPECAST:
    4.40 -                    JCTypeCast castTree = (JCTypeCast)env.next.tree;
    4.41 -                    restype = (castTree.expr == env.tree) ?
    4.42 -                        castTree.clazz.type :
    4.43 -                        syms.objectType;
    4.44 -                    break;
    4.45 -                case JCTree.EXEC:
    4.46 -                    JCTree.JCExpressionStatement execTree =
    4.47 -                            (JCTree.JCExpressionStatement)env.next.tree;
    4.48 -                    restype = (execTree.expr == env.tree) ?
    4.49 -                        syms.voidType :
    4.50 -                        syms.objectType;
    4.51 -                    break;
    4.52 -                default:
    4.53 -                    restype = syms.objectType;
    4.54 -            }
    4.55 +        //The return type for a polymorphic signature call is computed from
    4.56 +        //the enclosing tree E, as follows: if E is a cast, then use the
    4.57 +        //target type of the cast expression as a return type; if E is an
    4.58 +        //expression statement, the return type is 'void' - otherwise the
    4.59 +        //return type is simply 'Object'. A correctness check ensures that
    4.60 +        //env.next refers to the lexically enclosing environment in which
    4.61 +        //the polymorphic signature call environment is nested.
    4.62 +
    4.63 +        switch (env.next.tree.getTag()) {
    4.64 +            case JCTree.TYPECAST:
    4.65 +                JCTypeCast castTree = (JCTypeCast)env.next.tree;
    4.66 +                restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ?
    4.67 +                    castTree.clazz.type :
    4.68 +                    syms.objectType;
    4.69 +                break;
    4.70 +            case JCTree.EXEC:
    4.71 +                JCTree.JCExpressionStatement execTree =
    4.72 +                        (JCTree.JCExpressionStatement)env.next.tree;
    4.73 +                restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ?
    4.74 +                    syms.voidType :
    4.75 +                    syms.objectType;
    4.76 +                break;
    4.77 +            default:
    4.78 +                restype = syms.objectType;
    4.79          }
    4.80  
    4.81          List<Type> paramtypes = Type.map(argtypes, implicitArgType);
     5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Jan 13 21:28:38 2011 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jan 14 09:45:04 2011 +0000
     5.3 @@ -70,8 +70,6 @@
     5.4      public final boolean boxingEnabled; // = source.allowBoxing();
     5.5      public final boolean varargsEnabled; // = source.allowVarargs();
     5.6      public final boolean allowMethodHandles;
     5.7 -    public final boolean allowInvokeDynamic;
     5.8 -    public final boolean allowTransitionalJSR292;
     5.9      private final boolean debugResolve;
    5.10  
    5.11      Scope polymorphicSignatureScope;
    5.12 @@ -111,13 +109,8 @@
    5.13          varargsEnabled = source.allowVarargs();
    5.14          Options options = Options.instance(context);
    5.15          debugResolve = options.isSet("debugresolve");
    5.16 -        allowTransitionalJSR292 = options.isSet("allowTransitionalJSR292");
    5.17          Target target = Target.instance(context);
    5.18 -        allowMethodHandles = allowTransitionalJSR292 ||
    5.19 -                target.hasMethodHandles();
    5.20 -        allowInvokeDynamic = (allowTransitionalJSR292 ||
    5.21 -                target.hasInvokedynamic()) &&
    5.22 -                options.isSet("invokedynamic");
    5.23 +        allowMethodHandles = target.hasMethodHandles();
    5.24          polymorphicSignatureScope = new Scope(syms.noSymbol);
    5.25  
    5.26          inapplicableMethodException = new InapplicableMethodException(diags);
    5.27 @@ -336,8 +329,7 @@
    5.28                          boolean useVarargs,
    5.29                          Warner warn)
    5.30          throws Infer.InferenceException {
    5.31 -        boolean polymorphicSignature = (m.isPolymorphicSignatureGeneric() && allowMethodHandles) ||
    5.32 -                                        isTransitionalDynamicCallSite(site, m);
    5.33 +        boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles;
    5.34          if (useVarargs && (m.flags() & VARARGS) == 0)
    5.35              throw inapplicableMethodException.setMessage(null);
    5.36          Type mt = types.memberType(site, m);
    5.37 @@ -346,10 +338,7 @@
    5.38          // need to inferred.
    5.39          List<Type> tvars = env.info.tvars;
    5.40          if (typeargtypes == null) typeargtypes = List.nil();
    5.41 -        if (allowTransitionalJSR292 && polymorphicSignature && typeargtypes.nonEmpty()) {
    5.42 -            //transitional 292 call sites might have wrong number of targs
    5.43 -        }
    5.44 -        else if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
    5.45 +        if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
    5.46              // This is not a polymorphic method, but typeargs are supplied
    5.47              // which is fine, see JLS3 15.12.2.1
    5.48          } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) {
    5.49 @@ -387,7 +376,7 @@
    5.50  
    5.51          if (instNeeded)
    5.52              return polymorphicSignature ?
    5.53 -                infer.instantiatePolymorphicSignatureInstance(env, site, m.name, (MethodSymbol)m, argtypes, typeargtypes) :
    5.54 +                infer.instantiatePolymorphicSignatureInstance(env, site, m.name, (MethodSymbol)m, argtypes) :
    5.55                  infer.instantiateMethod(env,
    5.56                                      tvars,
    5.57                                      (MethodType)mt,
    5.58 @@ -402,14 +391,6 @@
    5.59          return mt;
    5.60      }
    5.61  
    5.62 -    boolean isTransitionalDynamicCallSite(Type site, Symbol sym) {
    5.63 -        return allowTransitionalJSR292 &&  // old logic that doesn't use annotations
    5.64 -                !sym.isPolymorphicSignatureInstance() &&
    5.65 -                ((allowMethodHandles && site == syms.methodHandleType && // invokeExact, invokeGeneric, invoke
    5.66 -                    (sym.name == names.invoke && sym.isPolymorphicSignatureGeneric())) ||
    5.67 -                (site == syms.invokeDynamicType && allowInvokeDynamic)); // InvokeDynamic.XYZ
    5.68 -    }
    5.69 -
    5.70      /** Same but returns null instead throwing a NoInstanceException
    5.71       */
    5.72      Type instantiate(Env<AttrContext> env,
    5.73 @@ -1412,12 +1393,11 @@
    5.74              steps = steps.tail;
    5.75          }
    5.76          if (sym.kind >= AMBIGUOUS) {
    5.77 -            if (site.tsym.isPolymorphicSignatureGeneric() ||
    5.78 -                    isTransitionalDynamicCallSite(site, sym)) {
    5.79 +            if (site.tsym.isPolymorphicSignatureGeneric()) {
    5.80                  //polymorphic receiver - synthesize new method symbol
    5.81                  env.info.varArgs = false;
    5.82                  sym = findPolymorphicSignatureInstance(env,
    5.83 -                        site, name, null, argtypes, typeargtypes);
    5.84 +                        site, name, null, argtypes);
    5.85              }
    5.86              else {
    5.87                  //if nothing is found return the 'first' error
    5.88 @@ -1431,7 +1411,7 @@
    5.89              //non-instantiated polymorphic signature - synthesize new method symbol
    5.90              env.info.varArgs = false;
    5.91              sym = findPolymorphicSignatureInstance(env,
    5.92 -                    site, name, (MethodSymbol)sym, argtypes, typeargtypes);
    5.93 +                    site, name, (MethodSymbol)sym, argtypes);
    5.94          }
    5.95          return sym;
    5.96      }
    5.97 @@ -1449,15 +1429,9 @@
    5.98      Symbol findPolymorphicSignatureInstance(Env<AttrContext> env, Type site,
    5.99                                              Name name,
   5.100                                              MethodSymbol spMethod,  // sig. poly. method or null if none
   5.101 -                                            List<Type> argtypes,
   5.102 -                                            List<Type> typeargtypes) {
   5.103 -        if (typeargtypes.nonEmpty() && (site.tsym.isPolymorphicSignatureGeneric() ||
   5.104 -                (spMethod != null && spMethod.isPolymorphicSignatureGeneric()))) {
   5.105 -            log.warning(env.tree.pos(), "type.parameter.on.polymorphic.signature");
   5.106 -        }
   5.107 -
   5.108 +                                            List<Type> argtypes) {
   5.109          Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
   5.110 -                site, name, spMethod, argtypes, typeargtypes);
   5.111 +                site, name, spMethod, argtypes);
   5.112          long flags = ABSTRACT | HYPOTHETICAL | POLYMORPHIC_SIGNATURE |
   5.113                      (spMethod != null ?
   5.114                          spMethod.flags() & Flags.AccessFlags :
     6.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Jan 13 21:28:38 2011 -0800
     6.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Jan 14 09:45:04 2011 +0000
     6.3 @@ -2153,9 +2153,6 @@
     6.4              }
     6.5              result = items.
     6.6                  makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
     6.7 -        } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.invokeDynamicType.tsym) {
     6.8 -            base.drop();
     6.9 -            result = items.makeDynamicItem(sym);
    6.10          } else {
    6.11              if (!accessSuper)
    6.12                  sym = binaryQualifier(sym, tree.selected.type);
     7.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Items.java	Thu Jan 13 21:28:38 2011 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Items.java	Fri Jan 14 09:45:04 2011 +0000
     7.3 @@ -139,13 +139,6 @@
     7.4          return new StaticItem(member);
     7.5      }
     7.6  
     7.7 -    /** Make an item representing a dynamically invoked method.
     7.8 -     *  @param member   The represented symbol.
     7.9 -     */
    7.10 -    Item makeDynamicItem(Symbol member) {
    7.11 -        return new DynamicItem(member);
    7.12 -    }
    7.13 -
    7.14      /** Make an item representing an instance variable or method.
    7.15       *  @param member       The represented symbol.
    7.16       *  @param nonvirtual   Is the reference not virtual? (true for constructors
    7.17 @@ -464,38 +457,6 @@
    7.18          }
    7.19      }
    7.20  
    7.21 -    /** An item representing a dynamic call site.
    7.22 -     */
    7.23 -    class DynamicItem extends StaticItem {
    7.24 -        DynamicItem(Symbol member) {
    7.25 -            super(member);
    7.26 -            Assert.check(member.owner == syms.invokeDynamicType.tsym);
    7.27 -        }
    7.28 -
    7.29 -        Item load() {
    7.30 -            Assert.error();
    7.31 -            return null;
    7.32 -        }
    7.33 -
    7.34 -        void store() {
    7.35 -            Assert.error();
    7.36 -        }
    7.37 -
    7.38 -        Item invoke() {
    7.39 -            // assert target.hasNativeInvokeDynamic();
    7.40 -            MethodType mtype = (MethodType)member.erasure(types);
    7.41 -            int rescode = Code.typecode(mtype.restype);
    7.42 -            ClassFile.NameAndType descr = new ClassFile.NameAndType(member.name, mtype);
    7.43 -            code.emitInvokedynamic(pool.put(descr), mtype);
    7.44 -            return stackItem[rescode];
    7.45 -        }
    7.46 -
    7.47 -        public String toString() {
    7.48 -            return "dynamic(" + member + ")";
    7.49 -        }
    7.50 -    }
    7.51 -
    7.52 -
    7.53      /** An item representing an instance variable or method.
    7.54       */
    7.55      class MemberItem extends Item {
     8.1 --- a/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Jan 13 21:28:38 2011 -0800
     8.2 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Fri Jan 14 09:45:04 2011 +0000
     8.3 @@ -284,13 +284,6 @@
     8.4              }
     8.5          }
     8.6  
     8.7 -        // phase this out with JSR 292 PFD
     8.8 -        if ("no".equals(options.get("allowTransitionalJSR292"))) {
     8.9 -            options.put("allowTransitionalJSR292", null);
    8.10 -        } else if (target.hasInvokedynamic() && options.isUnset("allowTransitionalJSR292")) {
    8.11 -            options.put("allowTransitionalJSR292", "allowTransitionalJSR292");
    8.12 -        }
    8.13 -
    8.14          // handle this here so it works even if no other options given
    8.15          String showClass = options.get("showClass");
    8.16          if (showClass != null) {
     9.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jan 13 21:28:38 2011 -0800
     9.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jan 14 09:45:04 2011 +0000
     9.3 @@ -128,8 +128,6 @@
     9.4  compiler.err.no.superclass=\
     9.5      {0} has no superclass
     9.6  
     9.7 -compiler.warn.type.parameter.on.polymorphic.signature=\
     9.8 -    change obsolete notation for MethodHandle invocations from x.<T>invoke(y) to (T)x.invoke(y)
     9.9  compiler.warn.wrong.target.for.polymorphic.signature.definition=\
    9.10      MethodHandle API building requires -target 7 runtimes or better; current is -target {0}
    9.11  
    10.1 --- a/src/share/classes/com/sun/tools/javac/util/Names.java	Thu Jan 13 21:28:38 2011 -0800
    10.2 +++ b/src/share/classes/com/sun/tools/javac/util/Names.java	Fri Jan 14 09:45:04 2011 +0000
    10.3 @@ -74,7 +74,6 @@
    10.4      public final Name serialVersionUID;
    10.5      public final Name java_lang_Enum;
    10.6      public final Name java_dyn_MethodHandle;
    10.7 -    public final Name java_dyn_InvokeDynamic;
    10.8      public final Name package_info;
    10.9      public final Name ConstantValue;
   10.10      public final Name LineNumberTable;
   10.11 @@ -115,7 +114,6 @@
   10.12      public final Name value;
   10.13      public final Name getMessage;
   10.14      public final Name getClass;
   10.15 -    public final Name invoke;  //allowTransitionalJSR292 only
   10.16      public final Name TYPE;
   10.17      public final Name TYPE_USE;
   10.18      public final Name TYPE_PARAMETER;
   10.19 @@ -186,7 +184,6 @@
   10.20          java_io_Serializable = fromString("java.io.Serializable");
   10.21          java_lang_Enum = fromString("java.lang.Enum");
   10.22          java_dyn_MethodHandle = fromString("java.dyn.MethodHandle");
   10.23 -        java_dyn_InvokeDynamic = fromString("java.dyn.InvokeDynamic");
   10.24          package_info = fromString("package-info");
   10.25          serialVersionUID = fromString("serialVersionUID");
   10.26          ConstantValue = fromString("ConstantValue");
   10.27 @@ -230,7 +227,6 @@
   10.28          value = fromString("value");
   10.29          getMessage = fromString("getMessage");
   10.30          getClass = fromString("getClass");
   10.31 -        invoke = fromString("invoke");  //allowTransitionalJSR292 only
   10.32  
   10.33          TYPE = fromString("TYPE");
   10.34          TYPE_USE = fromString("TYPE_USE");
    11.1 --- a/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java	Thu Jan 13 21:28:38 2011 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,33 +0,0 @@
    11.4 -/*
    11.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    11.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 - *
    11.8 - * This code is free software; you can redistribute it and/or modify it
    11.9 - * under the terms of the GNU General Public License version 2 only, as
   11.10 - * published by the Free Software Foundation.
   11.11 - *
   11.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 - * version 2 for more details (a copy is included in the LICENSE file that
   11.16 - * accompanied this code).
   11.17 - *
   11.18 - * You should have received a copy of the GNU General Public License version
   11.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 - *
   11.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 - * or visit www.oracle.com if you need additional information or have any
   11.24 - * questions.
   11.25 - */
   11.26 -
   11.27 -// key: compiler.warn.type.parameter.on.polymorphic.signature
   11.28 -// key: compiler.err.unreported.exception.need.to.catch.or.throw
   11.29 -
   11.30 -import java.dyn.MethodHandle;
   11.31 -
   11.32 -class TypeParameterOnPolymorphicSignature {
   11.33 -    void test(MethodHandle mh) {
   11.34 -        mh.<void>invokeExact("",123);
   11.35 -    }
   11.36 -}
    12.1 --- a/test/tools/javac/meth/InvokeDynTrans.out	Thu Jan 13 21:28:38 2011 -0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,5 +0,0 @@
    12.4 -InvokeDynTrans.java:55:39: compiler.warn.type.parameter.on.polymorphic.signature
    12.5 -InvokeDynTrans.java:57:34: compiler.warn.type.parameter.on.polymorphic.signature
    12.6 -- compiler.err.warnings.and.werror
    12.7 -1 error
    12.8 -2 warnings
    13.1 --- a/test/tools/javac/meth/InvokeMHTrans.java	Thu Jan 13 21:28:38 2011 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,102 +0,0 @@
    13.4 -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
    13.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.6 - *
    13.7 - * This code is free software; you can redistribute it and/or modify it
    13.8 - * under the terms of the GNU General Public License version 2 only, as
    13.9 - * published by the Free Software Foundation.
   13.10 - *
   13.11 - * This code is distributed in the hope that it will be useful, but WITHOUT
   13.12 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.13 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.14 - * version 2 for more details (a copy is included in the LICENSE file that
   13.15 - * accompanied this code).
   13.16 - *
   13.17 - * You should have received a copy of the GNU General Public License version
   13.18 - * 2 along with this work; if not, write to the Free Software Foundation,
   13.19 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.20 - *
   13.21 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.22 - * or visit www.oracle.com if you need additional information or have any
   13.23 - * questions.
   13.24 - */
   13.25 -
   13.26 -/*
   13.27 - * @test
   13.28 - * @bug 6754038 6979327
   13.29 - * @summary Generate call sites for method handle
   13.30 - * @author jrose
   13.31 - *
   13.32 - * @compile/fail/ref=InvokeMHTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeMHTrans.java
   13.33 - */
   13.34 -
   13.35 -/*
   13.36 - * Standalone testing:
   13.37 - * <code>
   13.38 - * $ cd $MY_REPO_DIR/langtools
   13.39 - * $ (cd make; make)
   13.40 - * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
   13.41 - * $ javap -c -classpath dist meth.InvokeMH
   13.42 - * </code>
   13.43 - */
   13.44 -
   13.45 -package meth;
   13.46 -
   13.47 -import java.dyn.MethodHandle;
   13.48 -
   13.49 -public class InvokeMHTrans {
   13.50 -    void test(MethodHandle mh_SiO,
   13.51 -              MethodHandle mh_vS,
   13.52 -              MethodHandle mh_vi,
   13.53 -              MethodHandle mh_vv) throws Throwable {
   13.54 -        Object o; String s; int i;  // for return type testing
   13.55 -
   13.56 -        // next five must have sig = (String,int)Object
   13.57 -        mh_SiO.invokeExact("world", 123);
   13.58 -        mh_SiO.invokeExact("mundus", 456);
   13.59 -        Object k = "kosmos";
   13.60 -        mh_SiO.invokeExact((String)k, 789);
   13.61 -        o = mh_SiO.invokeExact((String)null, 000);
   13.62 -        o = mh_SiO.<Object>invokeExact("arda", -123);
   13.63 -
   13.64 -        // sig = ()String
   13.65 -        s = mh_vS.<String>invokeExact();
   13.66 -
   13.67 -        // sig = ()int
   13.68 -        i = mh_vi.<int>invokeExact();
   13.69 -        o = mh_vi.<int>invokeExact();
   13.70 -        //s = mh_vi.<int>invokeExact(); //BAD
   13.71 -        mh_vi.<int>invokeExact();
   13.72 -
   13.73 -        // sig = ()void
   13.74 -        //o = mh_vv.<void>invokeExact(); //BAD
   13.75 -        mh_vv.<void>invokeExact();
   13.76 -    }
   13.77 -
   13.78 -    void testGen(MethodHandle mh_SiO,
   13.79 -                 MethodHandle mh_vS,
   13.80 -                 MethodHandle mh_vi,
   13.81 -                 MethodHandle mh_vv) throws Throwable {
   13.82 -        Object o; String s; int i;  // for return type testing
   13.83 -
   13.84 -        // next five must have sig = (*,*)*
   13.85 -        mh_SiO.invokeGeneric((Object)"world", (Object)123);
   13.86 -        mh_SiO.<void>invokeGeneric((Object)"mundus", (Object)456);
   13.87 -        Object k = "kosmos";
   13.88 -        mh_SiO.invokeGeneric(k, 789);
   13.89 -        o = mh_SiO.invokeGeneric(null, 000);
   13.90 -        o = mh_SiO.<Object>invokeGeneric("arda", -123);
   13.91 -
   13.92 -        // sig = ()String
   13.93 -        o = mh_vS.invokeGeneric();
   13.94 -
   13.95 -        // sig = ()int
   13.96 -        i = mh_vi.<int>invokeGeneric();
   13.97 -        o = mh_vi.invokeGeneric();
   13.98 -        //s = mh_vi.<int>invokeGeneric(); //BAD
   13.99 -        mh_vi.<void>invokeGeneric();
  13.100 -
  13.101 -        // sig = ()void
  13.102 -        //o = mh_vv.<void>invokeGeneric(); //BAD
  13.103 -        o = mh_vv.invokeGeneric();
  13.104 -    }
  13.105 -}
    14.1 --- a/test/tools/javac/meth/InvokeMHTrans.out	Thu Jan 13 21:28:38 2011 -0800
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,13 +0,0 @@
    14.4 -InvokeMHTrans.java:59:39: compiler.warn.type.parameter.on.polymorphic.signature
    14.5 -InvokeMHTrans.java:62:38: compiler.warn.type.parameter.on.polymorphic.signature
    14.6 -InvokeMHTrans.java:65:35: compiler.warn.type.parameter.on.polymorphic.signature
    14.7 -InvokeMHTrans.java:66:35: compiler.warn.type.parameter.on.polymorphic.signature
    14.8 -InvokeMHTrans.java:68:31: compiler.warn.type.parameter.on.polymorphic.signature
    14.9 -InvokeMHTrans.java:72:32: compiler.warn.type.parameter.on.polymorphic.signature
   14.10 -InvokeMHTrans.java:83:35: compiler.warn.type.parameter.on.polymorphic.signature
   14.11 -InvokeMHTrans.java:87:41: compiler.warn.type.parameter.on.polymorphic.signature
   14.12 -InvokeMHTrans.java:93:37: compiler.warn.type.parameter.on.polymorphic.signature
   14.13 -InvokeMHTrans.java:96:34: compiler.warn.type.parameter.on.polymorphic.signature
   14.14 -- compiler.err.warnings.and.werror
   14.15 -1 error
   14.16 -10 warnings
    15.1 --- a/test/tools/javac/meth/TestCP.java	Thu Jan 13 21:28:38 2011 -0800
    15.2 +++ b/test/tools/javac/meth/TestCP.java	Fri Jan 14 09:45:04 2011 +0000
    15.3 @@ -42,13 +42,15 @@
    15.4  
    15.5      static class TestClass {
    15.6          void test(MethodHandle mh) throws Throwable {
    15.7 -            Number n = mh.<Number>invokeExact("daddy",1,'n');
    15.8 +            Number n = (Number)mh.invokeExact("daddy",1,'n');
    15.9              n = (Number)mh.invokeExact("bunny",1,'d');
   15.10 +            n = (Number)(mh.invokeExact("foo",1,'d'));
   15.11 +            n = (Number)((mh.invokeExact("bar",1,'d')));
   15.12          }
   15.13      }
   15.14  
   15.15      static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
   15.16 -    static final int PS_CALLS_COUNT = 2;
   15.17 +    static final int PS_CALLS_COUNT = 4;
   15.18      static final String SUBTEST_NAME = TestClass.class.getName() + ".class";
   15.19      static final String TEST_METHOD_NAME = "test";
   15.20  
    16.1 --- a/test/tools/javac/meth/XlintWarn.java	Thu Jan 13 21:28:38 2011 -0800
    16.2 +++ b/test/tools/javac/meth/XlintWarn.java	Fri Jan 14 09:45:04 2011 +0000
    16.3 @@ -35,6 +35,19 @@
    16.4  class XlintWarn {
    16.5      void test(MethodHandle mh) throws Throwable {
    16.6          int i1 = (int)mh.invokeExact();
    16.7 -        int i2 = (int)mh.invokeVarargs();
    16.8 +        int i2 = (int)mh.invokeGeneric();
    16.9 +        int i3 = (int)mh.invokeWithArguments();
   16.10 +    }
   16.11 +
   16.12 +    void test2(MethodHandle mh) throws Throwable {
   16.13 +        int i1 = (int)(mh.invokeExact());
   16.14 +        int i2 = (int)(mh.invokeGeneric());
   16.15 +        int i3 = (int)(mh.invokeWithArguments());
   16.16 +    }
   16.17 +
   16.18 +    void test3(MethodHandle mh) throws Throwable {
   16.19 +        int i1 = (int)((mh.invokeExact()));
   16.20 +        int i2 = (int)((mh.invokeGeneric()));
   16.21 +        int i3 = (int)((mh.invokeWithArguments()));
   16.22      }
   16.23  }

mercurial