hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java
author vlivanov
Fri, 04 Dec 2015 23:46:19 +0300
changeset 35086 bbf32241d851
parent 30249 faf83ebbf040
child 38152 80e5da81fb2c
permissions -rw-r--r--
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls Reviewed-by: jrose, dlong, aph, forax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30249
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     1
/*
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     4
 *
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     7
 * published by the Free Software Foundation.
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     8
 *
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    13
 * accompanied this code).
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    14
 *
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    18
 *
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    21
 * questions.
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    22
 */
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    23
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    24
/*
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    25
 * @test WhiteBox
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    26
 * @bug 8011675
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    27
 * @summary verify that whitebox can be used even if not all functions are declared in java-part
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    28
 * @author igor.ignatyev@oracle.com
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    29
 * @library /testlibrary
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    30
 * @compile WhiteBox.java
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    31
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 30249
diff changeset
    32
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-CheckIntrinsics sun.hotspot.WhiteBox
30249
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    33
 */
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    34
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    35
package sun.hotspot;
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    36
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    37
public class WhiteBox {
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    38
    private static native void registerNatives();
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    39
    static { registerNatives(); }
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    40
    public native int notExistedMethod();
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    41
    public native int getHeapOopSize();
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    42
    public static void main(String[] args) {
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    43
        WhiteBox wb = new WhiteBox();
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    44
        if (wb.getHeapOopSize() < 0) {
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    45
            throw new Error("wb.getHeapOopSize() < 0");
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    46
        }
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    47
        boolean catched = false;
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    48
        try {
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    49
            wb.notExistedMethod();
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    50
        } catch (UnsatisfiedLinkError e) {
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    51
            catched = true;
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    52
        }
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    53
        if (!catched) {
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    54
            throw new Error("wb.notExistedMethod() was invoked");
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    55
        }
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    56
    }
faf83ebbf040 8077608: [TESTBUG] Enable Hotspot jtreg tests to run in agentvm mode
ctornqvi
parents:
diff changeset
    57
}