ansman/kotshi

Generated annotation not found when compiling against Java 11

tompee26 opened this issue · 10 comments

When i updated my source/target compatibility to 11, javax.annotation.processing package is no longer there. Probably changed to javax.annotation only.

javax.annotation.processing.Generated is available since Java 9.

Which JDK are you using to compile your project and are you setting both the Java and Kotlin target version or only one of them?

I am using JDK 11. I am setting both java and kotlin.

Is this Android or just JVM?

This is on Android

Found this somewhere. Might be related: google/dagger#1339

Can you post the full build error?

I set this sample project up. Both with and without the javax.annotation dependency, there are compile errors.
https://github.com/tompee26/KotshiJava11Test

Sorry for the slow response, I'm still investigating. My preliminary findings are that the Android Gradle Plugin does something which makes it work for generated Java code but it does not work for the Kotlin code.

For now, to become unblocked, you can include the javax.annotation-api dependency. Another option is to add an option in Kotshi to disable the generation.

I will file an issue against the Android Gradle Plugin once I can confirm it is at fault.

@tompee26 Do you still see this issue?

So I've found the root cause of the issue which is that Android does not support Java 11 yet and you won't be able to target Java 11 when compiling. If you change to Java 8 then it'll work as expected.