< prev index next >
test/hotspot/jtreg/vmTestbase/gc/gctests/gctest02/gctest02.java
Print this page
rev 59093 : [mq]: randomness-code_vmTestbase_gc
rev 59094 : imported patch randomness-keyword_vmTestbase_gc
rev 59095 : imported patch 8243430.00
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -23,11 +23,11 @@
//gctest02.java
/*
* @test
- * @key gc
+ * @key gc randomness
*
* @summary converted from VM Testbase gc/gctests/gctest02.
* VM Testbase keywords: [gc]
*
* @library /vmTestbase
@@ -38,10 +38,12 @@
package gc.gctests.gctest02;
import nsk.share.TestFailure;
import nsk.share.TestBug;
+import nsk.share.test.LocalRandom;
+
/* stress testing
create 16 memory evil threads requesting to allocate
the object of sizes from 8 to ( 2 ^ 19).
The live time of objects is random (0 ~ 1000).
Here we let the threads that reference the objects
@@ -53,24 +55,10 @@
class PopulationException extends Exception {
//this exception is used to signal that we've
//reached the end of the test
}
-//the LocalRandom class is used to isolate the pseudo-random
-//number generator from other parts of the system which might
-//silently be using it.
-//This is to make sure the tests are repeatable
-
-class LocalRandom {
- public static Random rGen = null;
-
- public static double random() {
- //should fail if rGen is not initialized
- return rGen.nextDouble();
- }
-}
-
class ThreadCount {
static int count= 0;
static synchronized void inc() { count++; }
static synchronized void dec() { count --; }
static synchronized int get() { return count; }
@@ -188,11 +176,10 @@
public class gctest02 {
public static void main(String args[] ) {
int bufsz = 8;
int peopleLimit = 1000;
- long randomSeed = System.currentTimeMillis();
Memevil me=null;
if (args.length > 0)
{
try
{
@@ -204,28 +191,13 @@
"Bad input to gctest02. Expected integer, got: ->"
+ args[0] + "<-", e);
}
}
- if (args.length == 2)
- {
- try
- {
- randomSeed = new Long(args[1]).longValue();
- }
- catch (NumberFormatException e)
- {
- throw new TestBug(
- "Bad input to gctest02. Expected long, got: ->"
- + args[0] + "<-", e);
- }
- }
Person.setPopulationLimit(peopleLimit);
- System.out.println("Seed value: " + randomSeed);
for (int ii=0; ii<40; ii++) {
bufsz = 8;
- LocalRandom.rGen = new Random(randomSeed);
Person.populationCount = 0;
Escaper you = new Escaper();
you.setName("Escaper");
ThreadCount.inc();
you.start();
< prev index next >