[lworld] setAccessible change and VarHandle test update

mandy chung mandy.chung at oracle.com
Thu Mar 22 23:57:05 UTC 2018


This is good.  Thanks.   Field::set throws IAE if it's a value type.  No 
change is needed in the implementation.  I have made minor change to 
Field::setAccessible to drop the final modifier change.

Paul,

I finally got the chance to modify the VarHandleTestMethodHandleAccess* 
test.  Can you review this patch:
http://cr.openjdk.java.net/~mchung/valhalla/webrevs/lworld-reflection-varhandles-2/

Mandy

On 3/9/18 5:07 PM, John Rose wrote:
> I think the "final means final" discussion applies only to objects
> with identity and at least the potential of a changeable state
> A value has no identity, and no way to express a change in
> state.  Attempting to change the state of a value (e.g., by
> updating a field) must *always* result in a new value,
> not somehow "the old value but with a different value".
>
> Thus, Field.set is an impossible operation for a field of
> a value type.  Not an inaccessible or unsafe or unwise
> operation, an impossible one.
>
> (This is the deep reason we can and should move ourselves
> away from using "final" as a modifier for fields in value classes:
> The word "final" doesn't mean what you think it means there.
> It's not just that you are not allowed to assign to it; it is that
> it intrinsically cannot change without changing the enclosing
> value along with it.)
>
> A new operation Field.with or Field.update could make
> sense for values, but the access control rules for it are
> not yet clear.
>
> Bottom line:  Field.set must not "do something" on value class
> fields (fields of any type: ref/prim/val), under any circumstances
> (final or not, setAccessible or not).
>
> — John




More information about the valhalla-dev mailing list