Yao-Wen Mei
07/06/2022, 9:40 PM@SerialInfo
annotation on Java annotations:
we have a Kotlin library which is depend on our Java library and use some of the Java annotations. I want to use some of the Java annotations during Kotlin serialization process. In order to do this, I have to 1) add @SerialInfo
on the Java annotations, and 2) define an inner class Impl
inside of my Java annotation for the Kotlin complier plugin. The working code is like below:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@SerialInfo //<--------------------------------------------------------- Add this line
@kotlin.annotation.Target(allowedTargets = AnnotationTarget.PROPERTY)
public @interface ServerTimestamp {
final class Impl implements ServerTimestamp { // <--------------------- Add this block
@Override
public Class<? extends Annotation> annotationType() {
return (Class<? extends Annotation>) ServerTimestamp.class;
}
}
}
My question is will the complier plugin always looking for the Impl
inner class in the future? How stable this mechanism is going to be? Thank you~ephemient
07/06/2022, 11:09 PM