On Mon, 1 Aug 2022 17:37:36 GMT, ExE Boss <d...@openjdk.org> wrote: >> src/java.base/share/classes/java/lang/reflect/AccessFlag.java line 101: >> >>> 99: PUBLIC(Modifier.PUBLIC, true, >>> 100: Set.of(Location.CLASS, Location.FIELD, Location.METHOD, >>> 101: Location.INNER_CLASS)) { >> >> Is there another way to implement this that does not create 19 anonymous >> classes with a single overloaded method? > > Probably by creating and using shared instances of `java.util.Function` which > would also allow deduplicating the code.
> Is there another way to implement this that does not create 19 anonymous > classes with a single overloaded method? Overriding a method in an enum constant specific class is one way to implement constant-specific behavior. Textually, I thought it had the advantage of having the class file version specific behavior close to the latest version behavior. This could be refactored in various ways, such as having AccessFlag.locations(ClassFileFormatVersion cffv) start with a switch over the location which implemented the enum constant specific behavior. Or the set of parameters of the enum constructor could be augmented to cover more cases (empty until $VERSION, then $LOCATIONS, etc.), with constant-specific overrides just constants with unique patterns like STRICT. ------------- PR: https://git.openjdk.org/jdk/pull/9299