test/compiler/jsr292/ConcurrentClassLoadingTest.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff test/compiler/jsr292/ConcurrentClassLoadingTest.java
test/compiler/jsr292/ConcurrentClassLoadingTest.java
Print this page
rev 7259 : 8044186: Introduce a reproducible random generator
Reviewed-by: iignatyev
Contributed-by: sergei.kovalev@oracle.com
*** 1,7 ****
/*
! * Copyright (c) 2013, 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.
--- 1,7 ----
/*
! * Copyright (c) 2013, 2014, 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,44 ****
/**
* @test
* @bug 8022595
* @summary JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
! *
* @run main/othervm ConcurrentClassLoadingTest
*/
! import java.util.*;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
public class ConcurrentClassLoadingTest {
int numThreads = 0;
- long seed = 0;
CyclicBarrier l;
! Random rand;
public static void main(String[] args) throws Throwable {
ConcurrentClassLoadingTest test = new ConcurrentClassLoadingTest();
test.parseArgs(args);
test.run();
--- 23,47 ----
/**
* @test
* @bug 8022595
* @summary JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
! * @library /testlibrary
* @run main/othervm ConcurrentClassLoadingTest
*/
! import com.oracle.java.testlibrary.Utils;
! import java.util.ArrayList;
! import java.util.Arrays;
! import java.util.List;
! import java.util.Random;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
public class ConcurrentClassLoadingTest {
int numThreads = 0;
CyclicBarrier l;
! private static final Random rand = Utils.getRandomInstance();
public static void main(String[] args) throws Throwable {
ConcurrentClassLoadingTest test = new ConcurrentClassLoadingTest();
test.parseArgs(args);
test.run();
*** 47,59 ****
void parseArgs(String[] args) {
int i = 0;
while (i < args.length) {
String flag = args[i];
switch(flag) {
- case "-seed":
- seed = Long.parseLong(args[++i]);
- break;
case "-numThreads":
numThreads = Integer.parseInt(args[++i]);
break;
default:
throw new Error("Unknown flag: " + flag);
--- 50,59 ----
*** 65,83 ****
void init() {
if (numThreads == 0) {
numThreads = Runtime.getRuntime().availableProcessors();
}
- if (seed == 0) {
- seed = (new Random()).nextLong();
- }
- rand = new Random(seed);
-
l = new CyclicBarrier(numThreads + 1);
System.out.printf("Threads: %d\n", numThreads);
- System.out.printf("Seed: %d\n", seed);
}
final List<Loader> loaders = new ArrayList<>();
void prepare() {
--- 65,77 ----
*** 88,98 ****
for (int t = 0; t < numThreads; t++) {
List<String> sel = new ArrayList<>();
System.out.printf("Thread #%d:\n", t);
for (int i = 0; i < count; i++) {
! if (c.size() == 0) break;
int k = rand.nextInt(c.size());
String elem = c.remove(k);
sel.add(elem);
System.out.printf("\t%s\n", elem);
--- 82,94 ----
for (int t = 0; t < numThreads; t++) {
List<String> sel = new ArrayList<>();
System.out.printf("Thread #%d:\n", t);
for (int i = 0; i < count; i++) {
! if (c.isEmpty()) {
! break;
! }
int k = rand.nextInt(c.size());
String elem = c.remove(k);
sel.add(elem);
System.out.printf("\t%s\n", elem);
test/compiler/jsr292/ConcurrentClassLoadingTest.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File