RFR: 8346132: fallbacklinker.cpp failed compilation due to unused variable

Calvin Cheung ccheung at openjdk.org
Wed Dec 18 07:40:36 UTC 2024


On Wed, 18 Dec 2024 05:21:55 GMT, Julian Waters <jwaters at openjdk.org> wrote:

>> src/java.base/share/native/libfallbackLinker/fallbackLinker.c line 168:
>> 
>>> 166:   // attach thread
>>> 167:   JNIEnv* env;
>>> 168:   (*VM)->AttachCurrentThreadAsDaemon(VM, (void**) &env, NULL);
>> 
>> I think the variable should be used! This code should be checking for a failed attach!
>
> Agree with David here. Generally I comment out unused code errors rather than outright remove them for this very reason. Also fallbackLinker doesn't seem to be a C++ file?

How about the following?


  jint result = (*VM)->AttachCurrentThreadAsDaemon(VM, (void**) &env, NULL);
  if (result != JNI_OK) {
    fprintf(stderr, "do_upcall trying to attach thread returned %d", result);
    return;
  }

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22799#discussion_r1889755164


More information about the core-libs-dev mailing list