hotspot/test/runtime/memory/ReadVMPageSize.java
author alanb
Thu, 01 Dec 2016 15:54:39 +0000
changeset 42309 21f9f3fbc302
parent 40631 ed82623d7831
permissions -rw-r--r--
8170599: compiler/** tests using ToolProvider.getSystemClassLoader failing Reviewed-by: hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27876
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27876
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     4
 *
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     7
 * published by the Free Software Foundation.
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     8
 *
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    13
 * accompanied this code).
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    14
 *
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    18
 *
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    21
 * questions.
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    22
 */
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    23
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    24
/*
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    25
 * @test
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    26
 * @summary Using WhiteBox to get VM page size
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 33730
diff changeset
    27
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    28
 * @library /test/lib
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    29
 * @build sun.hotspot.WhiteBox
27876
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    30
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    31
 * @run main/othervm  -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI  ReadVMPageSize
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    32
 */
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    33
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    34
import sun.hotspot.WhiteBox;
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    35
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    36
public class ReadVMPageSize {
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    37
  public static void main(String args[]) throws Exception {
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    38
    WhiteBox wb = WhiteBox.getWhiteBox();
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    39
    int pageSize = wb.getVMPageSize();
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    40
    if (pageSize < 0) {
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    41
      throw new Exception("pageSize < 0");
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    42
    } else {
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    43
      System.out.println("Page size = " + pageSize);
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    44
    }
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    45
  }
91fd97d8eb71 8053995: Add method to WhiteBox to get vm pagesize.
minqi
parents:
diff changeset
    46
}