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;
4444static jobject objVal;
4545static 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+
4754void 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 {
0 commit comments