annotate test/compiler/whitebox/CompilerWhiteBoxTest.java @ 10200:d1c9384eecb4

8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false Reviewed-by: kvn, vlivanov
author iignatyev
date Fri, 26 Apr 2013 07:21:41 -0700
parents 4b2eebe03f93
children 11237ee74aae
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"));
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
64
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
65 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
66 * Returns value of VM option.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
67 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
68 * @param name option's name
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
69 * @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
70 * @throws NullPointerException if name is null
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
71 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
72 protected static String getVMOption(String name) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
73 Objects.requireNonNull(name);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
74 HotSpotDiagnosticMXBean diagnostic
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
75 = ManagementFactoryHelper.getDiagnosticMXBean();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
76 VMOption tmp;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
77 try {
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
78 tmp = diagnostic.getVMOption(name);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
79 } catch (IllegalArgumentException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
80 tmp = null;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
81 }
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
82 return (tmp == null ? null : tmp.getValue());
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
83 }
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 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
86 * Returns value of VM option or default value.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
87 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
88 * @param name option's name
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
89 * @param defaultValue default value
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
90 * @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
91 * @throws NullPointerException if name is null
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
92 * @see #getVMOption(String)
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
93 */
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
94 protected static String getVMOption(String name, String defaultValue) {
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
95 String result = getVMOption(name);
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
96 return result == null ? defaultValue : result;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
97 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
98
10200
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
99 /** 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
100 protected static boolean isC1Compile(int compLevel) {
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
101 return (compLevel > COMP_LEVEL_NONE)
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
102 && (compLevel < COMP_LEVEL_FULL_OPTIMIZATION);
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
103 }
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
104
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
105 /** 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
106 protected static boolean isC2Compile(int compLevel) {
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
107 return compLevel == COMP_LEVEL_FULL_OPTIMIZATION;
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
108 }
d1c9384eecb4 8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents: 10113
diff changeset
109
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
110 /** tested method */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
111 protected final Executable method;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
112 private final Callable<Integer> callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
114 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
115 * Constructor.
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 * @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
118 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
119 protected CompilerWhiteBoxTest(TestCase testCase) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
120 Objects.requireNonNull(testCase);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
121 System.out.println("TEST CASE:" + testCase.name());
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
122 method = testCase.executable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
123 callable = testCase.callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
124 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
125
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
126 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
127 * 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
128 * {@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
129 * exception.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
130 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
131 * @throws RuntimeException if method {@linkplain #test()} throws any
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 * @see #test()
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
134 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
135 protected final void runTest() {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
136 if (ManagementFactoryHelper.getCompilationMXBean() == null) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
137 System.err.println(
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
138 "Warning: test is not applicable in interpreted mode");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
139 return;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
140 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
141 System.out.println("at test's start:");
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
142 printInfo();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
143 try {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
144 test();
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
145 } catch (Exception e) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
146 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
147 printInfo();
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
148 e.printStackTrace();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
149 if (e instanceof RuntimeException) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
150 throw (RuntimeException) e;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
151 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
152 throw new RuntimeException(e);
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
153 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
154 System.out.println("at test's end:");
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
155 printInfo();
8051
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
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
158 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
159 * Checks, that {@linkplain #method} is not compiled.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
160 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
161 * @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
162 * is compiled, or if {@linkplain #method} has zero
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
163 * compilation level.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
164 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
165 protected final void checkNotCompiled() {
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
166 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
167 throw new RuntimeException(method + " must not be in queue");
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
168 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
169 if (WHITE_BOX.isMethodCompiled(method)) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
170 throw new RuntimeException(method + " must be not compiled");
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
171 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
172 if (WHITE_BOX.getMethodCompilationLevel(method) != 0) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
173 throw new RuntimeException(method + " comp_level must be == 0");
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 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
176
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
177 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
178 * Checks, that {@linkplain #method} is compiled.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
179 *
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
180 * @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
181 * and isn't compiled, or if {@linkplain #method}
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
182 * has nonzero compilation level
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
183 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
184 protected final void checkCompiled() {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
185 final long start = System.currentTimeMillis();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
186 waitBackgroundCompilation();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
187 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
188 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
189 method, System.currentTimeMillis() - start);
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
190 return;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
191 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
192 if (!WHITE_BOX.isMethodCompiled(method)) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
193 throw new RuntimeException(method + " must be compiled");
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.getMethodCompilationLevel(method) == 0) {
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
196 throw new RuntimeException(method + " comp_level must be != 0");
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 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
199
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
200 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
201 * 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
202 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
203 protected final void waitBackgroundCompilation() {
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
204 if (!BACKGROUND_COMPILATION) {
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
205 return;
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
206 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
207 final Object obj = new Object();
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
208 for (int i = 0; i < 10
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
209 && WHITE_BOX.isMethodQueuedForCompilation(method); ++i) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
210 synchronized (obj) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
211 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
212 obj.wait(1000);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
213 } catch (InterruptedException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
214 Thread.currentThread().interrupt();
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
215 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
216 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
217 }
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
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
220 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
221 * Prints information about {@linkplain #method}.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
222 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
223 protected final void printInfo() {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
224 System.out.printf("%n%s:%n", method);
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
225 System.out.printf("\tcompilable:\t%b%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
226 WHITE_BOX.isMethodCompilable(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
227 System.out.printf("\tcompiled:\t%b%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
228 WHITE_BOX.isMethodCompiled(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
229 System.out.printf("\tcomp_level:\t%d%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
230 WHITE_BOX.getMethodCompilationLevel(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
231 System.out.printf("\tin_queue:\t%b%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
232 WHITE_BOX.isMethodQueuedForCompilation(method));
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
233 System.out.printf("compile_queues_size:\t%d%n%n",
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
234 WHITE_BOX.getCompileQueuesSize());
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
235 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
236
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
237 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
238 * Executes testing.
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
239 */
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
240 protected abstract void test() throws Exception;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
241
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
242 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
243 * 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
244 * {@linkplain #callable} enough times.
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 * @return accumulated result
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
247 * @see #compile(int)
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
248 */
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
249 protected final int compile() {
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
250 return compile(Math.max(COMPILE_THRESHOLD, 150000));
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
251 }
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
252
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
253 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
254 * 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
255 * {@linkplain #callable} specified times.
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 * @param count invocation count
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
258 * @return accumulated result
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
259 */
9080
b84fd7d73702 8007288: Additional WB API for compiler's testing
iignatyev
parents: 8766
diff changeset
260 protected final int compile(int count) {
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
261 int result = 0;
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
262 Integer tmp;
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
263 for (int i = 0; i < count; ++i) {
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
264 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
265 tmp = callable.call();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
266 } catch (Exception e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
267 tmp = null;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
268 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
269 result += tmp == null ? 0 : tmp;
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
270 }
8766
4efac99a998b 8008211: Some of WB tests on compiler fail
iignatyev
parents: 8051
diff changeset
271 System.out.println("method was invoked " + count + " times");
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
272 return result;
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
273 }
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
274 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
275
10113
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
276 /**
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
277 * 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
278 */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
279 enum TestCase {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
280 /** constructor test case */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
281 CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE),
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
282 /** method test case */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
283 METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE),
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
284 /** static method test case */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
285 STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
286
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
287 /** tested method */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
288 final Executable executable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
289 /** object to invoke {@linkplain #executable} */
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
290 final Callable<Integer> 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 private TestCase(Executable executable, Callable<Integer> callable) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
293 this.executable = executable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
294 this.callable = callable;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
295 }
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 static class Helper {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
298 private static final Callable<Integer> CONSTRUCTOR_CALLABLE
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
299 = new Callable<Integer>() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
300 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
301 public Integer call() throws Exception {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
302 return new Helper(1337).hashCode();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
303 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
304 };
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
305
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
306 private static final Callable<Integer> METHOD_CALLABLE
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
307 = new Callable<Integer>() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
308 private final Helper helper = new Helper();
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 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
311 public Integer call() throws Exception {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
312 return helper.method();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
313 }
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
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
316 private static final Callable<Integer> STATIC_CALLABLE
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
317 = new Callable<Integer>() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
318 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
319 public Integer call() throws Exception {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
320 return staticMethod();
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
321 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
322 };
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
323
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
324 private static final Constructor CONSTRUCTOR;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
325 private static final Method METHOD;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
326 private static final Method STATIC;
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 static {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
329 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
330 CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
331 } catch (NoSuchMethodException | SecurityException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
332 throw new RuntimeException(
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
333 "exception on getting method Helper.<init>(int)", e);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
334 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
335 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
336 METHOD = Helper.class.getDeclaredMethod("method");
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
337 } catch (NoSuchMethodException | SecurityException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
338 throw new RuntimeException(
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
339 "exception on getting method Helper.method()", e);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
340 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
341 try {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
342 STATIC = Helper.class.getDeclaredMethod("staticMethod");
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
343 } catch (NoSuchMethodException | SecurityException e) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
344 throw new RuntimeException(
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
345 "exception on getting method Helper.staticMethod()", e);
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
346 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
347 }
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
348
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
349 private static int staticMethod() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
350 return 1138;
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 private int method() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
354 return 42;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
355 }
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 private final int x;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
358
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
359 public Helper() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
360 x = 0;
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
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
363 private Helper(int x) {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
364 this.x = x;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
365 }
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 @Override
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
368 public int hashCode() {
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
369 return x;
4b2eebe03f93 8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents: 9080
diff changeset
370 }
8051
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
371 }
12e01444ca2d 8006683: Add WhiteBox API to testing of compiler
iignatyev
parents:
diff changeset
372 }