Fixed Bug 385404 - [1.7][compiler] invokeExact is not translated
correctly if the arguments is an array of Object

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 @@
 		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 25fee09..00d4a73 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
  * 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
@@ -997,7 +997,11 @@
 			    }
 				// 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;
 			}