In the end, only the continuum from never changes, can change the behavior in the next version of the point, just to work on your platform. Even the specified behavior may be outdated and then deleted at some point, this is extremely rare (for example, Thread.destroy ). Therefore, whether you can rely on reasonable, but unspecified behavior, depends on how much you need a guarantee, how much effort you want to spend on coding around things in protecting / adding tests to ensure that future changes are detected, etc.
But yes, javadocs are the strongest guarantee you can get, everything else means moving to thinner ice.
Many projects rely on APIs that are not only undocumented, but are considered internal and supposedly implementation-specific. sun.misc.Unsafe is the prime example here, right up to the point where most of its features have been reinforced as proper JDK APIs in 9.
In the case of Collections.unmodifiableMap , if you want to really protect a secure publication, you can insert a store fence after it is created.
the8472
source share