Skip to content

Commit 2a1e9be

Browse files
author
Alex Menkov
committed
8256364: vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002 failed with "assert(handle != __null) failed: JNI handle should not be null"
Reviewed-by: cjplummer, sspitsyn
1 parent f1d6e8d commit 2a1e9be

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -107,6 +107,7 @@ public int runIt(String argv[], PrintStream out) {
107107
class cm01t002Thread extends Thread {
108108
public Object startingMonitor = new Object();
109109
private Object waitingMonitor = new Object();
110+
private boolean timeToDie = false;
110111

111112
public cm01t002Thread(String name) {
112113
super(name);
@@ -128,7 +129,14 @@ public void run() {
128129

129130
// wait on monitor
130131
try {
131-
waitingMonitor.wait(cm01t002.timeout);
132+
long maxTime = System.currentTimeMillis() + cm01t002.timeout;
133+
while (!timeToDie) {
134+
long timeout = maxTime - System.currentTimeMillis();
135+
if (timeout <= 0) {
136+
break;
137+
}
138+
waitingMonitor.wait(timeout);
139+
}
132140
} catch (InterruptedException ignore) {
133141
// just finish
134142
}
@@ -144,6 +152,7 @@ public boolean checkReady() {
144152

145153
public void letFinish() {
146154
synchronized (waitingMonitor) {
155+
timeToDie = true;
147156
waitingMonitor.notify();
148157
}
149158
}

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002/cm01t002.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -99,6 +99,11 @@ static int prepare() {
9999
if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
100100
return NSK_FALSE;
101101

102+
if (thread == NULL) {
103+
nsk_lcomplain(__FILE__, __LINE__, "tested thread not found\n");
104+
return NSK_FALSE;
105+
}
106+
102107
/* get tested thread class */
103108
if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL))
104109
return NSK_FALSE;

0 commit comments

Comments
 (0)