I just learned that dereferencing null
in C and C++ can sometimes produce undefined results. This is very intriguing to me, like all bizarre programming behaviors
The behavior is defined in 15.12.4.4 Locate Method to Invoke:
Otherwise, an instance method is to be invoked and there is a target reference. If the target reference is null, a NullPointerException is thrown at this point. Otherwise, the target reference is said to refer to a target object and will be used as the value of the keyword this in the invoked method. The other four possibilities for the invocation mode are then considered.
Dereferencing null should throw a NullPointerException.