运行时注释在kotlin类中的一个字段上注释不正确

Kotlin编译器删除注释在字段上的Java运行时注释。注释如下所示。

@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @com.fasterxml.jackson.annotation.JacksonAnnotation public @interface JsonDeserialize 

我在一个领域宣布它,如下所示。

 @JsonSerialize(using = IDEncryptJsonSerializer::class) @JsonDeserialize(using = IDDecryptJsonDeserializer::class) @Column(name = "sku_id", nullable = false) open var skuId: Long = 0L 

注释不起作用。 然后,我用拳头看着班级文件,如下所示。

 @field:javax.persistence.Column public open var skuId: kotlin.Long 

JsonDeserialize和JsonSerialize注释被忽略。 这两个注释在Java中运行良好。 我的kotlin版本是1.1.4。 我该如何解决这个问题?

最后,我找到了导致这种现象的原因。 如果我在类构造函数中声明一个变量,那么注释该变量的注释可能无法正确编译。 由于kotlin编译器错误,一些注释可能会丢失。 然后,我移动类体中的变量。 一切正常。