author | duke |
Wed, 05 Jul 2017 20:01:44 +0200 | |
changeset 26660 | 5e174bbfc03a |
parent 26155 | 1f15bfaa9c52 |
permissions | -rw-r--r-- |
17122
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
1 |
/* |
25958
8dc85547d6d6
8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents:
17122
diff
changeset
|
2 |
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
17122
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
4 |
* |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
8 |
* |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
14 |
* |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
18 |
* |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
22 |
*/ |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
23 |
|
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
24 |
/* |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
25 |
* @test WhiteBox |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
26 |
* @bug 8011675 |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
27 |
* @summary verify that whitebox can be used even if not all functions are declared in java-part |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
28 |
* @author igor.ignatyev@oracle.com |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
29 |
* @library /testlibrary |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
30 |
* @compile WhiteBox.java |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
31 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
32 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI sun.hotspot.WhiteBox |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
33 |
* @clean sun.hotspot.WhiteBox |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
34 |
*/ |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
35 |
|
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
36 |
package sun.hotspot; |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
37 |
|
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
38 |
public class WhiteBox { |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
39 |
private static native void registerNatives(); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
40 |
static { registerNatives(); } |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
41 |
public native int notExistedMethod(); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
42 |
public native int getHeapOopSize(); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
43 |
public static void main(String[] args) { |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
44 |
WhiteBox wb = new WhiteBox(); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
45 |
if (wb.getHeapOopSize() < 0) { |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
46 |
throw new Error("wb.getHeapOopSize() < 0"); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
47 |
} |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
48 |
boolean catched = false; |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
49 |
try { |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
50 |
wb.notExistedMethod(); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
51 |
} catch (UnsatisfiedLinkError e) { |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
52 |
catched = true; |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
53 |
} |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
54 |
if (!catched) { |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
55 |
throw new Error("wb.notExistedMethod() was invoked"); |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
56 |
} |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
57 |
} |
6ceb071b96de
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
iignatyev
parents:
diff
changeset
|
58 |
} |