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 JLS is not specific on how the null reference is implemented but it specifies its behavior. In other words, no there is no unspecified behavior. If you encounter a behavior other than specified in the JLS, it’s a bug.
Let me clarify this: you can use native code to trash certain structures to let the JVM crash but that has nothing to do with any Java behavior anymore. But on typical JVM implementation, the implementation of the null
behavior is the last thing you can disturb. Not, that it matters, what you trash if you override arbitrary memory from native code.
“Unspecified behavior” means that the specification itself lets there room for differences in the resulting behavior. This is not the case with Java.