Thread
#serialization
    Yao-Wen Mei

    Yao-Wen Mei

    2 months ago
    Hello, a question on use
    @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~
    e

    ephemient

    2 months ago
    I expect it should be stable since future compiler plugin versions should still work with libraries compiled in the past. but since you're not using the compiler plugin itself but are trying to reproduce its effects, I don't think it can be guaranteed that you haven't missed anything that it might additionally depend on in the future