vwithfield and ValueType.findWither
Paul Sandoz
paul.sandoz at oracle.com
Thu Jun 15 17:26:45 UTC 2017
> On 15 Jun 2017, at 02:56, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
>
>
> On 15/06/17 10:47, John Rose wrote:
>> My concern is for other kinds of code, outside the VCC, which uses
>> compositions containing withers to build values, using MH's.
> This seems to suggest something similar to where Paul was going, I think - that is, findWither should _NOT_ be the vector for creating new DVT from scratch. In other words, we have two use cases:
>
> 1) I want to make a new DVT
> 2) I want to tweak an existing DVT
>
> I think it is fair to say that (1) should go through the POJO - as this is an operation that is likely to occur at the 'boundaries' (outside of the magic Q-MH world).
>
> And if advanced clients need low level access to tweak DVT fields, they can do so with a _real_ wither MH (not the mock one we expose now), which maybe savior devs could access using privateLookupIn as Paul suggested.
>
If we resolve the host class accessibility issues i believe the findWither implementation can use vwithfield.
The approach of box, update a field with unsafe (stomping on final and possibly private) fields and then unbox, is effectively similar to vwithfield (the box cannot be directly observed, perhaps just the shadows flickering on the wall when introspecting the VM).
Currently findWither does not to throw an IllegalAccessException, so we could choose to go with that or decide to enforce it and require privayeLookupIn, separate from the implementation technique.
In either implementation technique we bypass any constraints on state may be associated with a constructor on the VCC.
Separately i think we should explore construction:
1) make a new DVT from a VCC constructor, by calling a VCC constructor and then unbox
2) make a new DVT from a VCC constructor, a DVT, a VCC field and it’s value, by extracting a state vector from the DVT, updating the state vector replacing one state element with that of the field value, calling the VCC constructor with the updated state vector, and then unbox.
Paul.
> What do you think?
>
> Maurizio
More information about the valhalla-dev
mailing list