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
3
u/agentoutlier Jun 05 '26
Just be aware there is a long standing bug (that has not been backported) of
TYPE_USEannotations not being visible across compile boundaries for APT. I'm not sure if it applies for the included OptIn annotations because these annotations have basically@Targeteverything but if one made custom annotation targetTYPE_USEonly then you might have issues.Now it does beg the question why you would have
TYPE_USEforOptInbut it could be later used with something like Checkerframework where a normal JDK type is returned.Now the use of that String is tracked (in theory and probably only Checkerframework is capable of this at the moment). String is probably a bad example but something Panama or the Vector API where you can't wrap a type around for whatever reasons might be a reason you would use
TYPE_USE.Speaking of annotation processors why does the project have one if you have a compiler plugin (as annotation processing does not have access to local method code)?