1package compiler.profiling.spectrapredefineclass_classloaders;
2
3import java.lang.reflect.Method;
4
5public class Test {
6
7    public boolean m1(A a, Boolean early_return) {
8        if (early_return.booleanValue()) return true;
9        boolean res =  m2(a);
10        return res;
11    }
12
13    public boolean m2(A a) {
14        boolean res = false;
15        if (a.getClass() == B.class) {
16            a.m();
17        } else {
18            res = true;
19        }
20        return res;
21    }
22
23    public void m3(ClassLoader loader) throws Exception {
24        String packageName = Test.class.getPackage().getName();
25        Class Test_class = loader.loadClass(packageName + ".Test");
26        Object test = Test_class.newInstance();
27        Class A_class = loader.loadClass(packageName + ".A");
28        Object a = A_class.newInstance();
29        Class B_class = loader.loadClass(packageName + ".B");
30        Object b = B_class.newInstance();
31        Method m1 = Test_class.getMethod("m1", A_class, Boolean.class);
32
33        // So we don't hit uncommon trap in the next loop
34        for (int i = 0; i < 4000; i++) {
35            m4(m1, test, a, Boolean.TRUE);
36            m4(m1, test, b, Boolean.TRUE);
37        }
38        for (int i = 0; i < 20000; i++) {
39            m4(m1, test, a, Boolean.FALSE);
40        }
41        for (int i = 0; i < 4; i++) {
42            m4(m1, test, b, Boolean.FALSE);
43        }
44    }
45
46    public Object m4(Method m, Object test, Object a, Object early_return) throws Exception {
47        return m.invoke(test, a, early_return);
48    }
49
50    static public A a = new A();
51    static public B b = new B();
52}
53
54