--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jsr292/InvokerSignatureMismatch.java Thu Feb 09 19:00:48 2017 +0300
@@ -0,0 +1,58 @@
+package compiler.jsr292;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.MethodHandleHelper;
+import jdk.internal.vm.annotation.ForceInline;
+
+/*
+ * @test
+ * @bug 8166110
+ * @library /test/lib / patches
+ * @modules java.base/jdk.internal.misc
+ * java.base/jdk.internal.vm.annotation
+ *
+ * @build java.base/java.lang.invoke.MethodHandleHelper
+ * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:-TieredCompilation
+ * compiler.jsr292.InvokerSignatureMismatch
+ */
+public class InvokerSignatureMismatch {
+
+ static final MethodHandle INT_MH;
+
+ static {
+ MethodHandle mhI = null;
+ try {
+ mhI = MethodHandles.lookup().findStatic(InvokerSignatureMismatch.class, "bodyI", MethodType.methodType(void.class, int.class));
+ } catch (Throwable e) {
+ }
+ INT_MH = mhI;
+ }
+
+ public static void main(String[] args) throws Throwable {
+ mainLink();
+ mainInvoke();
+ }
+
+ static void mainLink() throws Throwable {
+ for (int i = 0; i < 50_000; i++) { // OSR
+ Object name = MethodHandleHelper.internalMemberName(INT_MH);
+ MethodHandleHelper.linkToStatic(INT_MH, (float) i, name);
+ }
+ }
+
+ static void mainInvoke() throws Throwable {
+ for (int i = 0; i < 50_000; i++) { // OSR
+ MethodHandleHelper.invokeBasicV(INT_MH, (float) i);
+ }
+ }
+
+ static int cnt = 0;
+ static void bodyI(int x) {
+ if ((x & 1023) == 0) { // already optimized x % 1024 == 0
+ ++cnt;
+ }
+ }
+
+}