Skip to content

Commit

Permalink
8267796: vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/TestD…
Browse files Browse the repository at this point in the history
…escription.java fails with NoClassDefFoundError

Reviewed-by: mdoerr
Backport-of: f12200cd11c2b689618cde1902db941ee23fbf80
  • Loading branch information
Andrew Lu committed May 17, 2024
1 parent b6a5d0b commit ed7cbd8
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, 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
Expand All @@ -24,6 +24,7 @@
package nsk.jvmti.scenarios.hotswap.HS201;

import java.io.PrintStream;
import java.util.concurrent.CountDownLatch;

import nsk.share.*;
import nsk.share.jvmti.*;
Expand Down Expand Up @@ -73,14 +74,23 @@ public int runIt(String args[], PrintStream out) {
timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds

log.display(">>> starting tested thread");
Thread thread = new hs201t002Thread();
hs201t002Thread thread = new hs201t002Thread();

// testing sync
status = checkStatus(status);

setThread(thread);
thread.start();

// setThread(thread) enables JVMTI events, and that can only be done on a live thread,
// so wait until the thread has started.
try {
thread.ready.await();
} catch (InterruptedException e) {
}
setThread(thread);

thread.go.countDown();

while (currentStep != 4) {
try {
Thread.sleep(100);
Expand Down Expand Up @@ -114,6 +124,10 @@ public int runIt(String args[], PrintStream out) {
}

log.display("Thread suspended in a wrong moment. Retrying...");
for (int i = 0; i < stackTrace.length; i++) {
log.display("\t" + i + ". " + stackTrace[i]);
}
log.display("Retrying...");
resumeThread(thread);
suspendTry++;
// Test thread will be suspended at the top of the loop. Let it run for a while.
Expand All @@ -136,12 +150,20 @@ public int runIt(String args[], PrintStream out) {

class hs201t002Thread extends Thread {

CountDownLatch ready = new CountDownLatch(1);
CountDownLatch go = new CountDownLatch(1);

hs201t002Thread() {
setName("hs201t002Thread");
}

public void run() {
// run method
ready.countDown();
try {
go.await();
} catch (InterruptedException e) {
}
try {
throwException();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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
Expand Down Expand Up @@ -73,7 +73,7 @@
*
* @build ExecDriver
* @run main/othervm/native PropertyResolvingWrapper ExecDriver --java
* "-agentlib:hs201t002=pathToNewByteCode=./bin -waittime=5"
* nsk.jvmti.scenarios.hotswap.HS201.hs201t002
* -agentlib:hs201t002=pathToNewByteCode=./bin,-waittime=5,-verbose
* nsk.jvmti.scenarios.hotswap.HS201.hs201t002 -verbose
*/

Loading

0 comments on commit ed7cbd8

Please sign in to comment.