WhiteBox.java revision 2714:2879b7785047
1194677Sthompsa/* 2194677Sthompsa * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. 3194677Sthompsa * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4194677Sthompsa * 5194677Sthompsa * This code is free software; you can redistribute it and/or modify it 6194677Sthompsa * under the terms of the GNU General Public License version 2 only, as 7194677Sthompsa * published by the Free Software Foundation. 8194677Sthompsa * 9194677Sthompsa * This code is distributed in the hope that it will be useful, but WITHOUT 10194677Sthompsa * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11194677Sthompsa * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12194677Sthompsa * version 2 for more details (a copy is included in the LICENSE file that 13194677Sthompsa * accompanied this code). 14194677Sthompsa * 15194677Sthompsa * You should have received a copy of the GNU General Public License version 16194677Sthompsa * 2 along with this work; if not, write to the Free Software Foundation, 17194677Sthompsa * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18194677Sthompsa * 19194677Sthompsa * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20194677Sthompsa * or visit www.oracle.com if you need additional information or have any 21194677Sthompsa * questions. 22194677Sthompsa */ 23194677Sthompsa 24194677Sthompsapackage sun.hotspot; 25194677Sthompsa 26194677Sthompsaimport java.lang.management.MemoryUsage; 27194677Sthompsaimport java.lang.reflect.Executable; 28194677Sthompsaimport java.util.Arrays; 29194677Sthompsaimport java.util.List; 30194677Sthompsaimport java.util.function.BiFunction; 31194677Sthompsaimport java.util.function.Function; 32200653Sthompsaimport java.security.BasicPermission; 33194677Sthompsaimport java.util.Objects; 34194677Sthompsa 35194677Sthompsaimport sun.hotspot.parser.DiagnosticCommand; 36194677Sthompsa 37194677Sthompsapublic class WhiteBox { 38194677Sthompsa @SuppressWarnings("serial") 39194677Sthompsa public static class WhiteBoxPermission extends BasicPermission { 40224777Shselasky public WhiteBoxPermission(String s) { 41194677Sthompsa super(s); 42194677Sthompsa } 43194677Sthompsa } 44194677Sthompsa 45194677Sthompsa private WhiteBox() {} 46194677Sthompsa private static final WhiteBox instance = new WhiteBox(); 47194677Sthompsa private static native void registerNatives(); 48194677Sthompsa 49194677Sthompsa /** 50194677Sthompsa * Returns the singleton WhiteBox instance. 51194677Sthompsa * 52194677Sthompsa * The returned WhiteBox object should be carefully guarded 53194677Sthompsa * by the caller, since it can be used to read and write data 54194677Sthompsa * at arbitrary memory addresses. It must never be passed to 55194677Sthompsa * untrusted code. 56194677Sthompsa */ 57194677Sthompsa public synchronized static WhiteBox getWhiteBox() { 58194677Sthompsa SecurityManager sm = System.getSecurityManager(); 59194677Sthompsa if (sm != null) { 60194677Sthompsa sm.checkPermission(new WhiteBoxPermission("getInstance")); 61194677Sthompsa } 62194677Sthompsa return instance; 63194677Sthompsa } 64194677Sthompsa 65194677Sthompsa static { 66194677Sthompsa registerNatives(); 67194677Sthompsa } 68194677Sthompsa 69194677Sthompsa // Get the maximum heap size supporting COOPs 70194677Sthompsa public native long getCompressedOopsMaxHeapSize(); 71194677Sthompsa // Arguments 72194677Sthompsa public native void printHeapSizes(); 73194677Sthompsa 74194677Sthompsa // Memory 75194677Sthompsa private native long getObjectAddress0(Object o); 76194677Sthompsa public long getObjectAddress(Object o) { 77194677Sthompsa Objects.requireNonNull(o); 78194677Sthompsa return getObjectAddress0(o); 79194677Sthompsa } 80194677Sthompsa 81194677Sthompsa public native int getHeapOopSize(); 82194677Sthompsa public native int getVMPageSize(); 83195121Sthompsa public native long getVMAllocationGranularity(); 84195121Sthompsa public native long getVMLargePageSize(); 85194677Sthompsa public native long getHeapSpaceAlignment(); 86194677Sthompsa public native long getHeapAlignment(); 87194677Sthompsa 88194677Sthompsa private native boolean isObjectInOldGen0(Object o); 89194677Sthompsa public boolean isObjectInOldGen(Object o) { 90194677Sthompsa Objects.requireNonNull(o); 91194677Sthompsa return isObjectInOldGen0(o); 92194677Sthompsa } 93194677Sthompsa 94194677Sthompsa private native long getObjectSize0(Object o); 95194677Sthompsa public long getObjectSize(Object o) { 96194677Sthompsa Objects.requireNonNull(o); 97194677Sthompsa return getObjectSize0(o); 98194677Sthompsa } 99194677Sthompsa 100194677Sthompsa // Runtime 101194677Sthompsa // Make sure class name is in the correct format 102194677Sthompsa public boolean isClassAlive(String name) { 103200653Sthompsa return isClassAlive0(name.replace('.', '/')); 104200653Sthompsa } 105246122Shselasky private native boolean isClassAlive0(String name); 106200653Sthompsa 107246122Shselasky private native boolean isMonitorInflated0(Object obj); 108200653Sthompsa public boolean isMonitorInflated(Object obj) { 109200653Sthompsa Objects.requireNonNull(obj); 110200653Sthompsa return isMonitorInflated0(obj); 111200653Sthompsa } 112194677Sthompsa 113194677Sthompsa public native void forceSafepoint(); 114194677Sthompsa 115194677Sthompsa private native long getConstantPool0(Class<?> aClass); 116194677Sthompsa public long getConstantPool(Class<?> aClass) { 117194677Sthompsa Objects.requireNonNull(aClass); 118194677Sthompsa return getConstantPool0(aClass); 119194677Sthompsa } 120194677Sthompsa 121194677Sthompsa private native int getConstantPoolCacheIndexTag0(); 122194677Sthompsa public int getConstantPoolCacheIndexTag() { 123194677Sthompsa return getConstantPoolCacheIndexTag0(); 124194677Sthompsa } 125194677Sthompsa 126194677Sthompsa private native int getConstantPoolCacheLength0(Class<?> aClass); 127194677Sthompsa public int getConstantPoolCacheLength(Class<?> aClass) { 128194677Sthompsa Objects.requireNonNull(aClass); 129194677Sthompsa return getConstantPoolCacheLength0(aClass); 130194677Sthompsa } 131194677Sthompsa 132194677Sthompsa private native int remapInstructionOperandFromCPCache0(Class<?> aClass, int index); 133194677Sthompsa public int remapInstructionOperandFromCPCache(Class<?> aClass, int index) { 134194677Sthompsa Objects.requireNonNull(aClass); 135194677Sthompsa return remapInstructionOperandFromCPCache0(aClass, index); 136194677Sthompsa } 137194677Sthompsa 138239214Shselasky private native int encodeConstantPoolIndyIndex0(int index); 139239214Shselasky public int encodeConstantPoolIndyIndex(int index) { 140194677Sthompsa return encodeConstantPoolIndyIndex0(index); 141194677Sthompsa } 142213435Shselasky 143194677Sthompsa // JVMTI 144194677Sthompsa private native void addToBootstrapClassLoaderSearch0(String segment); 145194677Sthompsa public void addToBootstrapClassLoaderSearch(String segment){ 146194677Sthompsa Objects.requireNonNull(segment); 147194677Sthompsa addToBootstrapClassLoaderSearch0(segment); 148194677Sthompsa } 149194677Sthompsa 150194677Sthompsa private native void addToSystemClassLoaderSearch0(String segment); 151194677Sthompsa public void addToSystemClassLoaderSearch(String segment) { 152199672Sthompsa Objects.requireNonNull(segment); 153199672Sthompsa addToSystemClassLoaderSearch0(segment); 154199672Sthompsa } 155199672Sthompsa 156199672Sthompsa // G1 157199672Sthompsa public native boolean g1InConcurrentMark(); 158199672Sthompsa private native boolean g1IsHumongous0(Object o); 159199672Sthompsa public boolean g1IsHumongous(Object o) { 160199672Sthompsa Objects.requireNonNull(o); 161199672Sthompsa return g1IsHumongous0(o); 162239214Shselasky } 163239214Shselasky 164239214Shselasky private native boolean g1BelongsToHumongousRegion0(long adr); 165239214Shselasky public boolean g1BelongsToHumongousRegion(long adr) { 166194677Sthompsa if (adr == 0) { 167194677Sthompsa throw new IllegalArgumentException("adr argument should not be null"); 168194677Sthompsa } 169194677Sthompsa return g1BelongsToHumongousRegion0(adr); 170194677Sthompsa } 171194677Sthompsa 172194677Sthompsa 173194677Sthompsa private native boolean g1BelongsToFreeRegion0(long adr); 174194677Sthompsa public boolean g1BelongsToFreeRegion(long adr) { 175194677Sthompsa if (adr == 0) { 176194677Sthompsa throw new IllegalArgumentException("adr argument should not be null"); 177194677Sthompsa } 178194677Sthompsa return g1BelongsToFreeRegion0(adr); 179194677Sthompsa } 180194677Sthompsa 181194677Sthompsa public native long g1NumMaxRegions(); 182214429Shselasky public native long g1NumFreeRegions(); 183194677Sthompsa public native int g1RegionSize(); 184194677Sthompsa public native MemoryUsage g1AuxiliaryMemoryUsage(); 185194677Sthompsa private native Object[] parseCommandLine0(String commandline, char delim, DiagnosticCommand[] args); 186194677Sthompsa public Object[] parseCommandLine(String commandline, char delim, DiagnosticCommand[] args) { 187194677Sthompsa Objects.requireNonNull(args); 188194677Sthompsa return parseCommandLine0(commandline, delim, args); 189194677Sthompsa } 190194677Sthompsa 191194677Sthompsa // Parallel GC 192194677Sthompsa public native long psVirtualSpaceAlignment(); 193194677Sthompsa public native long psHeapGenerationAlignment(); 194194677Sthompsa 195194677Sthompsa /** 196194677Sthompsa * Enumerates old regions with liveness less than specified and produces some statistics 197194677Sthompsa * @param liveness percent of region's liveness (live_objects / total_region_size * 100). 198194677Sthompsa * @return long[3] array where long[0] - total count of old regions 199194677Sthompsa * long[1] - total memory of old regions 200194677Sthompsa * long[2] - lowest estimation of total memory of old regions to be freed (non-full 201194677Sthompsa * regions are not included) 202194677Sthompsa */ 203194677Sthompsa public native long[] g1GetMixedGCInfo(int liveness); 204194677Sthompsa 205194677Sthompsa // NMT 206219100Shselasky public native long NMTMalloc(long size); 207219100Shselasky public native void NMTFree(long mem); 208219100Shselasky public native long NMTReserveMemory(long size); 209219100Shselasky public native void NMTCommitMemory(long addr, long size); 210219100Shselasky public native void NMTUncommitMemory(long addr, long size); 211219100Shselasky public native void NMTReleaseMemory(long addr, long size); 212219100Shselasky public native long NMTMallocWithPseudoStack(long size, int index); 213219100Shselasky public native boolean NMTChangeTrackingLevel(); 214219100Shselasky public native int NMTGetHashSize(); 215219100Shselasky 216194677Sthompsa // Compiler 217194677Sthompsa public native int matchesMethod(Executable method, String pattern); 218194677Sthompsa public native int matchesInline(Executable method, String pattern); 219194677Sthompsa public native boolean shouldPrintAssembly(Executable method, int comp_level); 220194677Sthompsa public native int deoptimizeFrames(boolean makeNotEntrant); 221194677Sthompsa public native void deoptimizeAll(); 222194677Sthompsa 223194677Sthompsa public boolean isMethodCompiled(Executable method) { 224194677Sthompsa return isMethodCompiled(method, false /*not osr*/); 225194677Sthompsa } 226194677Sthompsa private native boolean isMethodCompiled0(Executable method, boolean isOsr); 227194677Sthompsa public boolean isMethodCompiled(Executable method, boolean isOsr){ 228194677Sthompsa Objects.requireNonNull(method); 229194677Sthompsa return isMethodCompiled0(method, isOsr); 230239214Shselasky } 231194677Sthompsa public boolean isMethodCompilable(Executable method) { 232194677Sthompsa return isMethodCompilable(method, -2 /*any*/); 233194677Sthompsa } 234194677Sthompsa public boolean isMethodCompilable(Executable method, int compLevel) { 235194677Sthompsa return isMethodCompilable(method, compLevel, false /*not osr*/); 236194677Sthompsa } 237194677Sthompsa private native boolean isMethodCompilable0(Executable method, int compLevel, boolean isOsr); 238194677Sthompsa public boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr) { 239194677Sthompsa Objects.requireNonNull(method); 240223486Shselasky return isMethodCompilable0(method, compLevel, isOsr); 241223486Shselasky } 242223486Shselasky private native boolean isMethodQueuedForCompilation0(Executable method); 243223486Shselasky public boolean isMethodQueuedForCompilation(Executable method) { 244246194Shselasky Objects.requireNonNull(method); 245223486Shselasky return isMethodQueuedForCompilation0(method); 246223486Shselasky } 247223486Shselasky // Determine if the compiler corresponding to the compilation level 'compLevel' 248223486Shselasky // and to the compilation context 'compilation_context' provides an intrinsic 249223486Shselasky // for the method 'method'. An intrinsic is available for method 'method' if: 250223486Shselasky // - the intrinsic is enabled (by using the appropriate command-line flag) and 251246194Shselasky // - the platform on which the VM is running provides the instructions necessary 252246194Shselasky // for the compiler to generate the intrinsic code. 253246194Shselasky // 254246194Shselasky // The compilation context is related to using the DisableIntrinsic flag on a 255246194Shselasky // per-method level, see hotspot/src/share/vm/compiler/abstractCompiler.hpp 256246194Shselasky // for more details. 257246194Shselasky public boolean isIntrinsicAvailable(Executable method, 258246194Shselasky Executable compilationContext, 259223486Shselasky int compLevel) { 260223486Shselasky Objects.requireNonNull(method); 261194677Sthompsa return isIntrinsicAvailable0(method, compilationContext, compLevel); 262194677Sthompsa } 263194677Sthompsa // If usage of the DisableIntrinsic flag is not expected (or the usage can be ignored), 264194677Sthompsa // use the below method that does not require the compilation context as argument. 265194677Sthompsa public boolean isIntrinsicAvailable(Executable method, int compLevel) { 266194677Sthompsa return isIntrinsicAvailable(method, null, compLevel); 267194677Sthompsa } 268194677Sthompsa private native boolean isIntrinsicAvailable0(Executable method, 269194677Sthompsa Executable compilationContext, 270194677Sthompsa int compLevel); 271194677Sthompsa public int deoptimizeMethod(Executable method) { 272194677Sthompsa return deoptimizeMethod(method, false /*not osr*/); 273194677Sthompsa } 274194677Sthompsa private native int deoptimizeMethod0(Executable method, boolean isOsr); 275194677Sthompsa public int deoptimizeMethod(Executable method, boolean isOsr) { 276194677Sthompsa Objects.requireNonNull(method); 277194677Sthompsa return deoptimizeMethod0(method, isOsr); 278194677Sthompsa } 279194677Sthompsa public void makeMethodNotCompilable(Executable method) { 280194677Sthompsa makeMethodNotCompilable(method, -2 /*any*/); 281194677Sthompsa } 282194677Sthompsa public void makeMethodNotCompilable(Executable method, int compLevel) { 283194677Sthompsa makeMethodNotCompilable(method, compLevel, false /*not osr*/); 284194677Sthompsa } 285194677Sthompsa private native void makeMethodNotCompilable0(Executable method, int compLevel, boolean isOsr); 286194677Sthompsa public void makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr) { 287194677Sthompsa Objects.requireNonNull(method); 288194677Sthompsa makeMethodNotCompilable0(method, compLevel, isOsr); 289194677Sthompsa } 290194677Sthompsa public int getMethodCompilationLevel(Executable method) { 291223538Shselasky return getMethodCompilationLevel(method, false /*not ost*/); 292194677Sthompsa } 293194677Sthompsa private native int getMethodCompilationLevel0(Executable method, boolean isOsr); 294194677Sthompsa public int getMethodCompilationLevel(Executable method, boolean isOsr) { 295194677Sthompsa Objects.requireNonNull(method); 296223538Shselasky return getMethodCompilationLevel0(method, isOsr); 297194677Sthompsa } 298194677Sthompsa private native boolean testSetDontInlineMethod0(Executable method, boolean value); 299223538Shselasky public boolean testSetDontInlineMethod(Executable method, boolean value) { 300194677Sthompsa Objects.requireNonNull(method); 301194677Sthompsa return testSetDontInlineMethod0(method, value); 302194677Sthompsa } 303194677Sthompsa public int getCompileQueuesSize() { 304194677Sthompsa return getCompileQueueSize(-2 /*any*/); 305194677Sthompsa } 306194677Sthompsa public native int getCompileQueueSize(int compLevel); 307194677Sthompsa private native boolean testSetForceInlineMethod0(Executable method, boolean value); 308194677Sthompsa public boolean testSetForceInlineMethod(Executable method, boolean value) { 309194677Sthompsa Objects.requireNonNull(method); 310194677Sthompsa return testSetForceInlineMethod0(method, value); 311194677Sthompsa } 312194677Sthompsa public boolean enqueueMethodForCompilation(Executable method, int compLevel) { 313194677Sthompsa return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/); 314194677Sthompsa } 315223538Shselasky private native boolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci); 316194677Sthompsa public boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) { 317223538Shselasky Objects.requireNonNull(method); 318223538Shselasky return enqueueMethodForCompilation0(method, compLevel, entry_bci); 319223538Shselasky } 320194677Sthompsa private native boolean enqueueInitializerForCompilation0(Class<?> aClass, int compLevel); 321194677Sthompsa public boolean enqueueInitializerForCompilation(Class<?> aClass, int compLevel) { 322194677Sthompsa Objects.requireNonNull(aClass); 323194677Sthompsa return enqueueInitializerForCompilation0(aClass, compLevel); 324194677Sthompsa } 325194677Sthompsa private native void clearMethodState0(Executable method); 326194677Sthompsa public void clearMethodState(Executable method) { 327194677Sthompsa Objects.requireNonNull(method); 328194677Sthompsa clearMethodState0(method); 329194677Sthompsa } 330194677Sthompsa public native void lockCompilation(); 331194677Sthompsa public native void unlockCompilation(); 332194677Sthompsa private native int getMethodEntryBci0(Executable method); 333194677Sthompsa public int getMethodEntryBci(Executable method) { 334194677Sthompsa Objects.requireNonNull(method); 335194677Sthompsa return getMethodEntryBci0(method); 336194677Sthompsa } 337194677Sthompsa private native Object[] getNMethod0(Executable method, boolean isOsr); 338194677Sthompsa public Object[] getNMethod(Executable method, boolean isOsr) { 339194677Sthompsa Objects.requireNonNull(method); 340194677Sthompsa return getNMethod0(method, isOsr); 341194677Sthompsa } 342194677Sthompsa public native long allocateCodeBlob(int size, int type); 343194677Sthompsa public long allocateCodeBlob(long size, int type) { 344194677Sthompsa int intSize = (int) size; 345194677Sthompsa if ((long) intSize != size || size < 0) { 346194677Sthompsa throw new IllegalArgumentException( 347194677Sthompsa "size argument has illegal value " + size); 348194677Sthompsa } 349194677Sthompsa return allocateCodeBlob( intSize, type); 350194677Sthompsa } 351194677Sthompsa public native void freeCodeBlob(long addr); 352194677Sthompsa public native void forceNMethodSweep(); 353194677Sthompsa public native Object[] getCodeHeapEntries(int type); 354194677Sthompsa public native int getCompilationActivityMode(); 355194677Sthompsa private native long getMethodData0(Executable method); 356194677Sthompsa public long getMethodData(Executable method) { 357194677Sthompsa Objects.requireNonNull(method); 358194677Sthompsa return getMethodData0(method); 359194677Sthompsa } 360194677Sthompsa public native Object[] getCodeBlob(long addr); 361194677Sthompsa 362194677Sthompsa private native void clearInlineCaches0(boolean preserve_static_stubs); 363194677Sthompsa public void clearInlineCaches() { 364194677Sthompsa clearInlineCaches0(false); 365194677Sthompsa } 366194677Sthompsa public void clearInlineCaches(boolean preserve_static_stubs) { 367194677Sthompsa clearInlineCaches0(preserve_static_stubs); 368194677Sthompsa } 369194677Sthompsa 370194677Sthompsa // Intered strings 371194677Sthompsa public native boolean isInStringTable(String str); 372194677Sthompsa 373194677Sthompsa // Memory 374194677Sthompsa public native void readReservedMemory(); 375194677Sthompsa public native long allocateMetaspace(ClassLoader classLoader, long size); 376194677Sthompsa public native void freeMetaspace(ClassLoader classLoader, long addr, long size); 377194677Sthompsa public native long incMetaspaceCapacityUntilGC(long increment); 378194677Sthompsa public native long metaspaceCapacityUntilGC(); 379194677Sthompsa public native boolean metaspaceShouldConcurrentCollect(); 380194677Sthompsa 381194677Sthompsa // Don't use these methods directly 382194677Sthompsa // Use sun.hotspot.gc.GC class instead. 383194677Sthompsa public native int currentGC(); 384194677Sthompsa public native int allSupportedGC(); 385194677Sthompsa public native boolean gcSelectedByErgo(); 386194677Sthompsa 387194677Sthompsa // Force Young GC 388194677Sthompsa public native void youngGC(); 389194677Sthompsa 390194677Sthompsa // Force Full GC 391194677Sthompsa public native void fullGC(); 392194677Sthompsa 393194677Sthompsa // Method tries to start concurrent mark cycle. 394194677Sthompsa // It returns false if CM Thread is always in concurrent cycle. 395194677Sthompsa public native boolean g1StartConcMarkCycle(); 396200653Sthompsa 397200653Sthompsa // Tests on ReservedSpace/VirtualSpace classes 398200653Sthompsa public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations); 399200653Sthompsa public native void runMemoryUnitTests(); 400194677Sthompsa public native void readFromNoaccessArea(); 401194677Sthompsa public native long getThreadStackSize(); 402194677Sthompsa public native long getThreadRemainingStackSize(); 403194677Sthompsa 404194677Sthompsa // CPU features 405194677Sthompsa public native String getCPUFeatures(); 406194677Sthompsa 407194677Sthompsa // Native extensions 408194677Sthompsa public native long getHeapUsageForContext(int context); 409194677Sthompsa public native long getHeapRegionCountForContext(int context); 410194677Sthompsa private native int getContextForObject0(Object obj); 411194677Sthompsa public int getContextForObject(Object obj) { 412194677Sthompsa Objects.requireNonNull(obj); 413194677Sthompsa return getContextForObject0(obj); 414194677Sthompsa } 415194677Sthompsa public native void printRegionInfo(int context); 416194677Sthompsa 417194677Sthompsa // VM flags 418194677Sthompsa public native boolean isConstantVMFlag(String name); 419194677Sthompsa public native boolean isLockedVMFlag(String name); 420194677Sthompsa public native void setBooleanVMFlag(String name, boolean value); 421194677Sthompsa public native void setIntVMFlag(String name, long value); 422194677Sthompsa public native void setUintVMFlag(String name, long value); 423194677Sthompsa public native void setIntxVMFlag(String name, long value); 424194677Sthompsa public native void setUintxVMFlag(String name, long value); 425194677Sthompsa public native void setUint64VMFlag(String name, long value); 426194677Sthompsa public native void setSizeTVMFlag(String name, long value); 427194677Sthompsa public native void setStringVMFlag(String name, String value); 428194677Sthompsa public native void setDoubleVMFlag(String name, double value); 429194677Sthompsa public native Boolean getBooleanVMFlag(String name); 430194677Sthompsa public native Long getIntVMFlag(String name); 431194677Sthompsa public native Long getUintVMFlag(String name); 432194677Sthompsa public native Long getIntxVMFlag(String name); 433194677Sthompsa public native Long getUintxVMFlag(String name); 434194677Sthompsa public native Long getUint64VMFlag(String name); 435194677Sthompsa public native Long getSizeTVMFlag(String name); 436194677Sthompsa public native String getStringVMFlag(String name); 437194677Sthompsa public native Double getDoubleVMFlag(String name); 438194677Sthompsa private final List<Function<String,Object>> flagsGetters = Arrays.asList( 439194677Sthompsa this::getBooleanVMFlag, this::getIntVMFlag, this::getUintVMFlag, 440194677Sthompsa this::getIntxVMFlag, this::getUintxVMFlag, this::getUint64VMFlag, 441194677Sthompsa this::getSizeTVMFlag, this::getStringVMFlag, this::getDoubleVMFlag); 442194677Sthompsa 443194677Sthompsa public Object getVMFlag(String name) { 444194677Sthompsa return flagsGetters.stream() 445194677Sthompsa .map(f -> f.apply(name)) 446194677Sthompsa .filter(x -> x != null) 447194677Sthompsa .findAny() 448194677Sthompsa .orElse(null); 449194677Sthompsa } 450194677Sthompsa 451194677Sthompsa // Jigsaw 452194677Sthompsa public native void DefineModule(Object module, String version, String location, 453194677Sthompsa Object[] packages); 454194677Sthompsa public native void AddModuleExports(Object from_module, String pkg, Object to_module); 455194677Sthompsa public native void AddReadsModule(Object from_module, Object source_module); 456194677Sthompsa public native void AddModulePackage(Object module, String pkg); 457194677Sthompsa public native void AddModuleExportsToAllUnnamed(Object module, String pkg); 458194677Sthompsa public native void AddModuleExportsToAll(Object module, String pkg); 459194677Sthompsa 460194677Sthompsa public native int getOffsetForName0(String name); 461194677Sthompsa public int getOffsetForName(String name) throws Exception { 462194677Sthompsa int offset = getOffsetForName0(name); 463194677Sthompsa if (offset == -1) { 464194677Sthompsa throw new RuntimeException(name + " not found"); 465194677Sthompsa } 466194677Sthompsa return offset; 467194677Sthompsa } 468194677Sthompsa public native Boolean getMethodBooleanOption(Executable method, String name); 469194677Sthompsa public native Long getMethodIntxOption(Executable method, String name); 470224777Shselasky public native Long getMethodUintxOption(Executable method, String name); 471194677Sthompsa public native Double getMethodDoubleOption(Executable method, String name); 472194677Sthompsa public native String getMethodStringOption(Executable method, String name); 473194677Sthompsa private final List<BiFunction<Executable,String,Object>> methodOptionGetters 474194677Sthompsa = Arrays.asList(this::getMethodBooleanOption, this::getMethodIntxOption, 475194677Sthompsa this::getMethodUintxOption, this::getMethodDoubleOption, 476194677Sthompsa this::getMethodStringOption); 477194677Sthompsa 478194677Sthompsa public Object getMethodOption(Executable method, String name) { 479194677Sthompsa return methodOptionGetters.stream() 480194677Sthompsa .map(f -> f.apply(method, name)) 481194677Sthompsa .filter(x -> x != null) 482194677Sthompsa .findAny() 483194677Sthompsa .orElse(null); 484194677Sthompsa } 485194677Sthompsa 486194677Sthompsa // Safepoint Checking 487194677Sthompsa public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue); 488194677Sthompsa 489194677Sthompsa // Sharing 490194677Sthompsa public native boolean isShared(Object o); 491194677Sthompsa public native boolean isSharedClass(Class<?> c); 492194677Sthompsa public native boolean areSharedStringsIgnored(); 493214429Shselasky 494214429Shselasky // Compiler Directive 495225350Shselasky public native int addCompilerDirective(String compDirect); 496225350Shselasky public native void removeCompilerDirective(int count); 497239214Shselasky} 498239214Shselasky