Hi there, I have a custom annotation processor whi...
# kapt
m
Hi there, I have a custom annotation processor which looks for annotations attached to data class properties. Everything works fine for regular classes and primitives, but I get no annotations for a property of value class type. For example in this example:
Copy code
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class CustomAnnotation(
    val value: Boolean = true
)

@JvmInline
value class ValueStringClass(
    val value: String
)

data class InlineClassTest(
    @CustomAnnotation
    val stringValue: ValueStringClass,

    @CustomAnnotation
    val anotherStringValue: String
)
In my AP I can get the annotation for
anotherStringValue
of type
String
, but there is no annotation present for
stringValue
of type
ValueStringClass
which is a value class. When I debugged this, I don't see
stringValue
exposed as a regular property from the class. Here's what I get from my AP when getting the type elements and their annotation mirrors for the `InlineClassTest`:
Copy code
element 'stringValue', kind 'FIELD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'anotherStringValue', kind 'FIELD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'equals', kind 'METHOD', annotationMirrors '@java.lang.Override'
element 'hashCode', kind 'METHOD', annotationMirrors '@java.lang.Override'
element 'toString', kind 'METHOD', annotationMirrors '@org.jetbrains.annotations.NotNull,@java.lang.Override'
element '<init>', kind 'CONSTRUCTOR', annotationMirrors ''
element 'component2', kind 'METHOD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'getAnotherStringValue', kind 'METHOD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'getAnotherStringValue$annotations', kind 'METHOD', annotationMirrors '@com.doordash.protobuf.mapper.test.CustomAnnotation,@java.lang.Deprecated'
Unfortunately the code depends on 3rd party library which switched from using a wrapper around a String to a value class representing the string. Is there anything I can do to make the value class type to behave like a regular class from the AP perspective? Or something else to look for in the AP to get the annotation associated with that field in the data class? Thx!