• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WhiteBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中sun.hotspot.WhiteBox的典型用法代码示例。如果您正苦于以下问题:Java WhiteBox类的具体用法?Java WhiteBox怎么用?Java WhiteBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WhiteBox类属于sun.hotspot包,在下文中一共展示了WhiteBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
  if (args.length > 0) {
    WhiteBox.getWhiteBox().readReservedMemory();

    throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
  }

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "ReserveMemory",
        "test");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  if (isWindows()) {
    output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
  } else if (isOsx()) {
    output.shouldContain("SIGBUS");
  } else {
    output.shouldContain("SIGSEGV");
  }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:24,代码来源:ReserveMemory.java


示例2: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String... args) {

        WhiteBox wb = WhiteBox.getWhiteBox();
        StringBuilder sb = new StringBuilder();
        sb.append("1234x"); sb.append("x56789");
        String str = sb.toString();

        if (wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is already interned");
        }
        str.intern();
        if (!wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is not interned");
        }
        str = sb.toString();
        wb.fullGC();
        if (wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is in StringTable even after GC");
        }
    }
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:21,代码来源:SanityTest.java


示例3: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();

    wb.youngGC();
    assertTrue(wb.g1StartConcMarkCycle());
    while (wb.g1InConcurrentMark()) {
        Thread.sleep(5);
    }

    wb.fullGC();
    assertTrue(wb.g1StartConcMarkCycle());
    while (wb.g1InConcurrentMark()) {
        Thread.sleep(5);
    }
    assertTrue(wb.g1StartConcMarkCycle());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:TestConcMarkCycleWB.java


示例4: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String [] args) throws Exception {
  if (args.length != 1) {
    throw new IllegalArgumentException("Usage: <MetaspaceSize>");
  }

  WhiteBox wb = WhiteBox.getWhiteBox();

  // Allocate past the MetaspaceSize limit.
  long metaspaceSize = Long.parseLong(args[0]);
  long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
  long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);

  // Wait for at least one GC to occur. The caller will parse the log files produced.
  GarbageCollectorMXBean cmsGCBean = getCMSGCBean();
  while (cmsGCBean.getCollectionCount() == 0) {
    Thread.sleep(100);
  }

  wb.freeMetaspace(null, metaspace, metaspace);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:TestCMSClassUnloadingEnabledHWM.java


示例5: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    final WhiteBox wb = WhiteBox.getWhiteBox();
    // Fetch the dir where the test class and the class
    // to be loaded resides.
    String classDir = TestClassUnloadingDisabled.class.getProtectionDomain().getCodeSource().getLocation().getPath();
    String className = "ClassToLoadUnload";

    assertFalse(wb.isClassAlive(className), "Should not be loaded yet");

    // The NoPDClassLoader handles loading classes in the test directory
    // and loads them without a protection domain, which in some cases
    // keeps the class live regardless of marking state.
    NoPDClassLoader nopd = new NoPDClassLoader(classDir);
    nopd.loadClass(className);

    assertTrue(wb.isClassAlive(className), "Class should be loaded");

    // Clear the class-loader, class and object references to make
    // class unloading possible.
    nopd = null;

    System.gc();
    assertTrue(wb.isClassAlive(className), "Class should not have ben unloaded");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:TestClassUnloadingDisabled.java


示例6: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String [] args) throws Exception {
  if (args.length != 2) {
    throw new IllegalArgumentException("Usage: <MetaspaceSize> <YoungGenSize>");
  }

  WhiteBox wb = WhiteBox.getWhiteBox();

  // Allocate past the MetaspaceSize limit
  long metaspaceSize = Long.parseLong(args[0]);
  long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
  long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);

  long youngGenSize = Long.parseLong(args[1]);
  triggerYoungGCs(youngGenSize);

  wb.freeMetaspace(null, metaspace, metaspace);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestG1ClassUnloadingHWM.java


示例7: detectByteArrayAllocationOverhead

import sun.hotspot.WhiteBox; //导入依赖的package包/类
/**
 * Detects amount of extra bytes required to allocate a byte array.
 * Allocating a byte[n] array takes more then just n bytes in the heap.
 * Extra bytes are required to store object reference and the length.
 * This amount depends on bitness and other factors.
 *
 * @return byte[] memory overhead
 */
