Skip to content

Commit ff99698

Browse files
cost0muchPaul Hohensee
authored andcommitted
8300708: Some nsk jvmti tests fail with virtual thread wrapper due to jvmti missing some virtual thread support
Backport-of: fb0f2d25d218e64a86995478fd3ea10d619834d5
1 parent 3d90a9b commit ff99698

File tree

5 files changed

+82
-165
lines changed

5 files changed

+82
-165
lines changed

test/hotspot/jtreg/ProblemList-Virtual.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,8 @@ vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001/TestDescription.java
3636
####
3737
## Tests for functionality which currently is not supported for virtual threads
3838

39-
vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/TestDescription.java 8300708 generic-all
40-
vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/TestDescription.java 8300708 generic-all
41-
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/TestDescription.java 8300708 generic-all
42-
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/TestDescription.java 8300708 generic-all
43-
vmTestbase/nsk/jvmti/StopThread/stopthrd006/TestDescription.java 8300708 generic-all
44-
vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/TestDescription.java 8300708 generic-all
45-
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/TestDescription.java 8300708 generic-all
46-
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/TestDescription.java 8300708 generic-all
47-
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/TestDescription.java 8300708 generic-all
48-
vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/TestDescription.java 8300708 generic-all
49-
vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/TestDescription.java 8300708 generic-all
39+
vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/TestDescription.java 8348844 generic-all
40+
vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/TestDescription.java 8348844 generic-all
5041

5142
####
5243
## Test fails because it expects to find vthreads in GetAllThreads

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001.java

