RFR: 8263430: Uninitialized Method* variables after JDK-8233913
Coleen Phillimore
coleenp at openjdk.java.net
Thu Mar 11 14:24:17 UTC 2021
On Thu, 11 Mar 2021 09:43:52 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> 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.
Looks good.
src/hotspot/share/interpreter/linkResolver.cpp line 1153:
> 1151: // superinterface.method, which explicitly does not check shadowing
> 1152: Klass* resolved_klass = link_info.resolved_klass();
> 1153: Method* resolved_method = NULL;
Why would it complain about this one? resolved_method is going to get some value in the next 4 lines.
-------------
Marked as reviewed by coleenp (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/2936
More information about the hotspot-dev
mailing list