On Mon, 17 Apr 2023 13:45:05 GMT, Andrei Pangin <apan...@openjdk.org> wrote:
>> olivergillespie has refreshed the contents of this pull request, and >> previous commits have been removed. Incremental views are not available. The >> pull request now contains one commit: >> >> 8306075: Micro-optimize Enum.hashCode > > src/java.base/share/classes/java/lang/Enum.java line 181: > >> 179: */ >> 180: @Stable >> 181: private int hash; > > Should not we hide the field from reflection? > > I understand this is an implementation detail, however, it makes a big > difference that you add a private field to the *public* class that is *meant* > to be inherited by user classes. Although I'm not aware of a particular > example, this can be a breaking change for user code that does introspection > on enums. How is this a big difference? It's only discovered by getDeclaredFields. This can only be modified if users break jdk internal encapsulation in command line, which means they can change everything else. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13491#discussion_r1168738513