假设我的注释处理器的处理功能如下所示
override fun process(
annotations: MutableSet<out TypeElement>,
roundEnv: RoundEnvironment
): Boolean {
try {
roundEnv.getElementsAnnotatedWith(CustomAnnotation::class.java)
.mapNotNull {
if (it.kind != ElementKind.INTERFACE) {
printError(
"Only interfaces can be annotated with " +
MapperConfig::class.java.simpleName
)
null
} else {
it as TypeElement
}
}.forEach {
processMapperConfigInterface(it, roundEnv)
}
} catch (ex: Exception) {
messager.printError(ex.message!!)
}
return true
}
roundEnv.getElementsAnnotatedWith
返回没有任何 kotlin 类型信息的 java Elements,如何使用注释处理来获取正确的 kotlin 类型信息?