author | michaelm |
Thu, 25 Feb 2016 23:14:22 +0000 | |
changeset 36131 | 379db4b2f95d |
parent 35858 | 6e704583a38f |
child 37078 | dc9ee85e80d3 |
permissions | -rw-r--r-- |
35456
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
1 |
/* |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
4 |
* |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
8 |
* |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
13 |
* accompanied this code). |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
14 |
* |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
18 |
* |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
21 |
* questions. |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
22 |
*/ |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
23 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
24 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
25 |
/* |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
26 |
* @test ClassResolutionTest |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
27 |
* @bug 8144874 |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
28 |
* @library /testlibrary |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
29 |
* @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
30 |
* @run driver ClassResolutionTest |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
31 |
*/ |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
32 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
33 |
import jdk.test.lib.OutputAnalyzer; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
34 |
import jdk.test.lib.ProcessTools; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
35 |
import java.lang.ref.WeakReference; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
36 |
import java.lang.reflect.Method; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
37 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
38 |
public class ClassResolutionTest { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
39 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
40 |
public static class ClassResolutionTestMain { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
41 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
42 |
public static class Thing1 { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
43 |
public static int getThingNumber() { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
44 |
return 1; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
45 |
} |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
46 |
}; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
47 |
public static class Thing1Handler { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
48 |
public static int getThingNumber() { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
49 |
return Thing1.getThingNumber(); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
50 |
} |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
51 |
}; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
52 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
53 |
public static void main(String... args) throws Exception { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
54 |
Thing1Handler.getThingNumber(); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
55 |
} |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
56 |
} |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
57 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
58 |
public static void main(String... args) throws Exception { |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
59 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
60 |
// (1) classresolve should turn on. |
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
61 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=info", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
62 |
ClassResolutionTestMain.class.getName()); |
35456
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
63 |
OutputAnalyzer o = new OutputAnalyzer(pb.start()); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
64 |
o.shouldContain("[classresolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
65 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
66 |
// (2) classresolve should turn off. |
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
67 |
pb = ProcessTools.createJavaProcessBuilder("-Xlog", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
68 |
"-Xlog:classresolve=off", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
69 |
ClassResolutionTestMain.class.getName()); |
35456
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
70 |
o = new OutputAnalyzer(pb.start()); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
71 |
o.shouldNotContain("[classresolve]"); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
72 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
73 |
// (3) TraceClassResolution should turn on. |
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
74 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceClassResolution", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
75 |
ClassResolutionTestMain.class.getName()); |
35456
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
76 |
o = new OutputAnalyzer(pb.start()); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
77 |
o.shouldContain("[classresolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
78 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
79 |
// (4) TraceClassResolution should turn off. |
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
80 |
pb = ProcessTools.createJavaProcessBuilder("-Xlog", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
81 |
"-XX:-TraceClassResolution", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35456
diff
changeset
|
82 |
ClassResolutionTestMain.class.getName()); |
35456
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
83 |
o = new OutputAnalyzer(pb.start()); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
84 |
o.shouldNotContain("[classresolve]"); |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
85 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
86 |
|
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
87 |
}; |
6dce879deda9
8146485: Add test for Unified Logging classresolve tag.
mockner
parents:
diff
changeset
|
88 |
} |