7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test InlineMatcherTest
26 * @bug 8074095
27 * @modules java.base/jdk.internal.misc
28 * @library /testlibrary /test/lib
29 * @build sun.hotspot.WhiteBox
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
31 * sun.hotspot.WhiteBox$WhiteBoxPermission
32 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI InlineMatcherTest
33 * @summary Testing of compiler/InlineMatcher
34 */
35
36 import java.lang.reflect.Method;
37 import java.util.ArrayList;
38 import sun.hotspot.WhiteBox;
39
40 public class InlineMatcherTest {
41
42 /** Instance of WhiteBox */
43 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
44
45 Method helper;
46 Method getDate;
47 Method inner;
48 Method toString;
49
50 final public static int FORCE_INLINE = 2;
51 final public static int DONT_INLINE = 1;
52 final public static int NO_MATCH = 0;
53 final public static int PARSING_FAILURE = -1;
54
55 public InlineMatcherTest() {
56
57 }
58
59 public void test() throws Exception {
60 // instantiate before calling getMethod on innerHelper
61 TestCases testCases = new TestCases();
62
63 helper = getMethod(InlineMatcherTest.class, "helper");
64
65 testCases.add(helper, "*.*", PARSING_FAILURE);
66 testCases.add(helper, "+*.*", FORCE_INLINE);
67 testCases.add(helper, "++*.*", NO_MATCH); // + is a valid part of the
68 // class name
69 testCases.add(helper, "-*.*", DONT_INLINE);
70 testCases.add(helper, "--*.*", NO_MATCH); // - is a valid part of the
71 // class name
72
73 testCases.add(helper, "+InlineMatcherTest.*", FORCE_INLINE);
74 testCases.add(helper, "+InlineMatcherTest.helper", FORCE_INLINE);
75 testCases.add(helper, "+InlineMatcherTest.helper()", FORCE_INLINE);
76 testCases.add(helper, "+InlineMatcherTest.helper()V", FORCE_INLINE);
77 testCases.add(helper, "+InlineMatcherTest.helper(", FORCE_INLINE);
78
79 testCases.add(helper, "-InlineMatcherTest.*", DONT_INLINE);
80 testCases.add(helper, "-InlineMatcherTest.helper", DONT_INLINE);
81 testCases.add(helper, "-InlineMatcherTest.helper()", DONT_INLINE);
82 testCases.add(helper, "-InlineMatcherTest.helper()V", DONT_INLINE);
83 testCases.add(helper, "-InlineMatcherTest.helper(", DONT_INLINE);
84
85 testCases.add(helper, "+abc.*", NO_MATCH);
86 testCases.add(helper, "+*.abc", NO_MATCH);
87 testCases.add(helper, "-abc.*", NO_MATCH);
88 testCases.add(helper, "-*.abcls ", NO_MATCH);
89
90 int failures = 0;
91
92 for (TestCase t : testCases) {
93 System.out.println("Test case: " + t.pattern);
94 if (!t.test()) {
95 failures++;
96 System.out.println(" * FAILED");
97 }
98 }
99 if (failures != 0) {
100 throw new Exception("There where " + failures + " failures in this test");
101 }
102 }
103
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test InlineMatcherTest
26 * @bug 8074095
27 * @summary Testing of compiler/InlineMatcher
28 * @modules java.base/jdk.internal.misc
29 * @library /testlibrary /test/lib
30 *
31 * @build compiler.compilercontrol.InlineMatcherTest
32 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
33 * sun.hotspot.WhiteBox$WhiteBoxPermission
34 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35 * compiler.compilercontrol.InlineMatcherTest
36 */
37
38 package compiler.compilercontrol;
39
40 import sun.hotspot.WhiteBox;
41
42 import java.lang.reflect.Method;
43 import java.util.ArrayList;
44
45 public class InlineMatcherTest {
46
47 /** Instance of WhiteBox */
48 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
49
50 Method helper;
51 Method getDate;
52 Method inner;
53 Method toString;
54
55 final public static int FORCE_INLINE = 2;
56 final public static int DONT_INLINE = 1;
57 final public static int NO_MATCH = 0;
58 final public static int PARSING_FAILURE = -1;
59
60 public InlineMatcherTest() {
61
62 }
63
64 public void test() throws Exception {
65 // instantiate before calling getMethod on innerHelper
66 TestCases testCases = new TestCases();
67
68 helper = getMethod(InlineMatcherTest.class, "helper");
69
70 testCases.add(helper, "*.*", PARSING_FAILURE);
71 testCases.add(helper, "+*.*", FORCE_INLINE);
72 testCases.add(helper, "++*.*", NO_MATCH); // + is a valid part of the
73 // class name
74 testCases.add(helper, "-*.*", DONT_INLINE);
75 testCases.add(helper, "--*.*", NO_MATCH); // - is a valid part of the
76 // class name
77
78 String className = this.getClass().getName().replace('.', '/');
79 testCases.add(helper, "+" + className + ".*", FORCE_INLINE);
80 testCases.add(helper, "+" + className + ".helper", FORCE_INLINE);
81 testCases.add(helper, "+" + className + ".helper()", FORCE_INLINE);
82 testCases.add(helper, "+" + className + ".helper()V", FORCE_INLINE);
83 testCases.add(helper, "+" + className + ".helper(", FORCE_INLINE);
84
85 testCases.add(helper, "-" + className + ".*", DONT_INLINE);
86 testCases.add(helper, "-" + className + ".helper", DONT_INLINE);
87 testCases.add(helper, "-" + className + ".helper()", DONT_INLINE);
88 testCases.add(helper, "-" + className + ".helper()V", DONT_INLINE);
89 testCases.add(helper, "-" + className + ".helper(", DONT_INLINE);
90
91 testCases.add(helper, "+abc.*", NO_MATCH);
92 testCases.add(helper, "+*.abc", NO_MATCH);
93 testCases.add(helper, "-abc.*", NO_MATCH);
94 testCases.add(helper, "-*.abcls ", NO_MATCH);
95
96 int failures = 0;
97
98 for (TestCase t : testCases) {
99 System.out.println("Test case: " + t.pattern);
100 if (!t.test()) {
101 failures++;
102 System.out.println(" * FAILED");
103 }
104 }
105 if (failures != 0) {
106 throw new Exception("There where " + failures + " failures in this test");
107 }
108 }
109
|