Path: blob/master/test/hotspot/jtreg/compiler/profiling/spectrapredefineclass_classloaders/Test.java
41155 views
package compiler.profiling.spectrapredefineclass_classloaders;12import java.lang.reflect.Method;34public class Test {56public boolean m1(A a, Boolean early_return) {7if (early_return.booleanValue()) return true;8boolean res = m2(a);9return res;10}1112public boolean m2(A a) {13boolean res = false;14if (a.getClass() == B.class) {15a.m();16} else {17res = true;18}19return res;20}2122public void m3(ClassLoader loader) throws Exception {23String packageName = Test.class.getPackage().getName();24Class Test_class = loader.loadClass(packageName + ".Test");25Object test = Test_class.newInstance();26Class A_class = loader.loadClass(packageName + ".A");27Object a = A_class.newInstance();28Class B_class = loader.loadClass(packageName + ".B");29Object b = B_class.newInstance();30Method m1 = Test_class.getMethod("m1", A_class, Boolean.class);3132// So we don't hit uncommon trap in the next loop33for (int i = 0; i < 4000; i++) {34m4(m1, test, a, Boolean.TRUE);35m4(m1, test, b, Boolean.TRUE);36}37for (int i = 0; i < 20000; i++) {38m4(m1, test, a, Boolean.FALSE);39}40for (int i = 0; i < 4; i++) {41m4(m1, test, b, Boolean.FALSE);42}43}4445public Object m4(Method m, Object test, Object a, Object early_return) throws Exception {46return m.invoke(test, a, early_return);47}4849static public A a = new A();50static public B b = new B();51}52535455