From b51bae9983d5991a89bc07fa10a9c7d1b098aac5 Mon Sep 17 00:00:00 2001 From: mcimadamore Date: Fri, 14 Jan 2011 09:45:04 +0000 Subject: [PATCH] 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 --- .../com/sun/tools/javac/code/Symtab.java | 2 - .../com/sun/tools/javac/comp/Attr.java | 17 +-- .../com/sun/tools/javac/comp/Flow.java | 5 +- .../com/sun/tools/javac/comp/Infer.java | 61 +++++------ .../com/sun/tools/javac/comp/Resolve.java | 44 ++------ .../classes/com/sun/tools/javac/jvm/Gen.java | 3 - .../com/sun/tools/javac/jvm/Items.java | 39 ------- .../com/sun/tools/javac/main/Main.java | 7 -- .../tools/javac/resources/compiler.properties | 2 - .../com/sun/tools/javac/util/Names.java | 4 - .../TypeParameterOnPolymorphicSignature.java | 33 ------ test/tools/javac/meth/InvokeDynTrans.out | 5 - test/tools/javac/meth/InvokeMHTrans.java | 102 ------------------ test/tools/javac/meth/InvokeMHTrans.out | 13 --- test/tools/javac/meth/TestCP.java | 6 +- test/tools/javac/meth/XlintWarn.java | 15 ++- 16 files changed, 60 insertions(+), 298 deletions(-) delete mode 100644 test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java delete mode 100644 test/tools/javac/meth/InvokeDynTrans.out delete mode 100644 test/tools/javac/meth/InvokeMHTrans.java delete mode 100644 test/tools/javac/meth/InvokeMHTrans.out diff --git a/src/share/classes/com/sun/tools/javac/code/Symtab.java b/src/share/classes/com/sun/tools/javac/code/Symtab.java index 7331be06..bf3e68ac 100644 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java @@ -126,7 +126,6 @@ public class Symtab { public final Type serializableType; public final Type methodHandleType; public final Type polymorphicSignatureType; - public final Type invokeDynamicType; public final Type throwableType; public final Type errorType; public final Type illegalArgumentExceptionType; @@ -422,7 +421,6 @@ public class Symtab { serializableType = enterClass("java.io.Serializable"); methodHandleType = enterClass("java.dyn.MethodHandle"); polymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature"); - invokeDynamicType = enterClass("java.dyn.InvokeDynamic"); errorType = enterClass("java.lang.Error"); illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException"); exceptionType = enterClass("java.lang.Exception"); diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java index c879974f..a701a289 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1334,7 +1334,6 @@ public class Attr extends JCTree.Visitor { // The types of the actual method type arguments. List typeargtypes = null; - boolean typeargtypesNonRefOK = false; Name methName = TreeInfo.name(tree.meth); @@ -1463,21 +1462,7 @@ public class Attr extends JCTree.Visitor { restype.tsym); } - // Special case logic for JSR 292 types. - if (rs.allowTransitionalJSR292 && - tree.meth.getTag() == JCTree.SELECT && - !typeargtypes.isEmpty()) { - JCFieldAccess mfield = (JCFieldAccess) tree.meth; - // MethodHandle.invoke(abc) and InvokeDynamic.foo(abc) - // has type , and T can be a primitive type. - if (mfield.sym != null && - mfield.sym.isPolymorphicSignatureInstance()) - typeargtypesNonRefOK = true; - } - - if (!(rs.allowTransitionalJSR292 && typeargtypesNonRefOK)) { - chk.checkRefTypes(tree.typeargs, typeargtypes); - } + chk.checkRefTypes(tree.typeargs, typeargtypes); // Check that value of resulting type is admissible in the // current context. Also, capture the return type diff --git a/src/share/classes/com/sun/tools/javac/comp/Flow.java b/src/share/classes/com/sun/tools/javac/comp/Flow.java index e047f29e..6b43c46d 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -1375,8 +1375,9 @@ public class Flow extends TreeScanner { //where private boolean is292targetTypeCast(JCTypeCast tree) { boolean is292targetTypeCast = false; - if (tree.expr.getTag() == JCTree.APPLY) { - JCMethodInvocation apply = (JCMethodInvocation)tree.expr; + JCExpression expr = TreeInfo.skipParens(tree.expr); + if (expr.getTag() == JCTree.APPLY) { + JCMethodInvocation apply = (JCMethodInvocation)expr; Symbol sym = TreeInfo.symbol(apply.meth); is292targetTypeCast = sym != null && sym.kind == MTH && diff --git a/src/share/classes/com/sun/tools/javac/comp/Infer.java b/src/share/classes/com/sun/tools/javac/comp/Infer.java index d98fcf18..48b1afff 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -27,6 +27,7 @@ package com.sun.tools.javac.comp; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCTypeCast; +import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.List; import com.sun.tools.javac.code.*; @@ -538,43 +539,39 @@ public class Infer { /** * Compute a synthetic method type corresponding to the requested polymorphic - * method signature. If no explicit return type is supplied, a provisional - * return type is computed (just Object in case of non-transitional 292) + * method signature. The target return type is computed from the immediately + * enclosing scope surrounding the polymorphic-signature call. */ Type instantiatePolymorphicSignatureInstance(Env env, Type site, Name name, MethodSymbol spMethod, // sig. poly. method or null if none - List argtypes, - List typeargtypes) { + List argtypes) { final Type restype; - if (rs.allowTransitionalJSR292 && typeargtypes.nonEmpty()) { - restype = typeargtypes.head; - } else { - //The return type for a polymorphic signature call is computed from - //the enclosing tree E, as follows: if E is a cast, then use the - //target type of the cast expression as a return type; if E is an - //expression statement, the return type is 'void' - otherwise the - //return type is simply 'Object'. A correctness check ensures that - //env.next refers to the lexically enclosing environment in which - //the polymorphic signature call environment is nested. - - switch (env.next.tree.getTag()) { - case JCTree.TYPECAST: - JCTypeCast castTree = (JCTypeCast)env.next.tree; - restype = (castTree.expr == env.tree) ? - castTree.clazz.type : - syms.objectType; - break; - case JCTree.EXEC: - JCTree.JCExpressionStatement execTree = - (JCTree.JCExpressionStatement)env.next.tree; - restype = (execTree.expr == env.tree) ? - syms.voidType : - syms.objectType; - break; - default: - restype = syms.objectType; - } + + //The return type for a polymorphic signature call is computed from + //the enclosing tree E, as follows: if E is a cast, then use the + //target type of the cast expression as a return type; if E is an + //expression statement, the return type is 'void' - otherwise the + //return type is simply 'Object'. A correctness check ensures that + //env.next refers to the lexically enclosing environment in which + //the polymorphic signature call environment is nested. + + switch (env.next.tree.getTag()) { + case JCTree.TYPECAST: + JCTypeCast castTree = (JCTypeCast)env.next.tree; + restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? + castTree.clazz.type : + syms.objectType; + break; + case JCTree.EXEC: + JCTree.JCExpressionStatement execTree = + (JCTree.JCExpressionStatement)env.next.tree; + restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? + syms.voidType : + syms.objectType; + break; + default: + restype = syms.objectType; } List paramtypes = Type.map(argtypes, implicitArgType); diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java index b833af28..f84f8f1c 100644 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -70,8 +70,6 @@ public class Resolve { public final boolean boxingEnabled; // = source.allowBoxing(); public final boolean varargsEnabled; // = source.allowVarargs(); public final boolean allowMethodHandles; - public final boolean allowInvokeDynamic; - public final boolean allowTransitionalJSR292; private final boolean debugResolve; Scope polymorphicSignatureScope; @@ -111,13 +109,8 @@ public class Resolve { varargsEnabled = source.allowVarargs(); Options options = Options.instance(context); debugResolve = options.isSet("debugresolve"); - allowTransitionalJSR292 = options.isSet("allowTransitionalJSR292"); Target target = Target.instance(context); - allowMethodHandles = allowTransitionalJSR292 || - target.hasMethodHandles(); - allowInvokeDynamic = (allowTransitionalJSR292 || - target.hasInvokedynamic()) && - options.isSet("invokedynamic"); + allowMethodHandles = target.hasMethodHandles(); polymorphicSignatureScope = new Scope(syms.noSymbol); inapplicableMethodException = new InapplicableMethodException(diags); @@ -336,8 +329,7 @@ public class Resolve { boolean useVarargs, Warner warn) throws Infer.InferenceException { - boolean polymorphicSignature = (m.isPolymorphicSignatureGeneric() && allowMethodHandles) || - isTransitionalDynamicCallSite(site, m); + boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles; if (useVarargs && (m.flags() & VARARGS) == 0) throw inapplicableMethodException.setMessage(null); Type mt = types.memberType(site, m); @@ -346,10 +338,7 @@ public class Resolve { // need to inferred. List tvars = env.info.tvars; if (typeargtypes == null) typeargtypes = List.nil(); - if (allowTransitionalJSR292 && polymorphicSignature && typeargtypes.nonEmpty()) { - //transitional 292 call sites might have wrong number of targs - } - else if (mt.tag != FORALL && typeargtypes.nonEmpty()) { + if (mt.tag != FORALL && typeargtypes.nonEmpty()) { // This is not a polymorphic method, but typeargs are supplied // which is fine, see JLS3 15.12.2.1 } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) { @@ -387,7 +376,7 @@ public class Resolve { if (instNeeded) return polymorphicSignature ? - infer.instantiatePolymorphicSignatureInstance(env, site, m.name, (MethodSymbol)m, argtypes, typeargtypes) : + infer.instantiatePolymorphicSignatureInstance(env, site, m.name, (MethodSymbol)m, argtypes) : infer.instantiateMethod(env, tvars, (MethodType)mt, @@ -402,14 +391,6 @@ public class Resolve { return mt; } - boolean isTransitionalDynamicCallSite(Type site, Symbol sym) { - return allowTransitionalJSR292 && // old logic that doesn't use annotations - !sym.isPolymorphicSignatureInstance() && - ((allowMethodHandles && site == syms.methodHandleType && // invokeExact, invokeGeneric, invoke - (sym.name == names.invoke && sym.isPolymorphicSignatureGeneric())) || - (site == syms.invokeDynamicType && allowInvokeDynamic)); // InvokeDynamic.XYZ - } - /** Same but returns null instead throwing a NoInstanceException */ Type instantiate(Env env, @@ -1412,12 +1393,11 @@ public class Resolve { steps = steps.tail; } if (sym.kind >= AMBIGUOUS) { - if (site.tsym.isPolymorphicSignatureGeneric() || - isTransitionalDynamicCallSite(site, sym)) { + if (site.tsym.isPolymorphicSignatureGeneric()) { //polymorphic receiver - synthesize new method symbol env.info.varArgs = false; sym = findPolymorphicSignatureInstance(env, - site, name, null, argtypes, typeargtypes); + site, name, null, argtypes); } else { //if nothing is found return the 'first' error @@ -1431,7 +1411,7 @@ public class Resolve { //non-instantiated polymorphic signature - synthesize new method symbol env.info.varArgs = false; sym = findPolymorphicSignatureInstance(env, - site, name, (MethodSymbol)sym, argtypes, typeargtypes); + site, name, (MethodSymbol)sym, argtypes); } return sym; } @@ -1449,15 +1429,9 @@ public class Resolve { Symbol findPolymorphicSignatureInstance(Env env, Type site, Name name, MethodSymbol spMethod, // sig. poly. method or null if none - List argtypes, - List typeargtypes) { - if (typeargtypes.nonEmpty() && (site.tsym.isPolymorphicSignatureGeneric() || - (spMethod != null && spMethod.isPolymorphicSignatureGeneric()))) { - log.warning(env.tree.pos(), "type.parameter.on.polymorphic.signature"); - } - + List argtypes) { Type mtype = infer.instantiatePolymorphicSignatureInstance(env, - site, name, spMethod, argtypes, typeargtypes); + site, name, spMethod, argtypes); long flags = ABSTRACT | HYPOTHETICAL | POLYMORPHIC_SIGNATURE | (spMethod != null ? spMethod.flags() & Flags.AccessFlags : diff --git a/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 7473ec8f..12c2f99f 100644 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -2153,9 +2153,6 @@ public class Gen extends JCTree.Visitor { } result = items. makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue()); - } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.invokeDynamicType.tsym) { - base.drop(); - result = items.makeDynamicItem(sym); } else { if (!accessSuper) sym = binaryQualifier(sym, tree.selected.type); diff --git a/src/share/classes/com/sun/tools/javac/jvm/Items.java b/src/share/classes/com/sun/tools/javac/jvm/Items.java index 36f649ee..5550239f 100644 --- a/src/share/classes/com/sun/tools/javac/jvm/Items.java +++ b/src/share/classes/com/sun/tools/javac/jvm/Items.java @@ -139,13 +139,6 @@ public class Items { return new StaticItem(member); } - /** Make an item representing a dynamically invoked method. - * @param member The represented symbol. - */ - Item makeDynamicItem(Symbol member) { - return new DynamicItem(member); - } - /** Make an item representing an instance variable or method. * @param member The represented symbol. * @param nonvirtual Is the reference not virtual? (true for constructors @@ -464,38 +457,6 @@ public class Items { } } - /** An item representing a dynamic call site. - */ - class DynamicItem extends StaticItem { - DynamicItem(Symbol member) { - super(member); - Assert.check(member.owner == syms.invokeDynamicType.tsym); - } - - Item load() { - Assert.error(); - return null; - } - - void store() { - Assert.error(); - } - - Item invoke() { - // assert target.hasNativeInvokeDynamic(); - MethodType mtype = (MethodType)member.erasure(types); - int rescode = Code.typecode(mtype.restype); - ClassFile.NameAndType descr = new ClassFile.NameAndType(member.name, mtype); - code.emitInvokedynamic(pool.put(descr), mtype); - return stackItem[rescode]; - } - - public String toString() { - return "dynamic(" + member + ")"; - } - } - - /** An item representing an instance variable or method. */ class MemberItem extends Item { diff --git a/src/share/classes/com/sun/tools/javac/main/Main.java b/src/share/classes/com/sun/tools/javac/main/Main.java index c96a1572..be12bb57 100644 --- a/src/share/classes/com/sun/tools/javac/main/Main.java +++ b/src/share/classes/com/sun/tools/javac/main/Main.java @@ -284,13 +284,6 @@ public class Main { } } - // phase this out with JSR 292 PFD - if ("no".equals(options.get("allowTransitionalJSR292"))) { - options.put("allowTransitionalJSR292", null); - } else if (target.hasInvokedynamic() && options.isUnset("allowTransitionalJSR292")) { - options.put("allowTransitionalJSR292", "allowTransitionalJSR292"); - } - // handle this here so it works even if no other options given String showClass = options.get("showClass"); if (showClass != null) { diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 944fd7bd..1a32ae4e 100644 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -128,8 +128,6 @@ compiler.err.call.to.super.not.allowed.in.enum.ctor=\ compiler.err.no.superclass=\ {0} has no superclass -compiler.warn.type.parameter.on.polymorphic.signature=\ - change obsolete notation for MethodHandle invocations from x.invoke(y) to (T)x.invoke(y) compiler.warn.wrong.target.for.polymorphic.signature.definition=\ MethodHandle API building requires -target 7 runtimes or better; current is -target {0} diff --git a/src/share/classes/com/sun/tools/javac/util/Names.java b/src/share/classes/com/sun/tools/javac/util/Names.java index 08a56daf..1dfff566 100644 --- a/src/share/classes/com/sun/tools/javac/util/Names.java +++ b/src/share/classes/com/sun/tools/javac/util/Names.java @@ -74,7 +74,6 @@ public class Names { public final Name serialVersionUID; public final Name java_lang_Enum; public final Name java_dyn_MethodHandle; - public final Name java_dyn_InvokeDynamic; public final Name package_info; public final Name ConstantValue; public final Name LineNumberTable; @@ -115,7 +114,6 @@ public class Names { 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; @@ -186,7 +184,6 @@ public class Names { java_io_Serializable = fromString("java.io.Serializable"); java_lang_Enum = fromString("java.lang.Enum"); java_dyn_MethodHandle = fromString("java.dyn.MethodHandle"); - java_dyn_InvokeDynamic = fromString("java.dyn.InvokeDynamic"); package_info = fromString("package-info"); serialVersionUID = fromString("serialVersionUID"); ConstantValue = fromString("ConstantValue"); @@ -230,7 +227,6 @@ public class Names { value = fromString("value"); getMessage = fromString("getMessage"); getClass = fromString("getClass"); - invoke = fromString("invoke"); //allowTransitionalJSR292 only TYPE = fromString("TYPE"); TYPE_USE = fromString("TYPE_USE"); diff --git a/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java b/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java deleted file mode 100644 index fc23fde5..00000000 --- a/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.warn.type.parameter.on.polymorphic.signature -// key: compiler.err.unreported.exception.need.to.catch.or.throw - -import java.dyn.MethodHandle; - -class TypeParameterOnPolymorphicSignature { - void test(MethodHandle mh) { - mh.invokeExact("",123); - } -} diff --git a/test/tools/javac/meth/InvokeDynTrans.out b/test/tools/javac/meth/InvokeDynTrans.out deleted file mode 100644 index 06ed4851..00000000 --- a/test/tools/javac/meth/InvokeDynTrans.out +++ /dev/null @@ -1,5 +0,0 @@ -InvokeDynTrans.java:55:39: compiler.warn.type.parameter.on.polymorphic.signature -InvokeDynTrans.java:57:34: compiler.warn.type.parameter.on.polymorphic.signature -- compiler.err.warnings.and.werror -1 error -2 warnings diff --git a/test/tools/javac/meth/InvokeMHTrans.java b/test/tools/javac/meth/InvokeMHTrans.java deleted file mode 100644 index b3ebca44..00000000 --- a/test/tools/javac/meth/InvokeMHTrans.java +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6754038 6979327 - * @summary Generate call sites for method handle - * @author jrose - * - * @compile/fail/ref=InvokeMHTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeMHTrans.java - */ - -/* - * Standalone testing: - * - * $ cd $MY_REPO_DIR/langtools - * $ (cd make; make) - * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java - * $ javap -c -classpath dist meth.InvokeMH - * - */ - -package meth; - -import java.dyn.MethodHandle; - -public class InvokeMHTrans { - void test(MethodHandle mh_SiO, - MethodHandle mh_vS, - MethodHandle mh_vi, - MethodHandle mh_vv) throws Throwable { - Object o; String s; int i; // for return type testing - - // next five must have sig = (String,int)Object - mh_SiO.invokeExact("world", 123); - mh_SiO.invokeExact("mundus", 456); - Object k = "kosmos"; - mh_SiO.invokeExact((String)k, 789); - o = mh_SiO.invokeExact((String)null, 000); - o = mh_SiO.invokeExact("arda", -123); - - // sig = ()String - s = mh_vS.invokeExact(); - - // sig = ()int - i = mh_vi.invokeExact(); - o = mh_vi.invokeExact(); - //s = mh_vi.invokeExact(); //BAD - mh_vi.invokeExact(); - - // sig = ()void - //o = mh_vv.invokeExact(); //BAD - mh_vv.invokeExact(); - } - - void testGen(MethodHandle mh_SiO, - MethodHandle mh_vS, - MethodHandle mh_vi, - MethodHandle mh_vv) throws Throwable { - Object o; String s; int i; // for return type testing - - // next five must have sig = (*,*)* - mh_SiO.invokeGeneric((Object)"world", (Object)123); - mh_SiO.invokeGeneric((Object)"mundus", (Object)456); - Object k = "kosmos"; - mh_SiO.invokeGeneric(k, 789); - o = mh_SiO.invokeGeneric(null, 000); - o = mh_SiO.invokeGeneric("arda", -123); - - // sig = ()String - o = mh_vS.invokeGeneric(); - - // sig = ()int - i = mh_vi.invokeGeneric(); - o = mh_vi.invokeGeneric(); - //s = mh_vi.invokeGeneric(); //BAD - mh_vi.invokeGeneric(); - - // sig = ()void - //o = mh_vv.invokeGeneric(); //BAD - o = mh_vv.invokeGeneric(); - } -} diff --git a/test/tools/javac/meth/InvokeMHTrans.out b/test/tools/javac/meth/InvokeMHTrans.out deleted file mode 100644 index a745dcf2..00000000 --- a/test/tools/javac/meth/InvokeMHTrans.out +++ /dev/null @@ -1,13 +0,0 @@ -InvokeMHTrans.java:59:39: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:62:38: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:65:35: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:66:35: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:68:31: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:72:32: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:83:35: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:87:41: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:93:37: compiler.warn.type.parameter.on.polymorphic.signature -InvokeMHTrans.java:96:34: compiler.warn.type.parameter.on.polymorphic.signature -- compiler.err.warnings.and.werror -1 error -10 warnings diff --git a/test/tools/javac/meth/TestCP.java b/test/tools/javac/meth/TestCP.java index bbcb5bf9..b254b3da 100644 --- a/test/tools/javac/meth/TestCP.java +++ b/test/tools/javac/meth/TestCP.java @@ -42,13 +42,15 @@ public class TestCP { static class TestClass { void test(MethodHandle mh) throws Throwable { - Number n = mh.invokeExact("daddy",1,'n'); + Number n = (Number)mh.invokeExact("daddy",1,'n'); n = (Number)mh.invokeExact("bunny",1,'d'); + n = (Number)(mh.invokeExact("foo",1,'d')); + n = (Number)((mh.invokeExact("bar",1,'d'))); } } static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;"; - static final int PS_CALLS_COUNT = 2; + static final int PS_CALLS_COUNT = 4; static final String SUBTEST_NAME = TestClass.class.getName() + ".class"; static final String TEST_METHOD_NAME = "test"; diff --git a/test/tools/javac/meth/XlintWarn.java b/test/tools/javac/meth/XlintWarn.java index 844994b8..38543998 100644 --- a/test/tools/javac/meth/XlintWarn.java +++ b/test/tools/javac/meth/XlintWarn.java @@ -35,6 +35,19 @@ import java.dyn.*; class XlintWarn { void test(MethodHandle mh) throws Throwable { int i1 = (int)mh.invokeExact(); - int i2 = (int)mh.invokeVarargs(); + int i2 = (int)mh.invokeGeneric(); + int i3 = (int)mh.invokeWithArguments(); + } + + void test2(MethodHandle mh) throws Throwable { + int i1 = (int)(mh.invokeExact()); + int i2 = (int)(mh.invokeGeneric()); + int i3 = (int)(mh.invokeWithArguments()); + } + + void test3(MethodHandle mh) throws Throwable { + int i1 = (int)((mh.invokeExact())); + int i2 = (int)((mh.invokeGeneric())); + int i3 = (int)((mh.invokeWithArguments())); } } -- GitLab