RFR: 8263430: Uninitialized Method* variables after JDK-8233913

Aleksey Shipilev shade at openjdk.java.net
Thu Mar 11 09:49:19 UTC 2021


SonarCloud instance reports problems like:
 The left operand of '==' is a garbage value

C2V_VMENTRY_NULL(jobject, getResolvedJavaMethod, (JNIEnv* env, jobject, jobject base, jlong offset))
  Method* method;
 ...
  if (method == NULL) { // <--- here
    JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected type: %s", JVMCIENV->klass_name(base_object)));
  }

I believe this is caused by refactoring in [JDK-8233913](https://bugs.openjdk.java.net/browse/JDK-8233913) that [replaced](https://hg.openjdk.java.net/jdk/jdk/rev/15936b142f86#l39.38) `methodHandle` with naked `Method*`. `methodHandle` is implicitly initialized to null, while naked variable is not. After reading the original changeset, I found two other places where the same thing happens.

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

Commit messages:
 - 8263430: Uninitialized Method* variables after JDK-8233913

Changes: https://git.openjdk.java.net/jdk/pull/2936/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2936&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263430
  Stats: 3 lines in 3 files changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2936.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2936/head:pull/2936

PR: https://git.openjdk.java.net/jdk/pull/2936


More information about the hotspot-dev mailing list