Lines changed: 17 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, 2025, 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
@@ -80,6 +80,10 @@ public double meth01() {
8080
float f = 0f;
8181
double d = 0;
8282
checkPoint();
83+
if (currThread.isVirtual()) {
84+
out.println("meth01: skipping results check for virtual thread");
85+
return d + f + 1; // SetLocal* should return OPAQUE_FRAME for a virtual thread
86+
}
8387
if (l != 22L || f != floatVal || d != doubleVal) {
8488
out.println("meth01: l =" + l + " f = " + f + " d = " + d);
8589
result = 2;
@@ -97,6 +101,10 @@ public void meth02(int step) {
97101
meth02(step - 1);
98102
} else {
99103
checkPoint();
104+
if (currThread.isVirtual()) {
105+
out.println("meth02: skipping results check for virtual thread");
106+
return; // SetLocal* should return OPAQUE_FRAME for a virtual thread
107+
}
100108
if (i1 != 1 || i2 != 1 || i3 != 1 || i4 != 1 || !i5) {
101109
out.println("meth02: i1 =" + i1 + " i2 = " + i2 +
102110
" i3 = " + i3 + " i4 = " + i4 + " i5 = " + i5);
@@ -109,6 +117,10 @@ public static void meth03() {
109117
setlocal001 ob1 = null;
110118
int[] ob2 = null;
111119
checkPoint();
120+
if (currThread.isVirtual()) {
121+
out.println("meth03: skipping results check for virtual thread");
122+
return; // SetLocalObject for obj1 and obj2 should return OPAQUE_FRAME for a virtual thread
123+
}
112124
if (ob1.val != 3 || ob2[2] != 8) {
113125
out.println("meth03: ob1.val =" + ob1.val + " ob2[2] = " + ob2[2]);
114126
result = 2;
@@ -118,6 +130,10 @@ public static void meth03() {
118130
public static void meth04(int i1, long l, short i2, double d,
119131
char i3, float f, byte i4, boolean b) {
120132
checkPoint();
133+
if (currThread.isVirtual()) {
134+
out.println("meth04: skipping results check for virtual thread");
135+
return; // SetLocal* should return OPAQUE_FRAME for a virtual thread
136+
}
121137
if (i1 != 1 || i2 != 2 || i3 != 3 || i4 != 4 ||
122138
l != 22L || f != floatVal || d != doubleVal || !b) {
123139
out.println("meth04: i1 =" + i1 + " i2 = " + i2 +

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp

Lines changed: 27 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, 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
@@ -44,13 +44,21 @@ static jdouble doubleVal;
4444
static jobject objVal;
4545
static jobject arrVal;
4646

47+
static void check_error(jvmtiError err, bool is_virtual, const char* func_id) {
48+
if (err != JVMTI_ERROR_NONE && !(is_virtual && err == JVMTI_ERROR_OPAQUE_FRAME)) {
49+
printf("(%s) unexpected error: %s (%d)\n", func_id, TranslateError(err), err);
50+
result = STATUS_FAILED;
51+
}
52+
}
53+
4754
void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env,
4855
jthread thr, jmethodID method, jlocation location) {
4956
jvmtiError err;
5057
jmethodID mid;
5158
jlocation loc;
5259
jint entryCount;
5360
jvmtiLocalVariableEntry *table = nullptr;
61+
bool is_virtual = env->IsVirtualThread(thr);
5462
int i;
5563

5664
err = jvmti_env->GetFrameLocation(thr, 1, &mid, &loc);
@@ -74,159 +82,87 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env,
7482
if (strcmp(table[i].name, "l") == 0) {
7583
err = jvmti_env->SetLocalLong(thr, 1,
7684
table[i].slot, longVal);
77-
if (err != JVMTI_ERROR_NONE) {
78-
printf("(SetLocalLong) unexpected error: %s (%d)\n",
79-
TranslateError(err), err);
80-
result = STATUS_FAILED;
81-
}
85+
check_error(err, is_virtual, "SetLocalLong");
8286
} else if (strcmp(table[i].name, "f") == 0) {
8387
err = jvmti_env->SetLocalFloat(thr, 1,
8488
table[i].slot, floatVal);
85-
if (err != JVMTI_ERROR_NONE) {
86-
printf("(SetLocalFloat) unexpected error: %s (%d)\n",
87-
TranslateError(err), err);
88-
result = STATUS_FAILED;
89-
}
89+
check_error(err, is_virtual, "SetLocalFloat");
9090
} else if (strcmp(table[i].name, "d") == 0) {
9191
err = jvmti_env->SetLocalDouble(thr, 1,
9292
table[i].slot, doubleVal);
93-
if (err != JVMTI_ERROR_NONE) {
94-
printf("(SetLocalDouble) unexpected error: %s (%d)\n",
95-
TranslateError(err), err);
96-
result = STATUS_FAILED;
97-
}
93+
check_error(err, is_virtual, "SetLocalDouble");
9894
}
9995
}
10096
} else if (mid == mid2) {
10197
for (i = 0; i < entryCount; i++) {
10298
if (strcmp(table[i].name, "i1") == 0) {
10399
err = jvmti_env->SetLocalInt(thr, 1,
104100
table[i].slot, 1);
105-
if (err != JVMTI_ERROR_NONE) {
106-
printf("(SetLocalInt#i1) unexpected error: %s (%d)\n",
107-
TranslateError(err), err);
108-
result = STATUS_FAILED;
109-
}
101+
check_error(err, is_virtual, "SetLocalInt#i1");
110102
} else if (strcmp(table[i].name, "i2") == 0) {
111103
err = jvmti_env->SetLocalInt(thr, 1,
112104
table[i].slot, 1);
113-
if (err != JVMTI_ERROR_NONE) {
114-
printf("(SetLocalInt#i2) unexpected error: %s (%d)\n",
115-
TranslateError(err), err);
116-
result = STATUS_FAILED;
117-
}
105+
check_error(err, is_virtual, "SetLocalInt#i2");
118106
} else if (strcmp(table[i].name, "i3") == 0) {
119107
err = jvmti_env->SetLocalInt(thr, 1,
120108
table[i].slot, 1);
121-
if (err != JVMTI_ERROR_NONE) {
122-
printf("(SetLocalInt#i3) unexpected error: %s (%d)\n",
123-
TranslateError(err), err);
124-
result = STATUS_FAILED;
125-
}
109+
check_error(err, is_virtual, "SetLocalInt#i3");
126110
} else if (strcmp(table[i].name, "i4") == 0) {
127111
err = jvmti_env->SetLocalInt(thr, 1,
128112
table[i].slot, 1);
129-
if (err != JVMTI_ERROR_NONE) {
130-
printf("(SetLocalInt#i4) unexpected error: %s (%d)\n",
131-
TranslateError(err), err);
132-
result = STATUS_FAILED;
133-
}
113+
check_error(err, is_virtual, "SetLocalInt#i4");
134114
} else if (strcmp(table[i].name, "i5") == 0) {
135115
err = jvmti_env->SetLocalInt(thr, 1,
136116
table[i].slot, 1);
137-
if (err != JVMTI_ERROR_NONE) {
138-
printf("(SetLocalInt#i5) unexpected error: %s (%d)\n",
139-
TranslateError(err), err);
140-
result = STATUS_FAILED;
141-
}
117+
check_error(err, is_virtual, "SetLocalInt#i5");
142118
}
143119
}
144120
} else if (mid == mid3) {
145121
for (i = 0; i < entryCount; i++) {
146122
if (strcmp(table[i].name, "ob1") == 0) {
147123
err = jvmti_env->SetLocalObject(thr, 1,
148124
table[i].slot, objVal);
149-
if (err != JVMTI_ERROR_NONE) {
150-
printf("(SetLocalObject#ob1) unexpected error: %s (%d)\n",
151-
TranslateError(err), err);
152-
result = STATUS_FAILED;
153-
}
125+
check_error(err, is_virtual, "SetLocalObject#ob1");
154126
} else if (strcmp(table[i].name, "ob2") == 0) {
155127
err = jvmti_env->SetLocalObject(thr, 1,
156128
table[i].slot, arrVal);
157-
if (err != JVMTI_ERROR_NONE) {
158-
printf("(SetLocalObject#ob2) unexpected error: %s (%d)\n",
159-
TranslateError(err), err);
160-
result = STATUS_FAILED;
161-
}
129+
check_error(err, is_virtual, "SetLocalObject#ob2");
162130
}
163131
}
164132
} else if (mid == mid4) {
165133
for (i = 0; i < entryCount; i++) {
166134
if (strcmp(table[i].name, "i1") == 0) {
167135
err = jvmti_env->SetLocalInt(thr, 1,
168136
table[i].slot, 1);
169-
if (err != JVMTI_ERROR_NONE) {
170-
printf("(SetLocalInt#i1,param) unexpected error: %s (%d)\n",
171-
TranslateError(err), err);
172-
result = STATUS_FAILED;
173-
}
137+
check_error(err, is_virtual, "SetLocalInt#i1,param");
174138
} else if (strcmp(table[i].name, "i2") == 0) {
175139
err = jvmti_env->SetLocalInt(thr, 1,
176140
table[i].slot, 2);
177-
if (err != JVMTI_ERROR_NONE) {
178-
printf("(SetLocalInt#i2,param) unexpected error: %s (%d)\n",
179-
TranslateError(err), err);
180-
result = STATUS_FAILED;
181-
}
141+
check_error(err, is_virtual, "SetLocalInt#i2,param");
182142
} else if (strcmp(table[i].name, "i3") == 0) {
183143
err = jvmti_env->SetLocalInt(thr, 1,
184144
table[i].slot, 3);
185-
if (err != JVMTI_ERROR_NONE) {
186-
printf("(SetLocalInt#i3,param) unexpected error: %s (%d)\n",
187-
TranslateError(err), err);
188-
result = STATUS_FAILED;
189-
}
145+
check_error(err, is_virtual, "SetLocalInt#i3,param");
190146
} else if (strcmp(table[i].name, "i4") == 0) {
191147
err = jvmti_env->SetLocalInt(thr, 1,
192148
table[i].slot, 4);
193-
if (err != JVMTI_ERROR_NONE) {
194-
printf("(SetLocalInt#i4,param) unexpected error: %s (%d)\n",
195-
TranslateError(err), err);
196-
result = STATUS_FAILED;
197-
}
149+
check_error(err, is_virtual, "SetLocalInt#i4,param");
198150
} else if (strcmp(table[i].name, "b") == 0) {
199151
err = jvmti_env->SetLocalInt(thr, 1,
200152
table[i].slot, JNI_TRUE);
201-
if (err != JVMTI_ERROR_NONE) {
202-
printf("(SetLocalInt#b,param) unexpected error: %s (%d)\n",
203-
TranslateError(err), err);
204-
result = STATUS_FAILED;
205-
}
153+
check_error(err, is_virtual, "SetLocalInt#b,param");
206154
} else if (strcmp(table[i].name, "l") == 0) {
207155
err = jvmti_env->SetLocalLong(thr, 1,
208156
table[i].slot, longVal);
209-
if (err != JVMTI_ERROR_NONE) {
210-
printf("(SetLocalLong,param) unexpected error: %s (%d)\n",
211-
TranslateError(err), err);
212-
result = STATUS_FAILED;
213-
}
157+
check_error(err, is_virtual, "SetLocalLong,param");
214158
} else if (strcmp(table[i].name, "f") == 0) {
215159
err = jvmti_env->SetLocalFloat(thr, 1,
216160
table[i].slot, floatVal);
217-
if (err != JVMTI_ERROR_NONE) {
218-
printf("(SetLocalFloat,param) unexpected error: %s (%d)\n",
219-
TranslateError(err), err);
220-
result = STATUS_FAILED;
221-
}
161+
check_error(err, is_virtual, "SetLocalFloat,param");
222162
} else if (strcmp(table[i].name, "d") == 0) {
223163
err = jvmti_env->SetLocalDouble(thr, 1,
224164
table[i].slot, doubleVal);
225-
if (err != JVMTI_ERROR_NONE) {
226-
printf("(SetLocalDouble,param) unexpected error: %s (%d)\n",
227-
TranslateError(err), err);
228-
result = STATUS_FAILED;
229-
}
165+
check_error(err, is_virtual, "SetLocalDouble,param");
230166
}
231167
}
232168
} else {

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, 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
@@ -40,13 +40,23 @@ static jvmtiEventCallbacks callbacks;
4040
static jint result = PASSED;
4141
static jboolean printdump = JNI_FALSE;
4242

43+
static void check_error(jvmtiError err, bool is_virtual, char* var_name) {
44+
if (err != JVMTI_ERROR_INVALID_SLOT && !(is_virtual && err == JVMTI_ERROR_OPAQUE_FRAME)) {
45+
printf("(%s) ", var_name);
46+
printf("Error expected: JVMTI_ERROR_INVALID_SLOT or JVMTI_ERROR_OPAQUE_FRAME,\n");
47+
printf("\t actual: %s (%d)\n", TranslateError(err), err);
48+
result = STATUS_FAILED;
49+
}
50+
}
51+
4352
void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env,
4453
jthread thr, jmethodID method, jlocation location) {
4554
jvmtiError err;
4655
jmethodID mid;
4756
jlocation loc;
4857
jint entryCount;
4958
jvmtiLocalVariableEntry *table;
59+
bool is_virtual = env->IsVirtualThread(thr);
5060
int i;
5161

5262
err = jvmti_env->GetFrameLocation(thr, 1, &mid, &loc);
@@ -71,51 +81,28 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env,
7181
printf(">>> checking on invalid slot ...\n");
7282
}
7383
for (i = 0; i < entryCount; i++) {
84+
char* var_name = table[i].name;
85+
7486
if (strcmp(table[i].name, "o") == 0) {
7587
err = jvmti_env->SetLocalObject(thr, 1,
7688
INV_SLOT, (jobject)thr);
77-
if (err != JVMTI_ERROR_INVALID_SLOT) {
78-
printf("(%s) ", table[i].name);
79-
printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n");
80-
printf("\t actual: %s (%d)\n", TranslateError(err), err);
81-
result = STATUS_FAILED;
82-
}
89+
check_error(err, is_virtual, var_name);
8390
} else if (strcmp(table[i].name, "i") == 0) {
8491
err = jvmti_env->SetLocalInt(thr, 1,
8592
INV_SLOT, (jint)0);
86-
if (err != JVMTI_ERROR_INVALID_SLOT) {
87-
printf("(%s) ", table[i].name);
88-
printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n");
89-
printf("\t actual: %s (%d)\n", TranslateError(err), err);
90-
result = STATUS_FAILED;
91-
}
93+
check_error(err, is_virtual, var_name);
9294
} else if (strcmp(table[i].name, "l") == 0) {
9395
err = jvmti_env->SetLocalLong(thr, 1,
9496
INV_SLOT, (jlong)0);
95-
if (err != JVMTI_ERROR_INVALID_SLOT) {
96-
printf("(%s) ", table[i].name);
97-
printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n");
98-
printf("\t actual: %s (%d)\n", TranslateError(err), err);
99-
result = STATUS_FAILED;
100-
}
97+
check_error(err, is_virtual, var_name);
10198
} else if (strcmp(table[i].name, "f") == 0) {
10299
err = jvmti_env->SetLocalFloat(thr, 1,
103100
INV_SLOT, (jfloat)0);
104-
if (err != JVMTI_ERROR_INVALID_SLOT) {
105-
printf("(%s) ", table[i].name);
106-
printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n");
107-
printf("\t actual: %s (%d)\n", TranslateError(err), err);
108-
result = STATUS_FAILED;
109-
}
101+
check_error(err, is_virtual, var_name);
110102
} else if (strcmp(table[i].name, "d") == 0) {
111103
err = jvmti_env->SetLocalDouble(thr, 1,
112104
INV_SLOT, (jdouble)0);
113-
if (err != JVMTI_ERROR_INVALID_SLOT) {
114-
printf("(%s) ", table[i].name);
115-
printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n");
116-
printf("\t actual: %s (%d)\n", TranslateError(err), err);
117-
result = STATUS_FAILED;
118-
}
105+
check_error(err, is_virtual, var_name);
119106
}
120107
}
121108

0 commit comments

Comments
 (0)