Add Kotlin nullable type support for `AnnotatedService` arguments
See original GitHub issueCurrently, AnnotatedService requires @Nullable annotations(or Optional) to allow null values for method parameters even when it’s used with Kotlin which offers nice null-safety with nullable types.
Example:
@Get("/foo")
fun foo(@Nullable @Param("bar") bar: String?): HttpResponse {
// ...
}
Even though Kotlin nullable types(?), when compiled to java code, is attached @org.jetbrains.annotations.Nullable annotations, its retention policy is CLASS, which makes it invisible at Java Runtime.
kotlin-reflect seems to be the best bet to make this work.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Nullability in Java and Kotlin
This guide covers support for nullable types in Kotlin, how Kotlin treats nullable annotations from Java, and more.
Read more >Nullable types in kotlin annotation processor - Stack Overflow
Type annotations can target type of anything: type of local variable ... won't work at all times (such as in case of nested...
Read more >Add nullability annotations also to generic type variables and ...
I'd like to wait for feedback from the Kotlin community, e.g. Remove @Nullable annotation from ResultQuery.fetchSingleInto(Class) and Record.into(Class) ...
Read more >Improve code inspection with annotations - Android Developers
Add @Nullable and @NonNull annotations to check the nullness of a given variable, parameter, or return value. The @Nullable annotation indicates a variable, ......
Read more >@Nullable and @NotNull | IntelliJ IDEA Documentation
When you compile your project, the IDE adds assertions to all methods and parameters annotated with the @NotNull annotation. The assertions will ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The values of
@Metadataseem to be encoded as Protobuf. That are decoded bykotlinx-metadata-jvm.@ikhoon
I was thinking of using
isMarkedNullableAPI ofKType.I don’t know how exactly
isMarkedNullableAPI works at runtime(maybe by looking at@Metadataannotation values), but we can get nullability of function parameters at runtime.