On Thu, 13 Feb 2025 18:41:21 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> This is only done at compilation time, not at runtime. JEP 12 elaborates on 
>> this:
>> 
>>> --enable-preview itself does not take a version number because it would be 
>>> easy to misinterpret. For example, on JDK 18, the (hypothetical) flag 
>>> --enable-preview 19 would appear to suggest support for the preview 
>>> features of JDK 19, but those features are not known at the time of JDK 
>>> 18's release.
>
> Yeah, that's what I came to realize as well. So our property should remain 
> boolean.
> 
> The only other thing I could think of is for us to provide a new utility 
> method (in some class in javafx.base) that an application must call to 
> register the version of JavaFX API that are compiling against. For example, 
> imagine a `java.javafx.util.PreviewFeatures` class with the following method:
> 
> 
>     public void setVersion(int featureVersion) {}
> 
> 
> An application would need to call `PreviewFeatures.setVersion(25)` to use 
> JavaFX preview features from JavaFX 25. That method would unlock preview 
> features only if the version passed in matches the runtime feature version. 
> This would be in addition to the boolean system property.
> 
> The question is whether it is worth the additional complexity (not for us to 
> implement, that's trivial unless I'm missing something), but rather than 
> documentation and burden on the app developer using a preview feature. The 
> docs for each new preview feature would need to link to the PreviewFeatures 
> utility class to describe how to unlock the features. On the plus side, it 
> would provide a common place to document how to unlock preview features -- 
> "call this method from the application and set that system property on the 
> command line when running the app".

I wouldn't be in favor of requiring application developers to call a method to 
unlock a preview API. It seems a bit too cumbersome and intrusive to me, since 
it requires you to embed build information into your source code. I've also 
never seen this in other libraries or frameworks.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1359#discussion_r1955264014

Reply via email to