On Wed, 23 Feb 2022 00:40:44 GMT, Joe Darcy <da...@openjdk.org> wrote:
>> This is an early review of changes to better model JVM access flags, that is >> "modifiers" like public, protected, etc. but explicitly at a VM level. >> >> Language level modifiers and JVM level access flags are closely related, but >> distinct. There are concepts that overlap in the two domains (public, >> private, etc.), others that only have a language-level modifier (sealed), >> and still others that only have an access flag (synthetic). >> >> The existing java.lang.reflect.Modifier class is inadequate to model these >> subtleties. For example, the bit positions used by access flags on different >> kinds of elements overlap (such as "volatile" for fields and "bridge" for >> methods. Just having a raw integer does not provide sufficient context to >> decode the corresponding language-level string. Methods like >> Modifier.methodModifiers() were introduced to cope with this situation. >> >> With additional modifiers and flags on the horizon with projects like >> Valhalla, addressing the existent modeling deficiency now ahead of time is >> reasonable before further strain is introduced. >> >> This PR in its current form is meant to give the overall shape of the API. >> It is missing implementations to map from, say, method modifiers to access >> flags, taking into account overlaps in bit positions. >> >> The CSR https://bugs.openjdk.java.net/browse/JDK-8281660 will be filled in >> once the API is further along. > > Joe Darcy has updated the pull request incrementally with one additional > commit since the last revision: > > Add mask to access flag functionality. I've pushed an initial version of functionality to map from an integer mask to a set of access flags based on location. I suspect this will be refined and changed a bit before the code goes back. Potential changes I see now: * an ANY_CLASS location allowing the union of the flags for CLASS and INNER_CLASS (or a method providing equivalent functionality) * simple maskToAccessFlags(int mask) method that worked if all the bit positions were unambiguous. @asotona , how does this API look for your use cases? I'll start wiring up the various accessFlag methods on java.lang.Class, java.lang.reflect.* etc. ------------- PR: https://git.openjdk.java.net/jdk/pull/7445