Java Code Examples for jdk.test.lib.Platform#is64bit()

The following examples show how to use jdk.test.lib.Platform#is64bit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RunUnitTestsConcurrently.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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.");
}
 
Example 2
Source File: CompressedClassPointers.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.is64bit()) {
        // Can't test this on 32 bit, just pass
        System.out.println("Skipping test on 32bit");
        return;
    }
    // Solaris 10 can't mmap compressed oops space without a base
    if (Platform.isSolaris()) {
         String name = System.getProperty("os.version");
         if (name.equals("5.10")) {
             System.out.println("Skipping test on Solaris 10");
             return;
         }
    }
    smallHeapTest();
    smallHeapTestWith3G();
    largeHeapTest();
    largePagesTest();
    heapBaseMinAddressTest();
    sharingTest();
}
 
Example 3
Source File: TestMetaspaceMemoryPool.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    verifyThatMetaspaceMemoryManagerExists();

    boolean isMetaspaceMaxDefined = InputArguments.containsPrefix("-XX:MaxMetaspaceSize");
    verifyMemoryPool(getMemoryPool("Metaspace"), isMetaspaceMaxDefined);

    if (Platform.is64bit()) {
        if (InputArguments.contains("-XX:+UseCompressedOops")) {
            MemoryPoolMXBean cksPool = getMemoryPool("Compressed Class Space");
            verifyMemoryPool(cksPool, true);
        }
    }
}
 
Example 4
Source File: TestPerfCountersAndMemoryPools.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    checkMemoryUsage("Metaspace", "sun.gc.metaspace");

    if (InputArguments.contains("-XX:+UseCompressedClassPointers") && Platform.is64bit()) {
        checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace");
    }
}
 
Example 5
Source File: TestCompressedClassFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (Platform.is64bit()) {
        OutputAnalyzer output = runJava("-XX:CompressedClassSpaceSize=1g",
                                        "-XX:-UseCompressedClassPointers",
                                        "-version");
        output.shouldContain("warning");
        output.shouldNotContain("error");
        output.shouldHaveExitValue(0);
    }
}
 
Example 6
Source File: GetObjectSizeOverflow.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception  {

        if (!Platform.is64bit()) {
            System.out.println("Test needs a 4GB heap and can only be run as a 64bit process, skipping.");
            return;
        }

        PrintWriter pw = new PrintWriter("MANIFEST.MF");
        pw.println("Premain-Class: GetObjectSizeOverflowAgent");
        pw.close();

        ProcessBuilder pb = new ProcessBuilder();
        pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeOverflowAgent.class"});
        pb.start().waitFor();

        ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-Xmx4000m", "-javaagent:agent.jar",  "GetObjectSizeOverflowAgent");
        OutputAnalyzer output = new OutputAnalyzer(pt.start());

        if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) {
            System.out.println("stdout: " + output.getStdout());
            System.out.println("stderr: " + output.getStderr());
            System.out.println("Test could not reserve or allocate enough space, skipping");
            return;
        }

        output.stdoutShouldContain("GetObjectSizeOverflow passed");
    }
 
Example 7
Source File: LocalLongTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
    if (Platform.is64bit()) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint",
                                                                  "--add-opens",
                                                                  "java.base/java.lang=ALL-UNNAMED",
                                                                  "--add-opens",
                                                                  "java.base/java.lang.invoke=ALL-UNNAMED",
                                                                  "LocalLongHelper");
        OutputAnalyzer o = new OutputAnalyzer(pb.start());
        o.shouldHaveExitValue(0);
    }
}
 
