Reputation: 89
I have a Kotlin object that has several fields exposed as static @JvmFields
. The parser that I use (which I cannot edit or change) looks for public static
fields and creates a configuration file based on those. Since the INSTANCE
field is public too, the parser generates a new category called instance
. Is there a way to add actual annotations to the INSTANCE
field? I would want to add the @Ingore annotation to it so the parser does not use the INSTANCE
field.
Upvotes: 3
Views: 329
Reputation: 148169
Basically, the answer is no, Kotlin does not allow annotating or altering the INSTANCE
fields in any other way. If you believe this could be a useful feature, please file a feature request at kotl.in/issue.
The valid solutions to this problem are:
Make the bytecode analyzing tool Kotlin-aware, i.e. make it behave correctly with Kotlin declarations. Though this requires non-trivial job to be done and does not seem possible in your case, it could be a valuable time investment.
Create another ad-hoc tool that post-processes the classes produced by the Kotlin compiler and adds the annotations you need, then include that tool into your build.
Upvotes: 1