Open babsingh opened 2 years ago
fyi @gacholio
There may be other instances outside of JVMTI.
The most readable way of fixing this is to use a local for the unwrapped object:
j9object_t obj = (NULL == ref) ? NULL : J9_JNI_UNWRAP_REFERENCE(ref);
if (NULL == obj) {
}
Another option would be to handle NULL refs in J9_JNI_UNWRAP_REFERENCE
. This would mean removing some existing NULL checks to avoid duplication. The downside is that the NULL checks are sometimes unnecessary (no native will ever be called with a wrapped NULL).
In JVMTI (and few instances outside JVMTI), there are occurrences of incomplete null checks for JNI-refs.
Example:
It's legal to have a JNI ref to NULL (think weak global ref).
A complete null check will be as follows: