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