Re:OpenJDK mailing list: Null-safety and value types
by Someone on Tuesday February 07, 2023 @06:50PM
(#34701744)
It’s not only the checks, but allotted storage. An Integer that’s guaranteed not to be null can be stored in 4 bytes, a “Point” class with two “int” fields that is guaranteed to be not null can be loaded in a 64-bit register, etc. That makes it easier for the compiler to generate good code.
How so? Null checks are mostly “free” on the JVM, they trap on the zero page and get converted to an exception via a signal handler.