[lworld] RFR: 8281463: [lworld] VALUE / PRIMITIVE modifiers should be supported by reflection [v3]
Mandy Chung
mchung at openjdk.java.net
Tue Jun 7 19:38:50 UTC 2022
On Tue, 7 Jun 2022 19:07:10 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/Class.java line 1511:
>>
>>> 1509: * @param flag an {@link AccessFlag}
>>> 1510: */
>>> 1511: public boolean is(AccessFlag flag) {
>>
>> Is this API needed? We can do `Class.accessFlags().contains(flag)`. This discussion should belong to PR 7445 (see my comment in the `Modifier`).
>
> There are significant performance concerns. The current implementation of getModifers() is an intrinsic and all of the tests for modifiers are boolean operations against static constants.
> Doing a Set.contains against a set that is re-built every time getAccessFlags() is called is a non-starter.
> Many of the access flags have dedicated methods in j.l.Class, for example, isPublic, isStatic, etc.
> It would improve usability and performance to be able to check for an accessFlag in a simple direct operation.
> I'll keep this for the time being.
This new API requires discussion and also whether it needs to be performant. Can you bring this discussion to PR 7445.
`Class::isValue`, `Class::isIdentity` and `Class::isPrimitive` is performance-sensitive and the current implementation is performant checking against the modifiers. Is there a case that `Class::isXXX` cannot be used?
-------------
PR: https://git.openjdk.java.net/valhalla/pull/698
More information about the valhalla-dev
mailing list