aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAyushman Jain2012-07-20 06:17:24 (EDT)
committerAyushman Jain2012-07-20 06:17:24 (EDT)
commit93f7bdc9db07b3d133a0d0cb74ca50592e6517b1 (patch)
tree027de003bf2920de75fcd41139c406e56c4fe0c1
parent166bb18dfc5a3ebc7bd8aa135b74b0c874fa431d (diff)
downloadeclipse.jdt.core-93f7bdc9db07b3d133a0d0cb74ca50592e6517b1.zip
eclipse.jdt.core-93f7bdc9db07b3d133a0d0cb74ca50592e6517b1.tar.gz
eclipse.jdt.core-93f7bdc9db07b3d133a0d0cb74ca50592e6517b1.tar.bz2
master - Fixed Bug 385404 - [1.7][compiler] invokeExact is notrefs/changes/89/6889/1
translated correctly if the arguments is an array of Object Change-Id: I199e5e37848b04ad31052e9386f369e358720dec
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java22
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java4
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 ce967fa..84371b5 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
@@ -997,7 +997,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;
}