r/java • u/TheMrMilchmann • Jun 05 '26
Introducing opt-in requirements for Java APIs
https://osmerion.github.io/OptIn/blog/welcome
49
Upvotes
r/java • u/TheMrMilchmann • Jun 05 '26
View all comments
Show parent comment
4
u/TheMrMilchmann Jun 05 '26
There is actually quite a bit of javac configuration required because the verification partly happens in an annotation processor and partly in a javac plugin. It's documented here.
I strongly recommend using the Gradle plugin and (in the future) the Maven plugin which will to the work for you.
There can be multiple different opt-in requirements and you might not want to opt into all of them. The approach leaves the decision to library authors. For example, one might have a UI library with an
@ExperimentalTableApiand an@ExperimentalWebViewApi.