11/*
2- * Copyright (c) 2020, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2020, 2023 , 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
@@ -122,7 +122,9 @@ clear_breakpoint(JNIEnv *jni, const char *methodName,
122122 set_or_clear_breakpoint (jni, JNI_FALSE, methodName, klass, methods, method_count);
123123}
124124
125- static long tls_data = 0 ;
125+ static void * tls_data = 0 ;
126+ static const void * const tls_data1 = (const void *)0x111 ;
127+ static const void * const tls_data2 = (const void *)0x222 ;
126128
127129static void
128130breakpoint_hit1 (jvmtiEnv *jvmti, JNIEnv* jni,
@@ -149,14 +151,14 @@ breakpoint_hit1(jvmtiEnv *jvmti, JNIEnv* jni,
149151 // Test GetThreadLocalStorage for carrier thread.
150152 LOG (" Hit #1: Breakpoint: %s: checking GetThreadLocalStorage on carrier thread: %p\n " ,
151153 mname, (void *)cthread);
152- err = jvmti->GetThreadLocalStorage (cthread, ( void **) &tls_data);
154+ err = jvmti->GetThreadLocalStorage (cthread, &tls_data);
153155 check_jvmti_status (jni, err, " Breakpoint: error in JVMTI GetThreadLocalStorage" );
154156
155- if (tls_data != 111 ) {
157+ if (tls_data != tls_data1 ) {
156158 passed = JNI_FALSE;
157- LOG (" FAILED: GetThreadLocalStorage for carrier thread returned value: %d , expected 111 \n\n " , ( int ) tls_data);
159+ LOG (" FAILED: GetThreadLocalStorage for carrier thread returned value: %p , expected %p \n\n " , tls_data, tls_data1 );
158160 } else {
159- LOG (" GetThreadLocalStorage for carrier thread returned value %d as expected\n\n " , ( int ) tls_data);
161+ LOG (" GetThreadLocalStorage for carrier thread returned value %p as expected\n\n " , tls_data);
160162 }
161163 {
162164 jmethodID method = NULL ;
@@ -225,14 +227,14 @@ breakpoint_hit2(jvmtiEnv *jvmti, JNIEnv* jni,
225227 // Test GetThreadLocalStorage for virtual thread.
226228 LOG (" Hit #2: Breakpoint: %s: checking GetThreadLocalStorage on virtual thread: %p\n " ,
227229 mname, (void *)thread);
228- err = jvmti->GetThreadLocalStorage (thread, ( void **) &tls_data);
230+ err = jvmti->GetThreadLocalStorage (thread, &tls_data);
229231 check_jvmti_status (jni, err, " Breakpoint: error in JVMTI GetThreadLocalStorage" );
230232
231- if (tls_data != 222 ) {
233+ if (tls_data != tls_data2 ) {
232234 passed = JNI_FALSE;
233- LOG (" FAILED: GetThreadLocalStorage for virtual thread returned value: %d , expected 222 \n\n " , ( int ) tls_data);
235+ LOG (" FAILED: GetThreadLocalStorage for virtual thread returned value: %p , expected %p \n\n " , tls_data, tls_data2 );
234236 } else {
235- LOG (" GetThreadLocalStorage for virtual thread returned value %d as expected\n\n " , ( int ) tls_data);
237+ LOG (" GetThreadLocalStorage for virtual thread returned value %p as expected\n\n " , tls_data);
236238 }
237239}
238240
@@ -380,26 +382,26 @@ ThreadStart(jvmtiEnv *jvmti, JNIEnv* jni, jthread cthread) {
380382 return ; // avoid failures with JVMTI_ERROR_WRONG_PHASE
381383 }
382384 char * tname = get_thread_name (jvmti, jni, cthread);
383- long loc_tls_data = 0 ;
385+ void * loc_tls_data = 0 ;
384386 jvmtiError err;
385387
386388 RawMonitorLocker rml (jvmti, jni, event_mon);
387389
388390 LOG (" \n ThreadStart: cthread: %p, name: %s\n " , (void *)cthread, tname);
389391
390392 // Test SetThreadLocalStorage for carrier thread.
391- err = jvmti->SetThreadLocalStorage (cthread, ( void *) 111 );
393+ err = jvmti->SetThreadLocalStorage (cthread, tls_data1 );
392394 check_jvmti_status (jni, err, " ThreadStart: error in JVMTI SetThreadLocalStorage" );
393395
394396 // Test GetThreadLocalStorage for carrier thread.
395- err = jvmti->GetThreadLocalStorage (cthread, ( void **) &loc_tls_data);
397+ err = jvmti->GetThreadLocalStorage (cthread, &loc_tls_data);
396398 check_jvmti_status (jni, err, " ThreadStart: error in JVMTI GetThreadLocalStorage" );
397399
398- if (loc_tls_data != 111 ) {
400+ if (loc_tls_data != tls_data1 ) {
399401 passed = JNI_FALSE;
400- LOG (" ThreadStart: FAILED: GetThreadLocalStorage for carrier thread returned value: %d , expected 111 \n\n " , ( int ) loc_tls_data);
402+ LOG (" ThreadStart: FAILED: GetThreadLocalStorage for carrier thread returned value: %p , expected %p \n\n " , loc_tls_data, tls_data1 );
401403 } else {
402- LOG (" ThreadStart: GetThreadLocalStorage for carrier thread returned value %d as expected\n\n " , ( int ) loc_tls_data);
404+ LOG (" ThreadStart: GetThreadLocalStorage for carrier thread returned value %p as expected\n\n " , loc_tls_data);
403405 }
404406 deallocate (jvmti, jni, (void *)tname);
405407}
@@ -419,7 +421,7 @@ VirtualThreadStart(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread) {
419421 LOG (" \n VirtualThreadStart: %s thread: %p, name: %s\n " , virt, (void *)vthread, tname);
420422
421423 // Test SetThreadLocalStorage for virtual thread.
422- err = jvmti->SetThreadLocalStorage (vthread, ( void *) 222 );
424+ err = jvmti->SetThreadLocalStorage (vthread, tls_data2 );
423425 check_jvmti_status (jni, err, " VirtualThreadMount: error in JVMTI SetThreadLocalStorage" );
424426
425427 deallocate (jvmti, jni, (void *)tname);
@@ -463,7 +465,7 @@ VirtualThreadMount(jvmtiEnv *jvmti, ...) {
463465 print_frame_event_info (jvmti, jni, thread, method, " VirtualThreadMount" , vthread_mounted_count);
464466
465467 // Test SetThreadLocalStorage for virtual thread.
466- err = jvmti->SetThreadLocalStorage (thread, ( void *) 222 );
468+ err = jvmti->SetThreadLocalStorage (thread, tls_data2 );
467469 check_jvmti_status (jni, err, " VirtualThreadMount: error in JVMTI SetThreadLocalStorage" );
468470
469471 deallocate (jvmti, jni, (void *)mname);
0 commit comments