From 3b9c787e3c8ec3f89bf041d37c0b2d1484a2ada0 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 28 Nov 2023 03:17:41 +0000 Subject: [PATCH] 8208655: use JTreg skipped status in hotspot tests 8023735: [TESTBUG][macosx] runtime/XCheckJniJsig/XCheckJSig.java fails on MacOS X 8208701: Fix for JDK-8208655 causes test failures in CI tier1 8208706: compiler/tiered/ConstantGettersTransitionsTest.java fails to compile 8186095: upgrade to jtreg 4.2 b08 8183503: Update hotspot tests to allow for unique test classes directory 8213410: UseCompressedOops requirement check fails fails on 32-bit system Reviewed-by: stuefe, sgehwolf Backport-of: 17b730d7edf7be91ee841180ea6a59b26c0c567a --- hotspot/test/ProblemList.txt | 1 - hotspot/test/TEST.ROOT | 6 +- .../TestAnonymousClassUnloading.java | 3 +- .../ConstantGettersTransitionsTest.java | 10 +++- .../compiler/tiered/LevelTransitionTest.java | 8 ++- .../compiler/tiered/NonTieredLevelsTest.java | 7 ++- .../compiler/tiered/TieredLevelsTest.java | 9 ++- .../test/gc/arguments/TestAggressiveHeap.java | 9 ++- .../test/gc/g1/TestHumongousShrinkHeap.java | 11 ++-- .../gc/g1/TestLargePageUseForAuxMemory.java | 15 ++--- .../test/gc/g1/TestShrinkAuxiliaryData.java | 11 ++-- .../test/gc/g1/TestShrinkAuxiliaryData00.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData05.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData10.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData15.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData20.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData25.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData30.java | 2 +- .../CompressedClassSpaceSizeInJmapHeap.java | 1 + .../gc/metaspace/TestMetaspaceMemoryPool.java | 1 + .../6819213/TestBootNativeLibraryPath.java | 14 ++--- .../CompressedClassPointers.java | 14 ++--- .../CompressedKlassPointerAndOops.java | 11 +--- .../runtime/ErrorHandling/TestOnError.java | 10 +--- .../Metaspace/FragmentMetaspaceSimple.java | 55 +++++++++++++++++-- .../Metaspace/MaxMetaspaceSizeTest.java | 2 +- .../CdsDifferentObjectAlignment.java | 18 ++---- .../CdsSameObjectAlignment.java | 18 ++---- .../runtime/XCheckJniJsig/XCheckJSig.java | 41 +++++++------- .../LargePages/TestLargePagesFlags.java | 9 +-- .../test/runtime/os/AvailableProcessors.java | 28 +++++----- .../testlibrary/ClassUnloadCommon.java | 47 +++++++++++++--- .../jvmti/GetObjectSizeOverflow.java | 21 ++++--- test/jtreg-ext/requires/VMProps.java | 8 +++ test/lib/jtreg/SkippedException.java | 38 +++++++++++++ 35 files changed, 273 insertions(+), 167 deletions(-) create mode 100644 test/lib/jtreg/SkippedException.java diff --git a/hotspot/test/ProblemList.txt b/hotspot/test/ProblemList.txt index c05cc9a399..3f6cee0558 100644 --- a/hotspot/test/ProblemList.txt +++ b/hotspot/test/ProblemList.txt @@ -43,7 +43,6 @@ runtime/SharedArchiveFile/SharedBaseAddress.java 8044600 solaris-sparc runtime/6929067/Test6929067.sh 8028740 generic-all runtime/CDSCompressedKPtrs/XShareAuto.java 8026154 generic-all -runtime/XCheckJniJsig/XCheckJSig.java 8023735 generic-all runtime/6626217/Test6626217.sh 8028733 generic-all runtime/jsig/Test8017498.sh 8028806 generic-all runtime/LoadClass/LoadClassNegative.java 8028095 generic-all diff --git a/hotspot/test/TEST.ROOT b/hotspot/test/TEST.ROOT index 55ec2d6118..f271796a61 100644 --- a/hotspot/test/TEST.ROOT +++ b/hotspot/test/TEST.ROOT @@ -36,7 +36,11 @@ groups=TEST.groups [closed/TEST.groups] requires.extraPropDefns = ../../test/jtreg-ext/requires/VMProps.java requires.properties=sun.arch.data.model \ vm.flavor \ - vm.bits + vm.bits \ + vm.debug + +# Minimum jtreg version +requiredVersion=4.2 b13 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them diff --git a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java index 9ff45492f4..6126995782 100644 --- a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java +++ b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java @@ -107,7 +107,8 @@ public class TestAnonymousClassUnloading { */ static public void main(String[] args) throws Exception { // (1) Load an anonymous version of this class using the corresponding Unsafe method - URL classUrl = TestAnonymousClassUnloading.class.getResource("TestAnonymousClassUnloading.class"); + String rn = TestAnonymousClassUnloading.class.getSimpleName() + ".class"; + URL classUrl = TestAnonymousClassUnloading.class.getResource(rn); URLConnection connection = classUrl.openConnection(); int length = connection.getContentLength(); diff --git a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java index 2de9dc5784..73fb600344 100644 --- a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java +++ b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,12 +21,14 @@ * questions. */ +import jtreg.SkippedException; + import java.lang.reflect.Executable; import java.util.concurrent.Callable; /** * @test ConstantGettersTransitionsTest - * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib * @build TransitionsTestExecutor ConstantGettersTransitionsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions @@ -37,7 +39,9 @@ import java.util.concurrent.Callable; */ public class ConstantGettersTransitionsTest extends LevelTransitionTest { public static void main(String[] args) { - assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false)); + if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { + throw new SkippedException("Test isn't applicable for non-tiered mode"); + } // run test cases for (TestCase testCase : ConstantGettersTestCase.values()) { diff --git a/hotspot/test/compiler/tiered/LevelTransitionTest.java b/hotspot/test/compiler/tiered/LevelTransitionTest.java index 84ead05d1e..ca189c419b 100644 --- a/hotspot/test/compiler/tiered/LevelTransitionTest.java +++ b/hotspot/test/compiler/tiered/LevelTransitionTest.java @@ -21,6 +21,8 @@ * questions. */ +import jtreg.SkippedException; + import java.lang.reflect.Executable; import java.lang.reflect.Method; import java.util.Objects; @@ -28,7 +30,7 @@ import java.util.concurrent.Callable; /** * @test LevelTransitionTest - * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib * @build TransitionsTestExecutor LevelTransitionTest * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions @@ -44,7 +46,9 @@ public class LevelTransitionTest extends TieredLevelsTest { private int transitionCount; public static void main(String[] args) throws Throwable { - assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false)); + if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { + throw new SkippedException("Test isn't applicable for non-tiered mode"); + } CompilerWhiteBoxTest.main(LevelTransitionTest::new, args); // run extended test cases diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java index 1e86b6ebc3..f51a5effde 100644 --- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,10 +22,11 @@ */ import java.util.function.IntPredicate; +import jtreg.SkippedException; /** * @test NonTieredLevelsTest - * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib * @build NonTieredLevelsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation @@ -54,7 +55,7 @@ public class NonTieredLevelsTest extends CompLevelsTest { } public static void main(String[] args) throws Exception { if (CompilerWhiteBoxTest.skipOnTieredCompilation(true)) { - return; + throw new SkippedException("Test isn't applicable for tiered mode"); } CompilerWhiteBoxTest.main(NonTieredLevelsTest::new, args); } diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java index 28d2f76acb..648de62b3b 100644 --- a/hotspot/test/compiler/tiered/TieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test TieredLevelsTest - * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib * @build TieredLevelsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation @@ -33,10 +33,13 @@ * @summary Verify that all levels < 'TieredStopAtLevel' can be used * @author igor.ignatyev@oracle.com */ + +import jtreg.SkippedException; + public class TieredLevelsTest extends CompLevelsTest { public static void main(String[] args) throws Exception, Throwable { if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { - return; + throw new SkippedException("Test isn't applicable for non-tiered mode"); } CompilerWhiteBoxTest.main(TieredLevelsTest::new, args); } diff --git a/hotspot/test/gc/arguments/TestAggressiveHeap.java b/hotspot/test/gc/arguments/TestAggressiveHeap.java index 84e59eebdc..c2ac3c0fc6 100644 --- a/hotspot/test/gc/arguments/TestAggressiveHeap.java +++ b/hotspot/test/gc/arguments/TestAggressiveHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @key gc * @bug 8179084 * @summary Test argument processing for -XX:+AggressiveHeap. - * @library /testlibrary + * @library /testlibrary /test/lib * @run driver TestAggressiveHeap */ @@ -36,6 +36,7 @@ import javax.management.ObjectName; import com.oracle.java.testlibrary.OutputAnalyzer; import com.oracle.java.testlibrary.ProcessTools; +import jtreg.SkippedException; public class TestAggressiveHeap { @@ -86,9 +87,7 @@ public class TestAggressiveHeap { private static boolean canUseAggressiveHeapOption() throws Exception { if (!haveRequiredMemory()) { - System.out.println( - "Skipping test of " + option + " : insufficient memory"); - return false; + throw new SkippedException("Skipping test of " + option + " : insufficient memory"); } return true; } diff --git a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java index b2dcb00f8d..fcdedfc82e 100644 --- a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java +++ b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @requires vm.gc=="G1" | vm.gc=="null" * @summary Verify that heap shrinks after GC in the presence of fragmentation * due to humongous objects - * @library /testlibrary + * @library /testlibrary /test/lib * @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10 * -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc * TestHumongousShrinkHeap @@ -39,6 +39,7 @@ import java.util.ArrayList; import java.util.List; import sun.management.ManagementFactoryHelper; import static com.oracle.java.testlibrary.Asserts.*; +import jtreg.SkippedException; public class TestHumongousShrinkHeap { @@ -57,13 +58,11 @@ public class TestHumongousShrinkHeap { public static void main(String[] args) { if (HUMON_COUNT == 0) { - System.out.println("Skipped. Heap is too small"); - return; + throw new SkippedException("Heap is too small"); } if (TOTAL_MEMORY + REGION_SIZE * HUMON_COUNT > MAX_MEMORY) { - System.out.println("Skipped. Initial heap size is to close to max heap size."); - return; + throw new SkippedException("Initial heap size is to close to max heap size."); } System.out.format("Running with %s initial heap size of %s maximum heap size. " diff --git a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java index ef8ada7037..478fd0fdad 100644 --- a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java +++ b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,8 @@ * @test TestLargePageUseForAuxMemory.java * @bug 8058354 * @key gc - * @library /testlibrary /testlibrary/whitebox - * @requires (vm.gc=="G1" | vm.gc=="null") + * @library /testlibrary /testlibrary/whitebox /test/lib + * @requires (vm.gc=="G1" | vm.gc=="null") & vm.debug * @build TestLargePageUseForAuxMemory * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission @@ -35,6 +35,7 @@ */ import com.oracle.java.testlibrary.*; +import jtreg.SkippedException; import sun.hotspot.WhiteBox; public class TestLargePageUseForAuxMemory { @@ -88,18 +89,12 @@ public class TestLargePageUseForAuxMemory { } public static void main(String[] args) throws Exception { - if (!Platform.isDebugBuild()) { - System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option."); - return; - } - WhiteBox wb = WhiteBox.getWhiteBox(); smallPageSize = wb.getVMPageSize(); largePageSize = wb.getVMLargePageSize(); if (largePageSize == 0) { - System.out.println("Skip tests because large page support does not seem to be available on this platform."); - return; + throw new SkippedException("Large page support does not seem to be available on this platform."); } // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size). diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java index 3145eb6385..11dae8fe42 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ import com.oracle.java.testlibrary.OutputAnalyzer; import com.oracle.java.testlibrary.Platform; import com.oracle.java.testlibrary.ProcessTools; import com.oracle.java.testlibrary.Utils; +import jtreg.SkippedException; + import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.MemoryUsage; @@ -67,10 +69,9 @@ public class TestShrinkAuxiliaryData { int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize())); if (maxCacheSize < hotCardTableSize) { - System.out.format("Skiping test for %d cache size due max cache size %d", - hotCardTableSize, maxCacheSize - ); - return; + throw new SkippedException(String.format( + "Skiping test for %d cache size due max cache size %d", + hotCardTableSize, maxCacheSize)); } printTestInfo(maxCacheSize); diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java index 04523e50c3..e7baeb6613 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * TestShrinkAuxiliaryData TestShrinkAuxiliaryData00 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java index 652c262fab..dbc8dc861c 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * TestShrinkAuxiliaryData TestShrinkAuxiliaryData05 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java index 46af6f820c..0dfb879080 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java index a13af4ebcb..c69797c6ad 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java index 899acdbc55..092226a7ce 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java index 1e982f8d2a..8692d04d01 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java index bf11e0e909..731ad4a288 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java @@ -27,7 +27,7 @@ * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" - * @library /testlibrary /testlibrary/whitebox + * @library /testlibrary /testlibrary/whitebox /test/lib * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java index 0ca0878a63..1d9b81a5f4 100644 --- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java +++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java @@ -25,6 +25,7 @@ * @test CompressedClassSpaceSizeInJmapHeap * @bug 8004924 * @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize + * @requires vm.bits == 64 * @library /testlibrary * @run main/othervm -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap */ diff --git a/hotspot/test/gc/metaspace/TestMetaspaceMemoryPool.java b/hotspot/test/gc/metaspace/TestMetaspaceMemoryPool.java index bf9e74c8ab..f85960cdc7 100644 --- a/hotspot/test/gc/metaspace/TestMetaspaceMemoryPool.java +++ b/hotspot/test/gc/metaspace/TestMetaspaceMemoryPool.java @@ -30,6 +30,7 @@ import static com.oracle.java.testlibrary.Asserts.*; * @bug 8000754 * @summary Tests that a MemoryPoolMXBeans is created for metaspace and that a * MemoryManagerMXBean is created. + * @requires vm.bits == 64 * @library /testlibrary * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops TestMetaspaceMemoryPool * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPool diff --git a/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java b/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java index c31d7b6b40..37cf2a223a 100644 --- a/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java +++ b/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,11 +24,13 @@ /* * @test TestBootNativeLibraryPath.java * @bug 6819213 - * @compile -XDignore.symbol.file TestBootNativeLibraryPath.java * @summary verify sun.boot.native.library.path is expandable on 32 bit systems - * @run main TestBootNativeLibraryPath * @author ksrini -*/ + * @library /test/lib + * @requires vm.bits == 32 + * @compile -XDignore.symbol.file TestBootNativeLibraryPath.java + * @run main TestBootNativeLibraryPath + */ import java.io.BufferedReader; import java.io.File; @@ -107,10 +109,6 @@ public class TestBootNativeLibraryPath { public static void main(String[] args) { try { - if (!System.getProperty("sun.arch.data.model").equals("32")) { - System.out.println("Warning: test skipped for 64-bit systems\n"); - return; - } String osname = System.getProperty("os.name"); if (osname.startsWith("Windows")) { osname = "Windows"; diff --git a/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java b/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java index 66a335e279..7007b03be8 100644 --- a/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java +++ b/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java @@ -25,10 +25,13 @@ * @test * @bug 8024927 * @summary Testing address of compressed class pointer space as best as possible. - * @library /testlibrary + * @requires vm.bits == 64 + * @library /testlibrary /test/lib + * @run main CompressedClassPointers */ import com.oracle.java.testlibrary.*; +import jtreg.SkippedException; public class CompressedClassPointers { @@ -114,17 +117,10 @@ public class CompressedClassPointers { } 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; + throw new SkippedException("Solaris 10 can't mmap compressed oops space without a base"); } } smallHeapTest(); diff --git a/hotspot/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java b/hotspot/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java index 228d8cb6a7..55896e30ed 100644 --- a/hotspot/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java +++ b/hotspot/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ * @key regression * @summary NPG: UseCompressedClassPointers asserts with ObjectAlignmentInBytes=32 * @library /testlibrary + * @requires vm.bits == 64 + * @run main CompressedKlassPointerAndOops */ import com.oracle.java.testlibrary.*; @@ -34,13 +36,6 @@ import com.oracle.java.testlibrary.*; public class CompressedKlassPointerAndOops { 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); diff --git a/hotspot/test/runtime/ErrorHandling/TestOnError.java b/hotspot/test/runtime/ErrorHandling/TestOnError.java index 62d66b3805..44e5014e22 100644 --- a/hotspot/test/runtime/ErrorHandling/TestOnError.java +++ b/hotspot/test/runtime/ErrorHandling/TestOnError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,12 @@ /* * @test TestOnError + * @bug 8078470 * @summary Test using -XX:OnError= * @library /testlibrary + * @requires vm.debug * @build TestOnError com.oracle.java.testlibrary.* * @run main TestOnError - * @bug 8078470 */ import com.oracle.java.testlibrary.*; @@ -35,11 +36,6 @@ import com.oracle.java.testlibrary.*; public class TestOnError { public static void main(String[] args) throws Exception { - if (!Platform.isDebugBuild()) { - System.out.println("Test requires a non-product build - skipping"); - return; - } - String msg = "Test Succeeded"; // Execute the VM so that a diff --git a/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java b/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java index 2e6f7b52c0..4bff97c206 100644 --- a/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java +++ b/hotspot/test/runtime/Metaspace/FragmentMetaspaceSimple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,19 @@ * questions. */ +// ClassFileInstaller is needed to place test.Empty into well-known place /** * @test - * @library /runtime/testlibrary - * @library classes - * @build test.Empty ClassUnloadCommon + * @library /test/lib classes + * @build test.Empty + * @run driver ClassFileInstaller test.Empty * @run main/othervm/timeout=200 FragmentMetaspaceSimple */ +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.util.ArrayList; /** @@ -47,8 +52,14 @@ public class FragmentMetaspaceSimple { private static void runSimple(long time) { long startTime = System.currentTimeMillis(); ArrayList cls = new ArrayList<>(); - for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) { - ClassLoader ldr = ClassUnloadCommon.newClassLoader(); + char sep = File.separatorChar; + String fileName = "test" + sep + "Empty.class"; + File file = new File(fileName); + byte buff[] = read(file); + + int i = 0; + for (i = 0; System.currentTimeMillis() < startTime + time; ++i) { + ClassLoader ldr = new MyClassLoader(buff); if (i % 1000 == 0) { cls.clear(); } @@ -59,11 +70,43 @@ public class FragmentMetaspaceSimple { Class c = null; try { c = ldr.loadClass("test.Empty"); + c.getClass().getClassLoader(); // make sure we have a valid class. } catch (ClassNotFoundException ex) { + System.out.println("i=" + i + ", len" + buff.length); throw new RuntimeException(ex); } c = null; } cls = null; + System.out.println("Finished " + i + " iterations in " + + (System.currentTimeMillis() - startTime) + " ms"); + } + + private static byte[] read(File file) { + byte buff[] = new byte[(int)(file.length())]; + try { + DataInputStream din = new DataInputStream(new FileInputStream(file)); + din.readFully(buff); + din.close(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + return buff; + } + + static class MyClassLoader extends ClassLoader { + byte buff[]; + MyClassLoader(byte buff[]) { + this.buff = buff; + } + + public Class loadClass() throws ClassNotFoundException { + String name = "test.Empty"; + try { + return defineClass(name, buff, 0, buff.length); + } catch (Throwable e) { + throw new ClassNotFoundException(name, e); + } + } } } diff --git a/hotspot/test/runtime/Metaspace/MaxMetaspaceSizeTest.java b/hotspot/test/runtime/Metaspace/MaxMetaspaceSizeTest.java index a10b54d483..e7682d5a9d 100644 --- a/hotspot/test/runtime/Metaspace/MaxMetaspaceSizeTest.java +++ b/hotspot/test/runtime/Metaspace/MaxMetaspaceSizeTest.java @@ -26,7 +26,7 @@ import com.oracle.java.testlibrary.OutputAnalyzer; /* * @test MaxMetaspaceSizeTest - * @requires vm.bits == "64" + * @requires vm.bits == 64 * @bug 8087291 * @library /testlibrary * @run main/othervm MaxMetaspaceSizeTest diff --git a/hotspot/test/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java b/hotspot/test/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java index 9ecb1dae39..0848969402 100644 --- a/hotspot/test/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java +++ b/hotspot/test/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java @@ -28,26 +28,20 @@ * This is a negative test; using object alignment for loading that * is different from object alignment for creating a CDS file * should fail when loading. + * @requires vm.bits == 64 * @library /testlibrary * @bug 8025642 + * @run main CdsDifferentObjectAlignment */ import com.oracle.java.testlibrary.*; public class CdsDifferentObjectAlignment { - 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); - } - } + public static void main(String[] args) throws Exception { + createAndLoadSharedArchive(16, 64); + createAndLoadSharedArchive(64, 32); + } // Parameters are object alignment expressed in bytes private static void diff --git a/hotspot/test/runtime/SharedArchiveFile/CdsSameObjectAlignment.java b/hotspot/test/runtime/SharedArchiveFile/CdsSameObjectAlignment.java index 5c91f604a8..fd62fc00fc 100644 --- a/hotspot/test/runtime/SharedArchiveFile/CdsSameObjectAlignment.java +++ b/hotspot/test/runtime/SharedArchiveFile/CdsSameObjectAlignment.java @@ -25,25 +25,19 @@ * @test CdsSameObjectAlignment * @summary Testing CDS (class data sharing) using varying object alignment. * Using same object alignment for each dump/load pair + * @requires vm.bits == 64 * @library /testlibrary + * @run main CdsSameObjectAlignment */ import com.oracle.java.testlibrary.*; public class CdsSameObjectAlignment { 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); - } + dumpAndLoadSharedArchive(8); + dumpAndLoadSharedArchive(16); + dumpAndLoadSharedArchive(32); + dumpAndLoadSharedArchive(64); } private static void diff --git a/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java b/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java index ae0ad73cd3..1aed23f066 100644 --- a/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java +++ b/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,54 +25,55 @@ * @test * @bug 7051189 8023393 * @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so - * @library /testlibrary + * @library /testlibrary /test/lib + * @requires os.family == "solaris" | os.family == "linux" | os.family == "mac" * @run main XCheckJSig */ -import java.util.*; +import java.io.File; +import java.util.Map; import com.oracle.java.testlibrary.*; +import jtreg.SkippedException; public class XCheckJSig { public static void main(String args[]) throws Throwable { System.out.println("Regression test for bugs 7051189 and 8023393"); - if (!Platform.isSolaris() && !Platform.isLinux() && !Platform.isOSX()) { - System.out.println("Test only applicable on Solaris, Linux, and Mac OSX, skipping"); - return; - } String jdk_path = System.getProperty("test.jdk"); String os_arch = Platform.getOsArch(); String libjsig; String env_var; if (Platform.isOSX()) { - libjsig = jdk_path + "/jre/lib/server/libjsig.dylib"; env_var = "DYLD_INSERT_LIBRARIES"; + libjsig = jdk_path + "/jre/lib/libjsig.dylib"; // jdk location + if (!(new File(libjsig).exists())) { + libjsig = jdk_path + "/lib/libjsig.dylib"; // jre location + } } else { - libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; env_var = "LD_PRELOAD"; - } - String java_program; - if (Platform.isSolaris()) { - // On Solaris, need to call the 64-bit Java directly in order for - // LD_PRELOAD to work because libjsig.so is 64-bit. - java_program = jdk_path + "/jre/bin/" + os_arch + "/java"; - } else { - java_program = JDKToolFinder.getJDKTool("java"); + libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; // jdk location + if (!(new File(libjsig).exists())) { + libjsig = jdk_path + "/lib/" + os_arch + "/libjsig.so"; // jre location + } } // If this test fails, these might be useful to know. System.out.println("libjsig: " + libjsig); System.out.println("osArch: " + os_arch); - System.out.println("java_program: " + java_program); - ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version"); + // Make sure the libjsig file exists. + if (!(new File(libjsig).exists())) { + throw new jtreg.SkippedException("File " + libjsig + " not found"); + } + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-version"); Map env = pb.environment(); env.put(env_var, libjsig); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("libjsig is activated"); output.shouldHaveExitValue(0); - pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version"); + pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-verbose:jni", "-version"); env = pb.environment(); env.put(env_var, libjsig); output = new OutputAnalyzer(pb.start()); diff --git a/hotspot/test/runtime/memory/LargePages/TestLargePagesFlags.java b/hotspot/test/runtime/memory/LargePages/TestLargePagesFlags.java index 58044c695e..0083d05657 100644 --- a/hotspot/test/runtime/memory/LargePages/TestLargePagesFlags.java +++ b/hotspot/test/runtime/memory/LargePages/TestLargePagesFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test TestLargePagesFlags * @summary Tests how large pages are choosen depending on the given large pages flag combinations. + * @requires os.family == "linux" * @library /testlibrary * @run main TestLargePagesFlags */ @@ -30,16 +31,12 @@ import com.oracle.java.testlibrary.OutputAnalyzer; import com.oracle.java.testlibrary.Platform; import com.oracle.java.testlibrary.ProcessTools; + import java.util.ArrayList; public class TestLargePagesFlags { public static void main(String [] args) throws Exception { - if (!Platform.isLinux()) { - System.out.println("Skipping. TestLargePagesFlags has only been implemented for Linux."); - return; - } - testUseTransparentHugePages(); testUseHugeTLBFS(); testUseSHM(); diff --git a/hotspot/test/runtime/os/AvailableProcessors.java b/hotspot/test/runtime/os/AvailableProcessors.java index 482d762ed0..3ea53b4791 100644 --- a/hotspot/test/runtime/os/AvailableProcessors.java +++ b/hotspot/test/runtime/os/AvailableProcessors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,20 +20,24 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -import java.io.File; -import com.oracle.java.testlibrary.ProcessTools; -import com.oracle.java.testlibrary.OutputAnalyzer; -import java.util.ArrayList; /* * @test * @bug 6515172 * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux * @requires os.family == "linux" - * @library /testlibrary + * @library /testlibrary /test/lib * @build com.oracle.java.testlibrary.* * @run driver AvailableProcessors */ + +import com.oracle.java.testlibrary.ProcessTools; +import com.oracle.java.testlibrary.OutputAnalyzer; +import jtreg.SkippedException; + +import java.util.ArrayList; +import java.io.File; + public class AvailableProcessors { static final String SUCCESS_STRING = "Found expected processors: "; @@ -47,20 +51,18 @@ public class AvailableProcessors { String taskset; final String taskset1 = "/bin/taskset"; final String taskset2 = "/usr/bin/taskset"; - if (new File(taskset1).exists()) + if (new File(taskset1).exists()) { taskset = taskset1; - else if (new File(taskset2).exists()) + } else if (new File(taskset2).exists()) { taskset = taskset2; - else { - System.out.println("Skipping test: could not find taskset command"); - return; + } else { + throw new SkippedException("Could not find taskset command"); } int available = Runtime.getRuntime().availableProcessors(); if (available == 1) { - System.out.println("Skipping test: only one processor available"); - return; + throw new SkippedException("only one processor available"); } // Get the java command we want to execute diff --git a/hotspot/test/runtime/testlibrary/ClassUnloadCommon.java b/hotspot/test/runtime/testlibrary/ClassUnloadCommon.java index 06729ac6a8..2794b177a1 100644 --- a/hotspot/test/runtime/testlibrary/ClassUnloadCommon.java +++ b/hotspot/test/runtime/testlibrary/ClassUnloadCommon.java @@ -25,8 +25,10 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.stream.Stream; public class ClassUnloadCommon { public static class TestFailure extends RuntimeException { @@ -55,14 +57,45 @@ public class ClassUnloadCommon { System.gc(); } + /** + * Creates a class loader that loads classes from {@code ${test.class.path}} + * before delegating to the system class loader. + */ public static ClassLoader newClassLoader() { - try { - return new URLClassLoader(new URL[] { - Paths.get(System.getProperty("test.classes",".") + File.separatorChar + "classes").toUri().toURL(), - }, null); - } catch (MalformedURLException e){ - throw new RuntimeException("Unexpected URL conversion failure", e); - } + String cp = System.getProperty("test.class.path", "."); + URL[] urls = Stream.of(cp.split(File.pathSeparator)) + .map(Paths::get) + .map(ClassUnloadCommon::toURL) + .toArray(URL[]::new); + return new URLClassLoader(urls) { + @Override + public Class loadClass(String cn, boolean resolve) + throws ClassNotFoundException + { + synchronized (getClassLoadingLock(cn)) { + Class c = findLoadedClass(cn); + if (c == null) { + try { + c = findClass(cn); + } catch (ClassNotFoundException e) { + c = getParent().loadClass(cn); + } + + } + if (resolve) { + resolveClass(c); + } + return c; + } + } + }; } + static URL toURL(Path path) { + try { + return path.toUri().toURL(); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } } diff --git a/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java b/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java index 3f0aad09ee..1553bda47f 100644 --- a/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java +++ b/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,27 +20,27 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -import java.io.PrintWriter; -import com.oracle.java.testlibrary.*; /* * Test to verify GetObjectSize does not overflow on a 600M element int[] * * @test * @bug 8027230 - * @library /testlibrary + * @library /testlibrary /test/lib + * @requires vm.bits == 64 * @build ClassFileInstaller com.oracle.java.testlibrary.* GetObjectSizeOverflowAgent * @run main ClassFileInstaller GetObjectSizeOverflowAgent * @run main GetObjectSizeOverflow */ + +import java.io.PrintWriter; + +import com.oracle.java.testlibrary.*; +import jtreg.SkippedException; + public class GetObjectSizeOverflow { 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(); @@ -55,8 +55,7 @@ public class GetObjectSizeOverflow { 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; + throw new SkippedException("Test could not reserve or allocate enough space"); } output.stdoutShouldContain("GetObjectSizeOverflow passed"); diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index ef7de8faf3..1d7652be08 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -52,6 +52,7 @@ public class VMProps implements Callable> { map.put("vm.flavor", vmFlavor()); map.put("vm.compMode", vmCompMode()); map.put("vm.bits", vmBits()); + map.put("vm.debug", vmDebug()); dump(map); return map; } @@ -103,6 +104,13 @@ public class VMProps implements Callable> { return System.getProperty("sun.arch.data.model"); } + /** + * @return debug level value extracted from the "java.vm.version" property. + */ + protected String vmDebug() { + return "" + System.getProperty("java.vm.version").toLowerCase().contains("debug"); + } + /** * Dumps the map to the file if the file name is given as the property. * This functionality could be helpful to know context in the real diff --git a/test/lib/jtreg/SkippedException.java b/test/lib/jtreg/SkippedException.java new file mode 100644 index 0000000000..ac1afa5d0a --- /dev/null +++ b/test/lib/jtreg/SkippedException.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jtreg; + +/** + * {@code SkippedException} is an exception treaded by jtreg as an indication + * of skipped status. + */ +public final class SkippedException extends RuntimeException { + public SkippedException(String s, Throwable t) { + super(s, t); + } + + public SkippedException(String s) { + super(s); + } +}