public static int detectByteArrayAllocationOverhead() {

    WhiteBox whiteBox = WhiteBox.getWhiteBox();

    int zeroLengthByteArraySize = (int) whiteBox.getObjectSize(new byte[0]);

    // Since we do not know is there any padding in zeroLengthByteArraySize we cannot just take byte[0] size as overhead
    for (int i = 1; i < MAX_PADDING_SIZE + 1; ++i) {
        int realAllocationSize = (int) whiteBox.getObjectSize(new byte[i]);
        if (realAllocationSize != zeroLengthByteArraySize) {
            // It means we did not have any padding on previous step
            return zeroLengthByteArraySize - (i - 1);
        }
    }
    throw new Error("We cannot find byte[] memory overhead - should not reach here");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Helpers.java


示例8: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
  if (!Platform.isDebugBuild() || !Platform.is64bit()) {
    return;
  }
  wb = WhiteBox.getWhiteBox();
  System.out.println("Starting threads");

  int threads = Integer.valueOf(args[0]);
  timeout = Long.valueOf(args[1]);

  timeStamp = System.currentTimeMillis();

  Thread[] threadsArray = new Thread[threads];
  for (int i = 0; i < threads; i++) {
    threadsArray[i] = new Thread(new Worker());
    threadsArray[i].start();
  }
  for (int i = 0; i < threads; i++) {
    threadsArray[i].join();
  }

  System.out.println("Quitting test.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:RunUnitTestsConcurrently.java


示例9: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
  if (args.length > 0) {
    WhiteBox.getWhiteBox().readReservedMemory();

    throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
  }

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "-XX:-TransmitErrorReport",
        "-XX:-CreateCoredumpOnCrash",
        "-Xmx32m",
        "ReserveMemory",
        "test");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  if (Platform.isWindows()) {
    output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
  } else if (Platform.isOSX()) {
    output.shouldContain("SIGBUS");
  } else {
    output.shouldContain("SIGSEGV");
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ReserveMemory.java


示例10: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    if (args.length > 0) {
        WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, false);
    }
    if (Platform.isDebugBuild()){
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
              "-Xbootclasspath/a:.",
              "-XX:+UnlockDiagnosticVMOptions",
              "-XX:+WhiteBoxAPI",
              "-XX:-TransmitErrorReport",
              "-XX:-CreateCoredumpOnCrash",
              "-Xmx32m",
              "AssertSafepointCheckConsistency2",
              "test");

        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("assert").shouldContain("never");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:AssertSafepointCheckConsistency2.java


示例11: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    if (args.length > 0) {
        WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, true);
    }
    if (Platform.isDebugBuild()){
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
              "-Xbootclasspath/a:.",
              "-XX:+UnlockDiagnosticVMOptions",
              "-XX:+WhiteBoxAPI",
              "-XX:-TransmitErrorReport",
              "-XX:-CreateCoredumpOnCrash",
              "-Xmx32m",
              "AssertSafepointCheckConsistency1",
              "test");
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("assert").shouldContain("always");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:AssertSafepointCheckConsistency1.java


示例12: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    if (args.length > 0) {
        WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, false);
    }
    if (Platform.isDebugBuild()){
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
           "-Xbootclasspath/a:.",
           "-XX:+UnlockDiagnosticVMOptions",
           "-XX:+WhiteBoxAPI",
           "-XX:-TransmitErrorReport",
           "-XX:-CreateCoredumpOnCrash",
           "-Xmx32m",
           "AssertSafepointCheckConsistency4",
           "test");

        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldNotContain("assert");
        output.shouldNotContain("never");
        output.shouldNotContain("always");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:AssertSafepointCheckConsistency4.java


示例13: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    if (args.length > 0) {
        WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, true);
    }
    if (Platform.isDebugBuild()){
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
              "-Xbootclasspath/a:.",
              "-XX:+UnlockDiagnosticVMOptions",
              "-XX:+WhiteBoxAPI",
              "-XX:-TransmitErrorReport",
              "-XX:-CreateCoredumpOnCrash",
              "-Xmx32m",
              "AssertSafepointCheckConsistency3",
              "test");

        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldNotContain("assert");
        output.shouldNotContain("never");
        output.shouldNotContain("always");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:AssertSafepointCheckConsistency3.java


