Merge
This commit is contained in:
commit
7f623d813a
@ -174,6 +174,23 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
|
|||||||
return JNI_OK;
|
return JNI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL
|
||||||
|
Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t003_hs203t003_isSuspended(JNIEnv * jni,
|
||||||
|
jclass clas,
|
||||||
|
jthread thread) {
|
||||||
|
jboolean retvalue;
|
||||||
|
jint state;
|
||||||
|
retvalue = JNI_FALSE;
|
||||||
|
if ( ! NSK_JVMTI_VERIFY( NSK_CPP_STUB3(GetThreadState, jvmti, thread, &state) ) ) {
|
||||||
|
nsk_printf(" Agent :: Error while getting thread state.\n");
|
||||||
|
nsk_jvmti_agentFailed();
|
||||||
|
} else {
|
||||||
|
if ( state & JVMTI_THREAD_STATE_SUSPENDED) {
|
||||||
|
retvalue = JNI_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retvalue;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t003_hs203t003_popThreadFrame(JNIEnv * jni,
|
Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t003_hs203t003_popThreadFrame(JNIEnv * jni,
|
||||||
|
@ -62,7 +62,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
public class hs203t003 extends RedefineAgent {
|
public class hs203t003 extends RedefineAgent {
|
||||||
|
|
||||||
public native boolean popThreadFrame(Thread thread);
|
public native boolean popThreadFrame(Thread thread);
|
||||||
public native boolean resumeThread(Thread thread);
|
public native boolean isSuspended(Thread thread);
|
||||||
|
public native boolean resumeThread(Thread thread);
|
||||||
|
|
||||||
|
|
||||||
public hs203t003(String[] arg) {
|
public hs203t003(String[] arg) {
|
||||||
@ -82,10 +83,10 @@ public class hs203t003 extends RedefineAgent {
|
|||||||
MyThread mt = new MyThread();
|
MyThread mt = new MyThread();
|
||||||
try {
|
try {
|
||||||
mt.start();
|
mt.start();
|
||||||
// check if we can can pop the thread.
|
// Check if we can can pop the thread.
|
||||||
// we can not do redefine/pop frame on run method.
|
// We can not do redefine/pop frame on run method.
|
||||||
while (!MyThread.resume.get());
|
while (!MyThread.resume.get());
|
||||||
// sleep for some few secs to get redefined.
|
// Sleep for some few secs to get redefined.
|
||||||
while (!isRedefined()) {
|
while (!isRedefined()) {
|
||||||
if (!agentStatus()) {
|
if (!agentStatus()) {
|
||||||
System.out.println("Failed to redefine class");
|
System.out.println("Failed to redefine class");
|
||||||
@ -93,10 +94,26 @@ public class hs203t003 extends RedefineAgent {
|
|||||||
}
|
}
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
popThreadFrame(mt); // pop the frame.
|
// Wait for the thread to be suspended.
|
||||||
resumeThread(mt); // resume the thread.
|
while (!isSuspended(mt)) {
|
||||||
|
if (!agentStatus()) {
|
||||||
|
System.out.println("Failed to suspend thread");
|
||||||
|
return passed;
|
||||||
|
}
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
// Pop the frame.
|
||||||
|
if (!popThreadFrame(mt)) {
|
||||||
|
System.out.println("Failed to pop a frame = "
|
||||||
|
+ mt.threadState);
|
||||||
|
}
|
||||||
|
// Resume the thread.
|
||||||
|
if(!resumeThread(mt)) {
|
||||||
|
System.out.println("Failed to resume the thread = "
|
||||||
|
+ mt.threadState);
|
||||||
|
}
|
||||||
|
// Wait till the other thread completes its execution.
|
||||||
mt.join();
|
mt.join();
|
||||||
// wait till the other thread completes its execution.
|
|
||||||
System.out.println("Thread state after popping/redefining = "
|
System.out.println("Thread state after popping/redefining = "
|
||||||
+ mt.threadState);
|
+ mt.threadState);
|
||||||
} catch(Exception ie) {
|
} catch(Exception ie) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user