< prev index next >
test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java
Print this page
*** 27,37 ****
* @summary converted from VM Testbase metaspace/stressDictionary.
* VM Testbase keywords: [nonconcurrent, javac]
*
* @library /vmTestbase /test/lib
* @run driver jdk.test.lib.FileInstaller . .
! * @run main/othervm metaspace.stressDictionary.StressDictionary -stressTime 30
*/
package metaspace.stressDictionary;
import java.util.*;
--- 27,37 ----
* @summary converted from VM Testbase metaspace/stressDictionary.
* VM Testbase keywords: [nonconcurrent, javac]
*
* @library /vmTestbase /test/lib
* @run driver jdk.test.lib.FileInstaller . .
! * @run main/othervm/timeout=300 metaspace.stressDictionary.StressDictionary -stressTime 30
*/
package metaspace.stressDictionary;
import java.util.*;
*** 121,135 ****
}
for (int i = 0; i < NUMBER_OF_NOT_CORRUPTING_THREADS; i++) {
tasks.add(this.new RegularWorker());
}
ExecutorService executorService = Executors.newCachedThreadPool();
try {
! executorService.invokeAll(tasks);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private byte[] generateAndCompile() {
Map<String, CharSequence> sources = new HashMap<String, CharSequence>();
String className = "MyClass" + classesCounter.incrementAndGet();
--- 121,178 ----
}
for (int i = 0; i < NUMBER_OF_NOT_CORRUPTING_THREADS; i++) {
tasks.add(this.new RegularWorker());
}
ExecutorService executorService = Executors.newCachedThreadPool();
+ List<Future<Object>> results = null;
try {
! results = executorService.invokeAll(tasks);
} catch (InterruptedException e) {
e.printStackTrace();
}
+
+ int act_results = results.size();
+ int exp_results = NUMBER_OF_CORRUPTING_THREADS +
+ NUMBER_OF_NOT_CORRUPTING_THREADS;
+ if (act_results == exp_results) {
+ System.out.println("INFO: There are " + act_results + " results.");
+ } else {
+ throw new RuntimeException("Wrong # of results from invokeAll(); "
+ + "exp_results=" + exp_results + "; "
+ + "act_results=" + act_results + ".");
+ }
+
+ int cancelled_cnt = 0;
+ int not_done_cnt = 0;
+ for (int i = 0; i < act_results; i++) {
+ if (!results.get(i).isDone()) {
+ not_done_cnt++;
+ System.err.println("ERROR: task #" + i + " is not done.");
+ }
+ if (results.get(i).isCancelled()) {
+ cancelled_cnt++;
+ System.err.println("ERROR: task #" + i + " was canceled.");
+ }
+ }
+
+ if (cancelled_cnt == 0) {
+ System.out.println("INFO: no tasks were cancelled.");
+ }
+ if (not_done_cnt == 0) {
+ System.out.println("INFO: all tasks are done.");
+ }
+ if (cancelled_cnt != 0 && not_done_cnt != 0) {
+ throw new RuntimeException(cancelled_cnt
+ + " tasks were cancelled and "
+ + not_done_cnt
+ + " tasks are not done.");
+ } else if (cancelled_cnt != 0) {
+ throw new RuntimeException(cancelled_cnt
+ + " tasks were cancelled.");
+ } else if (not_done_cnt != 0) {
+ throw new RuntimeException(not_done_cnt + " tasks are not done.");
+ }
}
private byte[] generateAndCompile() {
Map<String, CharSequence> sources = new HashMap<String, CharSequence>();
String className = "MyClass" + classesCounter.incrementAndGet();
< prev index next >