On Tue, 4 Feb 2025 18:18:31 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> Michael Strauß has updated the pull request incrementally with one >> additional commit since the last revision: >> >> move enum field to top > > modules/javafx.base/src/main/java/com/sun/javafx/PreviewFeature.java line 37: > >> 35: * has opted into preview features. >> 36: */ >> 37: public enum PreviewFeature { > > Why enum? > Maybe use a regular class with a public constructor should do it. > What do you think? The idea is to make it easy and obvious to use from preview code: PreviewFeature.MY_PREVIEW_FEATURE.checkEnabled(); In addition to that, any IDE can easily list all uses of an enum constant, which gives you an overview where APIs of a particular feature are located. After all, enums are just regular classes with singleton instances. By the way, preview features can't be individually enabled or disabled. The point of checking on a enum constant is to generate an appropriate error message (including the name of the feature) in case the user didn't enable preview features. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1359#discussion_r1941783408