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

Damon Fenacci dfenacci at openjdk.org
Thu Oct 5 08:37:32 UTC 2023


`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`).

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

Commit messages:
 - JDK-8317502: remove ciTypeArrayKlass::make_impl assert as assert already present in Universe::typeArrayKlassObj
 - JDK-8317502: move assert to ciTypeArrayKlass::make_impl
 - JDK-8317502 Add asserts to check for non-null in ciInstance::java_lang_Class_klass and ciTypeArrayKlass::make

Changes: https://git.openjdk.org/jdk/pull/16038/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16038&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8317502
  Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/16038.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16038/head:pull/16038

PR: https://git.openjdk.org/jdk/pull/16038


More information about the hotspot-compiler-dev mailing list