Example 8
Source File: ReadFromNoaccessArea.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  if (!Platform.is64bit()) {
    System.out.println("ReadFromNoaccessArea tests is useful only on 64bit architecture. Passing silently.");
    return;
  }

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "-XX:+UseCompressedOops",
        "-XX:HeapBaseMinAddress=33G",
        "-XX:-CreateCoredumpOnCrash",
        "-Xmx32m",
        DummyClassWithMainTryingToReadFromNoaccessArea.class.getName());

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  System.out.println("******* Printing stdout for analysis in case of failure *******");
  System.out.println(output.getStdout());
  System.out.println("******* Printing stderr for analysis in case of failure *******");
  System.out.println(output.getStderr());
  System.out.println("***************************************************************");
  if (output.getStdout() != null && output.getStdout().contains("WB_ReadFromNoaccessArea method is useless")) {
    // Test conditions broken. There is no protected page in ReservedHeapSpace in these circumstances. Silently passing test.
    return;
  }
  if (Platform.isWindows()) {
    output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
  } else if (Platform.isOSX()) {
    output.shouldContain("SIGBUS");
  } else {
    output.shouldContain("SIGSEGV");
  }
}
 
Example 9
Source File: CompressedKlassPointerAndOops.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (!Platform.is64bit()) {
            // Can't test this on 32 bit, just pass
            System.out.println("Skipping test on 32bit");
            return;
        }

        runWithAlignment(16);
        runWithAlignment(32);
        runWithAlignment(64);
        runWithAlignment(128);
    }
 
Example 10
Source File: ObjectAlignment.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (Platform.is64bit()) {
            // Minimum alignment should be 8
            testObjectAlignment(4)
                .shouldContain("outside the allowed range")
                .shouldHaveExitValue(1);

            // Alignment has to be a power of 2
            testObjectAlignment(9)
                .shouldContain("must be power of 2")
                .shouldHaveExitValue(1);

            testObjectAlignment(-1)
                .shouldContain("outside the allowed range")
                .shouldHaveExitValue(1);

            // Maximum alignment allowed is 256
            testObjectAlignment(512)
                .shouldContain("outside the allowed range")
                .shouldHaveExitValue(1);

            // Valid alignments should work
            testObjectAlignment(8).shouldHaveExitValue(0);
            testObjectAlignment(16).shouldHaveExitValue(0);
            testObjectAlignment(256).shouldHaveExitValue(0);

        } else {
            // For a 32bit JVM the option isn't there, make sure it's not silently ignored
            testObjectAlignment(8)
                .shouldContain("Unrecognized VM option 'ObjectAlignmentInBytes=8'")
                .shouldHaveExitValue(1);
        }
    }
 
Example 11
Source File: CdsSameObjectAlignment.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String nativeWordSize = System.getProperty("sun.arch.data.model");
    if (!Platform.is64bit()) {
        System.out.println("ObjectAlignmentInBytes for CDS is only " +
            "supported on 64bit platforms; this plaform is " +
            nativeWordSize);
        System.out.println("Skipping the test");
    } else {
        dumpAndLoadSharedArchive(8);
        dumpAndLoadSharedArchive(16);
        dumpAndLoadSharedArchive(32);
        dumpAndLoadSharedArchive(64);
    }
}
 
Example 12
Source File: CdsDifferentObjectAlignment.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String nativeWordSize = System.getProperty("sun.arch.data.model");
    if (!Platform.is64bit()) {
        System.out.println("ObjectAlignmentInBytes for CDS is only " +
            "supported on 64bit platforms; this plaform is " +
            nativeWordSize);
        System.out.println("Skipping the test");
    } else {
        createAndLoadSharedArchive(16, 64);
        createAndLoadSharedArchive(64, 32);
    }
}
 
Example 13
Source File: ProcessTools.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
 *
 * @return String[] with platform specific arguments, empty if there are
 *         none
 */
public static String[] getPlatformSpecificVMArgs() {

if (Platform.is64bit() && Platform.isSolaris()) {
        return new String[] { "-d64" };
    }

    return new String[] {};
}
 
Example 14
Source File: TestMetaspacePerfCounters.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isUsingCompressedClassPointers() {
    return Platform.is64bit() && InputArguments.contains("-XX:+UseCompressedClassPointers");
}