[lworld] RFR: 8281463: [lworld] VALUE / PRIMITIVE modifiers should be supported by reflection [v2]

Roger Riggs rriggs at openjdk.java.net
Fri May 27 20:31:57 UTC 2022


On Fri, 27 May 2022 20:21:44 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Add support to java.lang.reflect.AccessFlag ACC_IDENTITY, ACC_VALUE, and ACC_PRIMITIVE.
>> Added corresponding flags to j.l.reflect.Modifier so the "source" of the AccessFlag is the Modifer mask.
>> Remove PERMITS_VALUE; moving the definition used by HotSpot to HotSpot code.
>> 
>> Add comments to java.l.reflect.Modifier suggesting use of AccessFlag instead and limitations.
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Restore AccessFlag SUPER

WRT AccessFlags...
The description of the "source" linkage should be expanded or possibly the feature removed.
My  prototyping for Valhalla involving adding identity, value, and primitive to the AccessFlag class.
These are new (in Valhalla) source keywords and ACC_* bits for classes.  
This suggests that the "source" value for them should be 'true', however, the condition and
AccessFlagTest require the matching name to be defined in Modifier.

That puts Modifier in a conflicted state, not able to correctly interpret the flags or
return an accurate result from `toString()` because the new flags overlap with existing
masks that apply to fields (and not classes).  Modifier has no information about whether the
value is from a class, method or field.  So regardless of the new AccessFlag API, Modifier
will need updates to mitigate the ambiguity.

My intention was to break the link with the existing j.u.Modifier and only support the new values in AccessFlag.
The "source" linkage to Modifier makes that difficult.
Perhaps separately, Modifier should be deprecated; however, it has wide usage.

-------------

PR: https://git.openjdk.java.net/valhalla/pull/698



More information about the valhalla-dev mailing list