RFR: JDK-8205549 JDK-8205698 Support of flattened values in Unsafe

Paul Sandoz paul.sandoz at oracle.com
Fri Jun 29 21:52:22 UTC 2018



> On Jun 29, 2018, at 2:40 PM, Karen Kinnear <karen.kinnear at oracle.com> wrote:
> 
> IV. Immutability
>  Immutability is not just a good idea, …
>  Immutability is not the same as final - sorry - we actually count on it.

But i would argue it is similar to how final fields are treated in j.l.invoke and fields annotated with @Stable within java.base. Writing to such a field using Unsafe can break the VM integrity.


>  I highly recommend that even through unsafe - value types are immutable.
> 

Yes, from the byte code and public accessor methods the immutable property should be enforced, and the JIT should assume that integrity is enforced and optimize just like it does for @Stable fields. 

IMO all bets are off if you use unsafe generally to scribble on presumed read-only areas of memory :-)

Paul.




More information about the valhalla-dev mailing list