While Kotlin already has a similar mechanism (which this project was heavily inspired by), there is no way to customize the annotations that require opt-in. Our verifier for Java correctly takes the Kotlin annotations into account, but they are not considered by the Kotlin compiler. To solve this, we should consider introducing a Kotlin compiler plugin that takes our annotations into account.
I prototyped this a while ago for the old Kotlin compiler. While it somewhat worked, it was not exactly a good experience as I had to essentially copy and rewrite all checks related to opt-ins. In K2, this is not possible yet due to https://youtrack.jetbrains.com/issue/KT-55028.
If this project gains any traction, I will try to reach out to JetBrains to see if we can maybe make the Kotlin compiler more flexible without rewriting the entire checks.
While Kotlin already has a similar mechanism (which this project was heavily inspired by), there is no way to customize the annotations that require opt-in. Our verifier for Java correctly takes the Kotlin annotations into account, but they are not considered by the Kotlin compiler. To solve this, we should consider introducing a Kotlin compiler plugin that takes our annotations into account.
I prototyped this a while ago for the old Kotlin compiler. While it somewhat worked, it was not exactly a good experience as I had to essentially copy and rewrite all checks related to opt-ins. In K2, this is not possible yet due to https://youtrack.jetbrains.com/issue/KT-55028.
If this project gains any traction, I will try to reach out to JetBrains to see if we can maybe make the Kotlin compiler more flexible without rewriting the entire checks.