示例14: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();

    if (wb.areSharedStringsIgnored()) {
        System.out.println("Shared strings are ignored, assuming PASS");
        return;
    }

    // The string below is known to be added to CDS archive
    String s = "<init>";
    String internedS = s.intern();

    // Check that it's a valid string
    if (s.getClass() != String.class || !(s instanceof String)) {
        throw new RuntimeException("Shared string is not a valid String: FAIL");
    }

    if (wb.isShared(internedS)) {
        System.out.println("Found shared string, result: PASS");
    } else {
        throw new RuntimeException("String is not shared, result: FAIL");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:SharedStringsWb.java


示例15: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();
    long reserveSize = 256 * 1024;
    long addr;

    ProcessBuilder pb = new ProcessBuilder();
    OutputAnalyzer output;
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());

    addr = wb.NMTReserveMemory(reserveSize);
    // Check for reserved
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"});
    output = new OutputAnalyzer(pb.start());
    output.shouldContain(" Test (reserved=256KB, committed=0KB)");

    wb.NMTReleaseMemory(addr, reserveSize);

    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"});
    output = new OutputAnalyzer(pb.start());
    output.shouldNotContain("Test (reserved=");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:ReleaseNoCommit.java


示例16: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
  OutputAnalyzer output;
  WhiteBox wb = WhiteBox.getWhiteBox();

  // Grab my own PID
  String pid = Long.toString(ProcessTools.getProcessId());
  ProcessBuilder pb = new ProcessBuilder();

  // Use WB API to alloc and free with the mtTest type
  long memAlloc3 = wb.NMTMalloc(128 * 1024);
  long memAlloc2 = wb.NMTMalloc(256 * 1024);
  wb.NMTFree(memAlloc3);
  long memAlloc1 = wb.NMTMalloc(512 * 1024);
  wb.NMTFree(memAlloc2);

  // Run 'jcmd <pid> VM.native_memory summary'
  pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
  output = new OutputAnalyzer(pb.start());
  output.shouldContain("Test (reserved=512KB, committed=512KB)");

  // Free the memory allocated by NMTAllocTest
  wb.NMTFree(memAlloc1);

  output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("Test (reserved=");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:MallocTestType.java


示例17: testAction

import sun.hotspot.WhiteBox; //导入依赖的package包/类
@Override
public void testAction() {
    commonTests();
    runVmTests();
    cleanup();
    if (runServer.orElseThrow(() -> new Error("runServer must be set"))
            && WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        for (int stop = 1; stop < CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION; stop++) {
            String vmOpt = "-XX:TieredStopAtLevel=" + stop;
            generateReplay(/* need coredump = */ false, vmOpt);
            int replayCompLevel = getCompLevelFromReplay();
            Asserts.assertGTE(stop, replayCompLevel, "Unexpected compLevel in replay");
            positiveTest(vmOpt);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:VMBase.java


示例18: getAvailableCompilationLevels

import sun.hotspot.WhiteBox; //导入依赖的package包/类
/**
 * Returns available compilation levels
 *
 * @return int array with compilation levels
 */
public static int[] getAvailableCompilationLevels() {
    if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
        return new int[0];
    }
    if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        Long flagValue = WhiteBox.getWhiteBox()
                .getIntxVMFlag("TieredStopAtLevel");
        int maxLevel = flagValue.intValue();
        Asserts.assertEQ(new Long(maxLevel), flagValue,
                "TieredStopAtLevel has value out of int capacity");
        return IntStream.rangeClosed(1, maxLevel).toArray();
    } else {
        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            return new int[]{4};
        }
        if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) {
            return new int[]{1};
        }
    }
    return new int[0];
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:CompilerUtils.java


示例19: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
  if (args.length > 0) {
    WhiteBox.getWhiteBox().readReservedMemory();

    throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
  }

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "-XX:-TransmitErrorReport",
        "-XX:-CreateCoredumpOnCrash",
        "-Xmx32m",
        "ReserveMemory",
        "test");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  if (isWindows()) {
    output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
  } else if (isOsx()) {
    output.shouldContain("SIGBUS");
  } else {
    output.shouldContain("SIGSEGV");
  }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:ReserveMemory.java


示例20: main

import sun.hotspot.WhiteBox; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();

    if (wb.areSharedStringsIgnored()) {
        System.out.println("Shared strings are ignored, assuming PASS");
        return;
    }

    // The string below is known to be added to CDS archive
    String s = "<init>";
    String internedS = s.intern();

    if (wb.isShared(internedS)) {
        System.out.println("Found shared string, result: PASS");
    } else {
        throw new RuntimeException("String is not shared, result: FAIL");
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:19,代码来源:SharedStringsWb.java



注:本文中的sun.hotspot.WhiteBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InjectorMeta类代码示例发布时间:2022-05-23
下一篇:
Java SSLAuthenticator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap