将包级别的Java注释转换为Kotlin

时间:2018-11-29 21:30:05

标签: java kotlin

是否可以将包级别的Java注释转换为Kotlin?

Java注释(MyAnnotation.java):

package com.myexample.annotation;

@Retention(RUNTIME) @Target(PACKAGE)
public @interface MyAnnotation {

}

注释的应用(package-info.java)

@MyAnnotation
package com.myexample

以下内容似乎不起作用(尽管确实可以编译)-我的注释处理器未检测到com.myexample软件包中的任何类:

MyAnnotation.kt

package com.myexample.annotation

@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FILE])
@Retention(AnnotationRetention.SOURCE)
annotation class MyAnnotation

package-info.kt

@file:MyAnnotation
package com.myexample

import com.myexample.annotation.MyAnnotation

1 个答案:

答案 0 :(得分:1)

否,当前不可能。您只需将package-info.java保留为Java文件即可。

相关问题