test/compiler/jsr292/ConcurrentClassLoadingTest.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/test/compiler/jsr292/ConcurrentClassLoadingTest.java Tue Oct 28 19:58:59 2014
--- new/test/compiler/jsr292/ConcurrentClassLoadingTest.java Tue Oct 28 19:58:59 2014
*** 1,7 ****
--- 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 ****
--- 23,47 ----
/**
* @test
* @bug 8022595
* @summary JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
*
+ * @library /testlibrary
* @run main/othervm ConcurrentClassLoadingTest
*/
! import java.util.*;
! 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;
long seed = 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 ****
--- 50,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);
*** 65,83 ****
--- 65,77 ----
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() {
*** 88,98 ****
--- 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.size() == 0) break;
! 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