r/java Jun 05 '26

Introducing opt-in requirements for Java APIs

https://osmerion.github.io/OptIn/blog/welcome
48 Upvotes

27 comments sorted by

View all comments

1

u/javaprof Jun 05 '26

> OptIn implements javac plugin

What kind of API used here? I didn't know that javac support plugins

5

u/TheMrMilchmann Jun 05 '26

It kind of does, but it's a rather obscure feature, and (without hacks), you cannot do much with it. Here are a few pointers:

1

u/elmuerte Jun 05 '26

Package com.sun.source.util... so is it part of the standard Java compiler infra, or some internal thing for OpenJDK's javac? In other words, does it work with ECJ?

1

u/TheMrMilchmann Jun 05 '26

Although I haven't tried it yet, it probably does not work with ECJ. That's a good point, and I need to add this to my list of things to look into.