juancho
10/28/2018, 6:36 PM@MyAnnotation
internal class Car
So I thought using Kotlin Reflection I would be able to get this information but no luck.
Any clues on how to do it?diesieben07
10/29/2018, 12:05 PM@Metadata
annotation from whatever source you have for your kotlin class. Once you have that, you can use kotlinx-metadata-jvm (https://github.com/JetBrains/kotlin/tree/master/libraries/kotlinx-metadata/jvm) to parse this metadata. Where the metadata comes from does not matter. It can be from an annotation read at runtime or in an annotation processor.juancho
10/29/2018, 4:47 PMvalues.forEach { value ->
when(value.fst.name.toString()) {
"mv" -> metadataVersion = (value.snd.value as List<Attribute.Constant>).map { it.value.toString().toInt() }.toIntArray()
"bv" -> bytecodeVersion = (value.snd.value as List<Attribute.Constant>).map { it.value.toString().toInt() }.toIntArray()
"k" -> kind = value.snd.value.toString().toInt()
"d1" -> data1 = (value.snd.value as List<Attribute.Constant>).map { it.value.toString() }.toTypedArray()
"d2" -> data2 = (value.snd.value as List<Attribute.Constant>).map { it.value.toString() }.toTypedArray()
}
}
diesieben07
10/29/2018, 4:52 PMAnnotationMirror
gives you a map of annotation values, where each one is an AnnotationValue
instance with a getValue
method. That one would return a List<Int>
for an int array, for example.juancho
10/29/2018, 7:20 PMdiesieben07
10/29/2018, 7:26 PMjuancho
10/29/2018, 9:01 PMoverride fun process(annotations: MutableSet<out TypeElement>, roundEnv: RoundEnvironment): Boolean {
roundEnv.getElementsAnnotatedWith(AutoDsl::class.java).forEach { classElement ->
diesieben07
10/29/2018, 9:19 PMjuancho
11/03/2018, 1:49 AM