Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6857159.java
41149 views
1
/*
2
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/**
25
* @test
26
* @bug 6857159
27
* @summary local schedule failed with checkcast of Thread.currentThread()
28
* @library /test/lib
29
* @modules java.base/jdk.internal.misc
30
*
31
* @build sun.hotspot.WhiteBox
32
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
33
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
34
* -Xbatch -XX:CompileCommand=compileonly,compiler.c2.Test6857159$ct0::run
35
* compiler.c2.Test6857159
36
*/
37
38
package compiler.c2;
39
40
import sun.hotspot.WhiteBox;
41
42
public class Test6857159 extends Thread {
43
public static void main(String[] args) throws Exception {
44
var whiteBox = WhiteBox.getWhiteBox();
45
var method = ct0.class.getDeclaredMethod("run");
46
for (int i = 0; i < 20000; i++) {
47
Thread t = null;
48
switch (i % 3) {
49
case 0:
50
t = new ct0();
51
break;
52
case 1:
53
t = new ct1();
54
break;
55
case 2:
56
t = new ct2();
57
break;
58
}
59
t.start();
60
t.join();
61
}
62
if (!whiteBox.isMethodCompiled(method)) {
63
throw new AssertionError(method + " didn't get compiled");
64
}
65
}
66
67
static class ct0 extends Test6857159 {
68
public void message() { }
69
70
public void run() {
71
message();
72
ct0 ct = (ct0) Thread.currentThread();
73
ct.message();
74
}
75
}
76
77
static class ct1 extends ct0 {
78
public void message() { }
79
}
80
81
static class ct2 extends ct0 {
82
public void message() { }
83
}
84
}
85
86