diff --git a/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java b/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java index 6c35c266829..9f1e4ea3a79 100644 --- a/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java +++ b/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java @@ -24,7 +24,7 @@ /* * @test - * @key nmt jcmd + * @key nmt jcmd randomness * @library /test/lib * @requires vm.bits == 64 * @modules java.base/jdk.internal.misc @@ -39,6 +39,7 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; public class HugeArenaTracking { @@ -60,7 +61,7 @@ public static void main(String args[]) throws Exception { output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=2KB, committed=2KB)"); - Random rand = new Random(); + Random rand = Utils.getRandomInstance(); // Allocate 2GB+ from arena long total = 0; diff --git a/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java b/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java index fb3238d2d67..7f322e64e7c 100644 --- a/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java +++ b/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, 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,7 +24,7 @@ /* * @test * @summary Stress test for malloc tracking - * @key nmt jcmd stress + * @key nmt jcmd stress randomness * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -39,6 +39,7 @@ import java.util.Random; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.Platform; +import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import sun.hotspot.WhiteBox; @@ -159,6 +160,7 @@ static class MallocMemory { } static class AllocThread extends Thread { + private final Random random = new Random(Utils.getRandomInstance().nextLong()); AllocThread() { this.setName("MallocThread"); this.start(); @@ -166,7 +168,6 @@ static class AllocThread extends Thread { // AllocThread only runs "Alloc" phase public void run() { - Random random = new Random(); // MallocStressTest.phase == TestPhase.alloc for (int loops = 0; loops < 100; loops++) { int r = random.nextInt(Integer.MAX_VALUE); @@ -201,7 +202,7 @@ public void run() { } static class ReleaseThread extends Thread { - private Random random = new Random(); + private final Random random = new Random(Utils.getRandomInstance().nextLong()); ReleaseThread() { this.setName("ReleaseThread"); this.start(); diff --git a/test/hotspot/jtreg/runtime/NMT/MallocTrackingVerify.java b/test/hotspot/jtreg/runtime/NMT/MallocTrackingVerify.java index 68b535dbc9b..269856db187 100644 --- a/test/hotspot/jtreg/runtime/NMT/MallocTrackingVerify.java +++ b/test/hotspot/jtreg/runtime/NMT/MallocTrackingVerify.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, 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,7 +25,7 @@ * @test * @bug 8054836 * @summary Test to verify correctness of malloc tracking - * @key nmt jcmd + * @key nmt jcmd randomness * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -41,6 +41,7 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; @@ -58,7 +59,7 @@ public static void main(String args[]) throws Exception { String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); - Random random = new Random(); + Random random = Utils.getRandomInstance(); // Allocate small amounts of memory with random pseudo call stack while (mallocd_total < MAX_ALLOC) { int size = random.nextInt(31) + 1; diff --git a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java index 2982bb6ab10..216646ccc93 100644 --- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java +++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * @summary SharedArchiveConsistency * @requires vm.cds * @library /test/lib diff --git a/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressApp.java b/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressApp.java index 636da040d6b..824c88be2da 100644 --- a/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressApp.java +++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, 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,6 +24,7 @@ import java.io.*; import java.util.*; +import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; // All strings in archived classes are shared @@ -43,7 +44,7 @@ static String get_shared_string1() { static void allocAlot() { try { - Random random = new Random(); + Random random = Utils.getRandomInstance(); for (int i = 0; i < 1024 * 1024; i++) { int len = random.nextInt(10000); arr = new int[len]; diff --git a/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressTest.java b/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressTest.java index 2d2cfff453a..326307480f9 100644 --- a/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressTest.java +++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, 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,15 +24,16 @@ /* * @test + * @key randomness * @summary * @requires vm.cds.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/appcds * @modules java.base/jdk.internal.misc * @modules java.management * jdk.jartool/sun.tools.jar - * @build sun.hotspot.WhiteBox + * @build sun.hotspot.WhiteBox jdk.test.lib.Utils * @compile GCStressApp.java - * @run driver ClassFileInstaller -jar gcstress.jar GCStressApp + * @run driver ClassFileInstaller -jar gcstress.jar GCStressApp jdk.test.lib.Utils * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox * @run main GCStressTest */