On 12/01/18 04:33, Jason Greene wrote: > The internal @Stable facility provides the desired semantics and > precision, but it is heavily locked down, with privileged code > checks and export restrictions. Could this be made more accessible > (or perhaps a variant restricted to just final fields)? Informing > the compiler that a final field is a true lazy initialized constant, > with no store-to-final seems a pretty useful construct in general. I > can understand that the long term desire is that this shouldn’t be > necessary, and should be inferred [3], but at that point the > annotation is still useful as documentation and legacy > compatibility. If nothing else could it be allowed in non-privileged > code via some flag?
I don't know of any way to do that without compromising the integrity of the JVM. All that anybody would have to do to break the VM is to define a field as @Stable and then change the field. I suppose you could say that Unsafe is just as bad and people still are allowed to use it, but there's understandable reluctance any further to transform a safe runtime into an unsafe one. -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671