| author | Ayushman Jain | 2012-07-20 06:17:24 (EDT) |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2012-08-10 02:57:28 (EDT) |
| commit | 28af1b381fbe3ba1e0381f77621ff65d497927e0 (patch) (side-by-side diff) | |
| tree | dc4f1a97c2ffa9fabc7a46a6e1d60ad2249cc3f4 | |
| parent | 77c4fc99b77799252d5be9c7606ffbaa714b3d5d (diff) | |
| download | eclipse.jdt.core-28af1b381fbe3ba1e0381f77621ff65d497927e0.zip eclipse.jdt.core-28af1b381fbe3ba1e0381f77621ff65d497927e0.tar.gz eclipse.jdt.core-28af1b381fbe3ba1e0381f77621ff65d497927e0.tar.bz2 | |
master - Fixed Bug 385404 - [1.7][compiler] invokeExact is not
translated correctly if the arguments is an array of Object
Change-Id: I199e5e37848b04ad31052e9386f369e358720dec
2 files changed, 23 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java index 6c60003..df9dd79 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation. + * Copyright (c) 2011, 2012 IBM Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,18 +27,34 @@ public class PolymorphicSignatureTest extends AbstractRegressionTest { this.runConformTest( new String[] { "X.java", - "import java.lang.invoke.*; \n" + + "import java.lang.invoke.*;\n" + "public class X {\n" + " public static void main(String[] args) throws Throwable{\n" + " MethodType mt; MethodHandle mh; \n" + " MethodHandles.Lookup lookup = MethodHandles.lookup();\n" + " mt = MethodType.methodType(String.class, char.class, char.class);\n"+ " mh = lookup.findVirtual(String.class, \"replace\", mt);\n"+ - " String s = (String) mh.invokeExact(\"daddy\",'d','n');\n"+ + " String s = (String) mh.invokeExact(\"daddy\",'d','n');\n"+ " System.out.println(s);\n"+ " }\n" + "}\n" }, "nanny"); } + public void test0002() { + this.runConformTest( + new String[] { + "X.java", + "import static java.lang.invoke.MethodHandles.*; \n" + + "import java.lang.invoke.MethodHandle;\n" + + "public class X {\n" + + " public static void main(String[] args) throws Throwable {\n" + + " MethodHandle mh = dropArguments(insertArguments(identity(int.class), 0, 42), 0, Object[].class);\n" + + " int value = (int)mh.invokeExact(new Object[0]);\n" + + " System.out.println(value);\n"+ + " }\n" + + "}" + }, + "42"); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java index 6d128b7..9066874 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java @@ -1020,7 +1020,11 @@ public abstract class Scope { } // targeting a generic method could find an exact match with variable return type if (invocationSite.genericTypeArguments() != null) { + // computeCompatibleMethod(..) will return a PolymorphicMethodBinding if needed exactMethod = computeCompatibleMethod(exactMethod, argumentTypes, invocationSite); + } else if ((exactMethod.tagBits & TagBits.AnnotationPolymorphicSignature) != 0) { + // generate polymorphic method + return this.environment().createPolymorphicMethod(exactMethod, argumentTypes); } return exactMethod; } |

