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

Damon Fenacci dfenacci at openjdk.org
Fri Oct 6 11:03:25 UTC 2023


On Thu, 5 Oct 2023 17:47:13 GMT, Vladimir Kozlov <kvn 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`).
>
> Good.

Thank you very much for the reviews @vnkozlov @TobiHartmann.

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

PR Comment: https://git.openjdk.org/jdk/pull/16038#issuecomment-1750181693


More information about the hotspot-compiler-dev mailing list