Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6857159.java
41149 views
/*1* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 685715926* @summary local schedule failed with checkcast of Thread.currentThread()27* @library /test/lib28* @modules java.base/jdk.internal.misc29*30* @build sun.hotspot.WhiteBox31* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox32* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI33* -Xbatch -XX:CompileCommand=compileonly,compiler.c2.Test6857159$ct0::run34* compiler.c2.Test685715935*/3637package compiler.c2;3839import sun.hotspot.WhiteBox;4041public class Test6857159 extends Thread {42public static void main(String[] args) throws Exception {43var whiteBox = WhiteBox.getWhiteBox();44var method = ct0.class.getDeclaredMethod("run");45for (int i = 0; i < 20000; i++) {46Thread t = null;47switch (i % 3) {48case 0:49t = new ct0();50break;51case 1:52t = new ct1();53break;54case 2:55t = new ct2();56break;57}58t.start();59t.join();60}61if (!whiteBox.isMethodCompiled(method)) {62throw new AssertionError(method + " didn't get compiled");63}64}6566static class ct0 extends Test6857159 {67public void message() { }6869public void run() {70message();71ct0 ct = (ct0) Thread.currentThread();72ct.message();73}74}7576static class ct1 extends ct0 {77public void message() { }78}7980static class ct2 extends ct0 {81public void message() { }82}83}848586