8145800: [Testbug] CompilerControl: inline message differs for not inlined methods
authorppunegov
Wed, 20 Jan 2016 20:26:33 +0300
changeset 35587 173b2da63cc3
parent 35580 1225225bd34e
child 35588 5d373c2c7c47
8145800: [Testbug] CompilerControl: inline message differs for not inlined methods Summary: Create callables outside the Internal subclasses Reviewed-by: kvn
hotspot/test/compiler/compilercontrol/share/pool/SubMethodHolder.java
hotspot/test/compiler/compilercontrol/share/pool/sub/Klass.java
hotspot/test/compiler/compilercontrol/share/pool/subpack/KlassDup.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/compilercontrol/share/pool/SubMethodHolder.java	Wed Jan 20 20:26:33 2016 +0300
@@ -0,0 +1,49 @@
+package pool;
+
+import jdk.test.lib.Pair;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+/**
+ * A helper class that creates executables and callables for internal classes
+ * It's necessary to have this class to make all helper lambdas not contain
+ * any of class names that could be used as a pattern (Internal*, *Klass*)
+ */
+public abstract class SubMethodHolder extends MethodHolder {
+    @Override
+    public List<Pair<Executable, Callable<?>>> getAllMethods() {
+        List<Pair<Executable, Callable<?>>> pairs = new ArrayList<>();
+        {
+            Method method = getMethod(this, "method", Float.class);
+            Pair<Executable, Callable<?>> pair = new Pair<>(method,
+                    () -> method.invoke(this, 3.141592f));
+            pairs.add(pair);
+        }
+        {
+            Method method = getMethod(this, "methodDup");
+            Pair<Executable, Callable<?>> pair = new Pair<>(method,
+                    () -> method.invoke(this));
+            pairs.add(pair);
+        }
+        {
+            Method method = getMethod(this, "smethod", Integer.class);
+            Pair<Executable, Callable<?>> pair = new Pair<>(method,
+                    () -> method.invoke(this, 1024));
+            pairs.add(pair);
+        }
+        try {
+            Constructor constructor = this.getClass().getConstructor();
+            Pair<Executable, Callable<?>> pair = new Pair<>(constructor,
+                    constructor::newInstance);
+            pairs.add(pair);
+        } catch (NoSuchMethodException e) {
+            throw new Error("TESTBUG: unable to get constructor");
+        }
+        return pairs;
+    }
+}
--- a/hotspot/test/compiler/compilercontrol/share/pool/sub/Klass.java	Mon Jan 18 17:31:14 2016 +0100
+++ b/hotspot/test/compiler/compilercontrol/share/pool/sub/Klass.java	Wed Jan 20 20:26:33 2016 +0300
@@ -23,13 +23,8 @@
 
 package pool.sub;
 
-import jdk.test.lib.Pair;
 import pool.MethodHolder;
-
-import java.lang.reflect.Executable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
+import pool.SubMethodHolder;
 
 /**
  * Simple class with methods to test signatures
@@ -53,7 +48,7 @@
     }
 
     // Internal class and constructor
-    public static class Internal extends MethodHolder {
+    public static class Internal extends SubMethodHolder {
         public Internal() { }
 
         public Double method(Float fl) { return Double.valueOf(fl); }
@@ -66,27 +61,5 @@
             Integer var = 1024;
             return arg + var;
         }
-
-        @Override
-        public List<Pair<Executable, Callable<?>>> getAllMethods() {
-            List<Pair<Executable, Callable<?>>> pairs = new ArrayList<>();
-            Pair<Executable, Callable<?>> pair = new Pair<>
-                    (getMethod(this, "method", Float.class),
-                            () -> this.method(3.141592f));
-            pairs.add(pair);
-            pair = new Pair<>(getMethod(this, "methodDup"), this::methodDup);
-            pairs.add(pair);
-            pair = new Pair<>(getMethod(this, "smethod", Integer.class),
-                    () -> smethod(1024));
-            pairs.add(pair);
-            try {
-                pair = new Pair<>(this.getClass().getConstructor(),
-                        Internal::new);
-                pairs.add(pair);
-            } catch (NoSuchMethodException e) {
-                throw new Error("TESTBUG: unable to get constructor");
-            }
-            return pairs;
-        }
     }
 }
--- a/hotspot/test/compiler/compilercontrol/share/pool/subpack/KlassDup.java	Mon Jan 18 17:31:14 2016 +0100
+++ b/hotspot/test/compiler/compilercontrol/share/pool/subpack/KlassDup.java	Wed Jan 20 20:26:33 2016 +0300
@@ -23,13 +23,8 @@
 
 package pool.subpack;
 
-import jdk.test.lib.Pair;
 import pool.MethodHolder;
-
-import java.lang.reflect.Executable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
+import pool.SubMethodHolder;
 
 /**
  * This is a clone of the pool.sub.Klass used to test pattern matching
@@ -54,7 +49,7 @@
     }
 
     // Internal class and constructor
-    public static class Internal extends MethodHolder {
+    public static class Internal extends SubMethodHolder {
         public Internal() { }
 
         public Double method(Float fl) { return Double.valueOf(fl); }
@@ -67,27 +62,5 @@
             Integer var = 1024;
             return arg + var;
         }
-
-        @Override
-        public List<Pair<Executable, Callable<?>>> getAllMethods() {
-            List<Pair<Executable, Callable<?>>> pairs = new ArrayList<>();
-            Pair<Executable, Callable<?>> pair = new Pair<>
-                    (getMethod(this, "method", Float.class),
-                            () -> this.method(3.141592f));
-            pairs.add(pair);
-            pair = new Pair<>(getMethod(this, "methodDup"), this::methodDup);
-            pairs.add(pair);
-            pair = new Pair<>(getMethod(this, "smethod", Integer.class),
-                    () -> smethod(1024));
-            pairs.add(pair);
-            try {
-                pair = new Pair<>(this.getClass().getConstructor(),
-                        Internal::new);
-                pairs.add(pair);
-            } catch (NoSuchMethodException e) {
-                throw new Error("TESTBUG: unable to get constructor");
-            }
-            return pairs;
-        }
     }
 }