annotate test/compiler/whitebox/CompilerWhiteBoxTest.java @ 12026:11237ee74aae

8019915: whitebox testClearMethodStateTest fails with tiered on sparc Summary: 'compileonly' directive has beens added to each 'compiler/whitebox' test Reviewed-by: kvn
author iignatyev
date Sat, 10 Aug 2013 10:01:12 +0400
parents d1c9384eecb4
children f99558245e5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
1 /*
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
4 *
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
7 * published by the Free Software Foundation.
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
8 *
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
13 * accompanied this code).
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
14 *
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
18 *
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
21 * questions.
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
22 */
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
23
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
24 import com.sun.management.HotSpotDiagnosticMXBean;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
25 import com.sun.management.VMOption;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
26 import sun.hotspot.WhiteBox;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
27 import sun.management.ManagementFactoryHelper;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
28
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
29 import java.lang.reflect.Constructor;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
30 import java.lang.reflect.Executable;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
31 import java.lang.reflect.Method;
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
32 import java.util.Objects;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
33 import java.util.concurrent.Callable;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
34
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
35 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
36 * Abstract class for WhiteBox testing of JIT.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
37 *
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
38 * @author igor.ignatyev@oracle.com
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
39 */
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
40 public abstract class CompilerWhiteBoxTest {
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
41 /** {@code CompLevel::CompLevel_none} -- Interpreter */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
42 protected static int COMP_LEVEL_NONE = 0;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
43 /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
44 protected static int COMP_LEVEL_ANY = -1;
10200
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
45 /** {@code CompLevel::CompLevel_simple} -- C1 */
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
46 protected static int COMP_LEVEL_SIMPLE = 1;
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
47 /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
48 protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
49
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
50 /** Instance of WhiteBox */
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
51 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
52 /** Value of {@code -XX:CompileThreshold} */
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
53 protected static final int COMPILE_THRESHOLD
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
54 = Integer.parseInt(getVMOption("CompileThreshold", "10000"));
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
55 /** Value of {@code -XX:BackgroundCompilation} */
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
56 protected static final boolean BACKGROUND_COMPILATION
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
57 = Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
58 /** Value of {@code -XX:TieredCompilation} */
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
59 protected static final boolean TIERED_COMPILATION
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
60 = Boolean.valueOf(getVMOption("TieredCompilation", "false"));
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
61 /** Value of {@code -XX:TieredStopAtLevel} */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
62 protected static final int TIERED_STOP_AT_LEVEL
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
63 = Integer.parseInt(getVMOption("TieredStopAtLevel", "0"));
12026
11237ee74aae 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents: 10200
diff changeset
64 /** Flag for verbose output, true if {@code -Dverbose} specified */
11237ee74aae 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents: 10200
diff changeset
65 protected static final boolean IS_VERBOSE
11237ee74aae 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents: 10200
diff changeset
66 = System.getProperty("verbose") != null;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
67
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
68 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
69 * Returns value of VM option.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
70 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
71 * @param name option's name
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
72 * @return value of option or {@code null}, if option doesn't exist
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
73 * @throws NullPointerException if name is null
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
74 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
75 protected static String getVMOption(String name) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
76 Objects.requireNonNull(name);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
77 HotSpotDiagnosticMXBean diagnostic
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
78 = ManagementFactoryHelper.getDiagnosticMXBean();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
79 VMOption tmp;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
80 try {
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
81 tmp = diagnostic.getVMOption(name);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
82 } catch (IllegalArgumentException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
83 tmp = null;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
84 }
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
85 return (tmp == null ? null : tmp.getValue());
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
86 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
87
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
88 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
89 * Returns value of VM option or default value.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
90 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
91 * @param name option's name
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
92 * @param defaultValue default value
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
93 * @return value of option or {@code defaultValue}, if option doesn't exist
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
94 * @throws NullPointerException if name is null
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
95 * @see #getVMOption(String)
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
96 */
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
97 protected static String getVMOption(String name, String defaultValue) {
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
98 String result = getVMOption(name);
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
99 return result == null ? defaultValue : result;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
100 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
101
10200
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
102 /** copy of is_c1_compile(int) from utilities/globalDefinitions.hpp */
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
103 protected static boolean isC1Compile(int compLevel) {
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
104 return (compLevel > COMP_LEVEL_NONE)
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
105 && (compLevel < COMP_LEVEL_FULL_OPTIMIZATION);
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
106 }
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
107
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
108 /** copy of is_c2_compile(int) from utilities/globalDefinitions.hpp */
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
109 protected static boolean isC2Compile(int compLevel) {
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
110 return compLevel == COMP_LEVEL_FULL_OPTIMIZATION;
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
111 }
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
112
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
113 /** tested method */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
114 protected final Executable method;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
115 private final Callable<Integer> callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
116
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
117 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
118 * Constructor.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
119 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
120 * @param testCase object, that contains tested method and way to invoke it.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
121 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
122 protected CompilerWhiteBoxTest(TestCase testCase) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
123 Objects.requireNonNull(testCase);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
124 System.out.println("TEST CASE:" + testCase.name());
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
125 method = testCase.executable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
126 callable = testCase.callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
127 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
128
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
129 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
130 * Template method for testing. Prints tested method's info before
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
131 * {@linkplain #test()} and after {@linkplain #test()} or on thrown
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
132 * exception.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
133 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
134 * @throws RuntimeException if method {@linkplain #test()} throws any
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
135 * exception
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
136 * @see #test()
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
137 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
138 protected final void runTest() {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
139 if (ManagementFactoryHelper.getCompilationMXBean() == null) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
140 System.err.println(
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
141 "Warning: test is not applicable in interpreted mode");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
142 return;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
143 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
144 System.out.println("at test's start:");
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
145 printInfo();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
146 try {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
147 test();
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
148 } catch (Exception e) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
149 System.out.printf("on exception '%s':", e.getMessage());
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
150 printInfo();
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
151 e.printStackTrace();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
152 if (e instanceof RuntimeException) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
153 throw (RuntimeException) e;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
154 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
155 throw new RuntimeException(e);
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
156 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
157 System.out.println("at test's end:");
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
158 printInfo();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
159 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
160
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
161 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
162 * Checks, that {@linkplain #method} is not compiled.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
163 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
164 * @throws RuntimeException if {@linkplain #method} is in compiler queue or
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
165 * is compiled, or if {@linkplain #method} has zero
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
166 * compilation level.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
167 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
168 protected final void checkNotCompiled() {
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
169 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
170 throw new RuntimeException(method + " must not be in queue");
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
171 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
172 if (WHITE_BOX.isMethodCompiled(method)) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
173 throw new RuntimeException(method + " must be not compiled");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
174 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
175 if (WHITE_BOX.getMethodCompilationLevel(method) != 0) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
176 throw new RuntimeException(method + " comp_level must be == 0");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
177 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
178 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
179
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
180 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
181 * Checks, that {@linkplain #method} is compiled.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
182 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
183 * @throws RuntimeException if {@linkplain #method} isn't in compiler queue
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
184 * and isn't compiled, or if {@linkplain #method}
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
185 * has nonzero compilation level
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
186 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
187 protected final void checkCompiled() {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
188 final long start = System.currentTimeMillis();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
189 waitBackgroundCompilation();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
190 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
191 System.err.printf("Warning: %s is still in queue after %dms%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
192 method, System.currentTimeMillis() - start);
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
193 return;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
194 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
195 if (!WHITE_BOX.isMethodCompiled(method)) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
196 throw new RuntimeException(method + " must be compiled");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
197 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
198 if (WHITE_BOX.getMethodCompilationLevel(method) == 0) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
199 throw new RuntimeException(method + " comp_level must be != 0");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
200 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
201 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
202
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
203 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
204 * Waits for completion of background compilation of {@linkplain #method}.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
205 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
206 protected final void waitBackgroundCompilation() {
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
207 if (!BACKGROUND_COMPILATION) {
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
208 return;
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
209 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
210 final Object obj = new Object();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
211 for (int i = 0; i < 10
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
212 && WHITE_BOX.isMethodQueuedForCompilation(method); ++i) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
213 synchronized (obj) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
214 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
215 obj.wait(1000);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
216 } catch (InterruptedException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
217 Thread.currentThread().interrupt();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
218 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
219 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
220 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
221 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
222
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
223 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
224 * Prints information about {@linkplain #method}.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
225 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
226 protected final void printInfo() {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
227 System.out.printf("%n%s:%n", method);
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
228 System.out.printf("\tcompilable:\t%b%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
229 WHITE_BOX.isMethodCompilable(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
230 System.out.printf("\tcompiled:\t%b%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
231 WHITE_BOX.isMethodCompiled(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
232 System.out.printf("\tcomp_level:\t%d%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
233 WHITE_BOX.getMethodCompilationLevel(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
234 System.out.printf("\tin_queue:\t%b%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
235 WHITE_BOX.isMethodQueuedForCompilation(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
236 System.out.printf("compile_queues_size:\t%d%n%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
237 WHITE_BOX.getCompileQueuesSize());
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
238 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
239
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
240 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
241 * Executes testing.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
242 */
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
243 protected abstract void test() throws Exception;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
244
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
245 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
246 * Tries to trigger compilation of {@linkplain #method} by call
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
247 * {@linkplain #callable} enough times.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
248 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
249 * @return accumulated result
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
250 * @see #compile(int)
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
251 */
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
252 protected final int compile() {
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
253 return compile(Math.max(COMPILE_THRESHOLD, 150000));
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
254 }
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
255
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
256 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
257 * Tries to trigger compilation of {@linkplain #method} by call
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
258 * {@linkplain #callable} specified times.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
259 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
260 * @param count invocation count
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
261 * @return accumulated result
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
262 */
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
263 protected final int compile(int count) {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
264 int result = 0;
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
265 Integer tmp;
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
266 for (int i = 0; i < count; ++i) {
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
267 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
268 tmp = callable.call();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
269 } catch (Exception e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
270 tmp = null;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
271 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
272 result += tmp == null ? 0 : tmp;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
273 }
12026
11237ee74aae 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents: 10200
diff changeset
274 if (IS_VERBOSE) {
11237ee74aae 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents: 10200
diff changeset
275 System.out.println("method was invoked " + count + " times");
11237ee74aae 8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents: 10200
diff changeset
276 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
277 return result;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
278 }
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
279 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
280
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
281 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
282 * Utility structure containing tested method and object to invoke it.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
283 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
284 enum TestCase {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
285 /** constructor test case */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
286 CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE),
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
287 /** method test case */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
288 METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE),
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
289 /** static method test case */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
290 STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
291
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
292 /** tested method */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
293 final Executable executable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
294 /** object to invoke {@linkplain #executable} */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
295 final Callable<Integer> callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
296
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
297 private TestCase(Executable executable, Callable<Integer> callable) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
298 this.executable = executable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
299 this.callable = callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
300 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
301
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
302 private static class Helper {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
303 private static final Callable<Integer> CONSTRUCTOR_CALLABLE
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
304 = new Callable<Integer>() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
305 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
306 public Integer call() throws Exception {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
307 return new Helper(1337).hashCode();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
308 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
309 };
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
310
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
311 private static final Callable<Integer> METHOD_CALLABLE
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
312 = new Callable<Integer>() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
313 private final Helper helper = new Helper();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
314
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
315 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
316 public Integer call() throws Exception {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
317 return helper.method();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
318 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
319 };
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
320
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
321 private static final Callable<Integer> STATIC_CALLABLE
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
322 = new Callable<Integer>() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
323 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
324 public Integer call() throws Exception {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
325 return staticMethod();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
326 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
327 };
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
328
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
329 private static final Constructor CONSTRUCTOR;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
330 private static final Method METHOD;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
331 private static final Method STATIC;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
332
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
333 static {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
334 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
335 CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
336 } catch (NoSuchMethodException | SecurityException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
337 throw new RuntimeException(
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
338 "exception on getting method Helper.<init>(int)", e);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
339 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
340 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
341 METHOD = Helper.class.getDeclaredMethod("method");
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
342 } catch (NoSuchMethodException | SecurityException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
343 throw new RuntimeException(
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
344 "exception on getting method Helper.method()", e);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
345 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
346 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
347 STATIC = Helper.class.getDeclaredMethod("staticMethod");
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
348 } catch (NoSuchMethodException | SecurityException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
349 throw new RuntimeException(
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
350 "exception on getting method Helper.staticMethod()", e);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
351 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
352 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
353
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
354 private static int staticMethod() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
355 return 1138;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
356 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
357
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
358 private int method() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
359 return 42;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
360 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
361
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
362 private final int x;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
363
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
364 public Helper() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
365 x = 0;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
366 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
367
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
368 private Helper(int x) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
369 this.x = x;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
370 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
371
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
372 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
373 public int hashCode() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
374 return x;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
375 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
376 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
377 }