Does Kotlin support the annotations present in `or...
# spring
p
Does Kotlin support the annotations present in
org.springframework.lang
? The online Javadoc for the website does indicate that it does https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/lang/package-summary.html however, on Kotlin's own source file, it is not mentioned anywhere here: https://github.com/JetBrains/kotlin/blob/master/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.kt. I am confused, does Kotlin support it or not? And if so, how does it do so despite not being listed?
j
why would you expect Spring's annotations to be specifically recognized by the Kotlin compiler?
you understand there are thousands of annotations in Java and Kotlin libraries that are not listed here, right?
p
@JasonB I know Kotlin can recognize nullability annotations from Android, Lombok, FindBugs, Eclipse, and JetBrains. I presumed this was due to their efforts to interop with Java as best as they could. So, it stands to reason I could reasonably expect Spring annotations to be recognized by Kotlin, since Spring is a very popular framework
j
you know what, I misunderstood what annotations you were referring to
if you look at the source, though, you can see that they used the
javax.annotation
annotations to mark these, which Kotlin does recognize
the Spring annotations are also marked as deprecated since Spring 7 in favor of JSpecify
p
Oh neat, I see. Also, the current version of Spring is 6 right? That means the deprecation will only start after Spring 7 is made stable
k
That's correct, the current version is 6. Spring Framework 7.0.0 is scheduled to be released in November according to their website. Kotlin 2.2.0 will support JSpecify: https://youtrack.jetbrains.com/issue/KT-75371
👍 1
s
With Spring Framework 6, you need to configure the Kotlin compiler with
-Xjsr305=strict
since
org.springframework.lang
nullness annotations are meta-annotated with JSR 305 ones. With Spring Framework 7, JSpecify annotations will be recognized out-of-the-box.
👍 1