test/testlibrary/whitebox/sun/hotspot/WhiteBox.java

Tue, 02 Apr 2013 11:28:33 +0200

author
mgerdin
date
Tue, 02 Apr 2013 11:28:33 +0200
changeset 4850
ede380e13960
parent 4637
1b0dc9f87e75
child 4885
3b890cd4da64
child 4908
b84fd7d73702
child 4916
b0301c02f38e
permissions
-rw-r--r--

8009763: Add WB test for String.intern()
Summary: Add convenience method in StringTable, add WhiteBox method and simple sanity test
Reviewed-by: mgerdin, zgu
Contributed-by: leonid.mesnik@oracle.com

mgerdin@3619 1 /*
mgerdin@4637 2 * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
mgerdin@3619 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mgerdin@3619 4 *
mgerdin@3619 5 * This code is free software; you can redistribute it and/or modify it
mgerdin@3619 6 * under the terms of the GNU General Public License version 2 only, as
mgerdin@3619 7 * published by the Free Software Foundation.
mgerdin@3619 8 *
mgerdin@3619 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mgerdin@3619 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mgerdin@3619 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mgerdin@3619 12 * version 2 for more details (a copy is included in the LICENSE file that
mgerdin@3619 13 * accompanied this code).
mgerdin@3619 14 *
mgerdin@3619 15 * You should have received a copy of the GNU General Public License version
mgerdin@3619 16 * 2 along with this work; if not, write to the Free Software Foundation,
mgerdin@3619 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mgerdin@3619 18 *
mgerdin@3619 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mgerdin@3619 20 * or visit www.oracle.com if you need additional information or have any
mgerdin@3619 21 * questions.
mgerdin@3619 22 *
mgerdin@3619 23 */
mgerdin@3619 24
mgerdin@3619 25 package sun.hotspot;
iignatyev@4592 26
iignatyev@4592 27 import java.lang.reflect.Method;
mgerdin@3619 28 import java.security.BasicPermission;
nloodin@3681 29 import sun.hotspot.parser.DiagnosticCommand;
mgerdin@3619 30
mgerdin@3619 31 public class WhiteBox {
mgerdin@3619 32
mgerdin@3619 33 @SuppressWarnings("serial")
mgerdin@3619 34 public static class WhiteBoxPermission extends BasicPermission {
mgerdin@3619 35 public WhiteBoxPermission(String s) {
mgerdin@3619 36 super(s);
mgerdin@3619 37 }
mgerdin@3619 38 }
mgerdin@3619 39
mgerdin@3619 40 private WhiteBox() {}
mgerdin@3619 41 private static final WhiteBox instance = new WhiteBox();
mgerdin@3619 42 private static native void registerNatives();
mgerdin@3619 43
mgerdin@3619 44 /**
mgerdin@3619 45 * Returns the singleton WhiteBox instance.
mgerdin@3619 46 *
mgerdin@3619 47 * The returned WhiteBox object should be carefully guarded
mgerdin@3619 48 * by the caller, since it can be used to read and write data
mgerdin@3619 49 * at arbitrary memory addresses. It must never be passed to
mgerdin@3619 50 * untrusted code.
mgerdin@3619 51 */
mgerdin@3619 52 public synchronized static WhiteBox getWhiteBox() {
mgerdin@3619 53 SecurityManager sm = System.getSecurityManager();
mgerdin@3619 54 if (sm != null) {
mgerdin@3619 55 sm.checkPermission(new WhiteBoxPermission("getInstance"));
mgerdin@3619 56 }
mgerdin@3619 57 return instance;
mgerdin@3619 58 }
mgerdin@3619 59
mgerdin@3619 60 static {
mgerdin@3619 61 registerNatives();
mgerdin@3619 62 }
mgerdin@3619 63
mgerdin@3619 64 // Memory
mgerdin@3619 65 public native long getObjectAddress(Object o);
mgerdin@3619 66 public native int getHeapOopSize();
mgerdin@3619 67
coleenp@4037 68 // Runtime
coleenp@4037 69 // Make sure class name is in the correct format
coleenp@4037 70 public boolean isClassAlive(String name) {
coleenp@4037 71 return isClassAlive0(name.replace('.', '/'));
coleenp@4037 72 }
coleenp@4037 73 private native boolean isClassAlive0(String name);
coleenp@4037 74
mgerdin@3619 75 // G1
mgerdin@3619 76 public native boolean g1InConcurrentMark();
mgerdin@3619 77 public native boolean g1IsHumongous(Object o);
mgerdin@3619 78 public native long g1NumFreeRegions();
mgerdin@3619 79 public native int g1RegionSize();
nloodin@3681 80 public native Object[] parseCommandLine(String commandline, DiagnosticCommand[] args);
ctornqvi@4512 81
ctornqvi@4512 82 // NMT
ctornqvi@4512 83 public native boolean NMTAllocTest();
ctornqvi@4512 84 public native boolean NMTFreeTestMemory();
ctornqvi@4512 85 public native boolean NMTWaitForDataMerge();
iignatyev@4592 86
iignatyev@4592 87 // Compiler
iignatyev@4592 88 public native void deoptimizeAll();
iignatyev@4592 89 public native boolean isMethodCompiled(Method method);
iignatyev@4592 90 public native boolean isMethodCompilable(Method method);
iignatyev@4592 91 public native boolean isMethodQueuedForCompilation(Method method);
iignatyev@4592 92 public native int deoptimizeMethod(Method method);
iignatyev@4592 93 public native void makeMethodNotCompilable(Method method);
iignatyev@4592 94 public native int getMethodCompilationLevel(Method method);
iignatyev@4592 95 public native boolean setDontInlineMethod(Method method, boolean value);
iignatyev@4592 96 public native int getCompileQueuesSize();
mgerdin@4850 97
mgerdin@4850 98 //Intered strings
mgerdin@4850 99 public native boolean isInStringTable(String str);
mgerdin@4850 100
mgerdin@4850 101 // force Full GC
mgerdin@4850 102 public native void fullGC();
mgerdin@3619 103 }

mercurial