author | jiangli |
Fri, 02 Nov 2018 19:30:31 -0400 | |
changeset 52397 | 1322829d1501 |
parent 50735 | 2f2af62dfac7 |
permissions | -rw-r--r-- |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
1 |
/* |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
4 |
* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
8 |
* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
13 |
* accompanied this code). |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
14 |
* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
18 |
* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
21 |
* questions. |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
22 |
*/ |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
23 |
|
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
24 |
/* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
25 |
* @test |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38152
diff
changeset
|
26 |
* @library /test/lib |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
27 |
* @summary Proof of concept test for RedefineClassHelper |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
30604
diff
changeset
|
28 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
29 |
* @modules java.compiler |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
30 |
* java.instrument |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
31 |
* jdk.jartool/sun.tools.jar |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
32 |
* @run main RedefineClassHelper |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
33 |
* @run main/othervm -javaagent:redefineagent.jar RedefineClassTest |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
34 |
*/ |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
35 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
36 |
import static jdk.test.lib.Asserts.*; |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
37 |
|
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
38 |
/* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
39 |
* Proof of concept test for the test utility class RedefineClassHelper |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
40 |
*/ |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
41 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
42 |
// package access top-level class to avoid problem with RedefineClassHelper |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
43 |
// and nested types. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
44 |
class RedefineClassTest_A { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
45 |
public int Method() { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
46 |
return 1; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
47 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
48 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
49 |
|
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
50 |
public class RedefineClassTest { |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
51 |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
52 |
public static String newClass = "class RedefineClassTest_A { public int Method() { return 2; } }"; |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
53 |
public static void main(String[] args) throws Exception { |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
54 |
RedefineClassTest_A a = new RedefineClassTest_A(); |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
55 |
assertTrue(a.Method() == 1); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
56 |
RedefineClassHelper.redefineClass(RedefineClassTest_A.class, newClass); |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
57 |
assertTrue(a.Method() == 2); |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
58 |
} |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
59 |
} |