RFR: JDK-8317502 Add asserts to check for non-null in ciInstance::java_lang_Class_klass

Tobias Hartmann thartmann at openjdk.org
Fri Oct 6 07:45:58 UTC 2023


On Wed, 4 Oct 2023 13:10:53 GMT, Damon Fenacci <dfenacci at openjdk.org> wrote:

> `ciInstance::java_lang_Class_klass` and `ciTypeArrayKlass::make_impl` could potentially return a `null` pointer (solely based on the code). A static code analyzer found out that in other places in the code this could potentially lead to a null pointer dereferencing. However we know that this will never happen: `java_lang_Class::as_Klass(get_oop())` cannot be null and neither can `Universe::typeArrayKlassObj(t)` (there is already an explicit assert in `typeArrayKlassObj`).
> 
> So, this change adds an assert in `ciInstance::java_lang_Class_klass` ensuring that `java_lang_Class::as_Klass(get_oop())` don't return `nullptr` (no assert in `ciTypeArrayKlass::make_impl` as `Universe::typeArrayKlassObj(t)`already includes one for `_typeArrayKlassObjs[t] != nullptr`).

Looks good to me too.

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

Marked as reviewed by thartmann (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16038#pullrequestreview-1661294510


More information about the hotspot-compiler-dev mailing list