Skip to content

Commit a898601

Browse files
authored
Expose Elasticsearch API nullability information to Kotlin compiler. (#43912) (#44518)
This change allows the Kotlin compiler to type check methods annotated with the org.elasticsearch.common.Nullable annotation in Elasticsearch Java APIs as described in: https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support. (cherry picked from commit 0d0485a)
1 parent 21971fe commit a898601

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

libs/core/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ publishing {
7373
}
7474

7575
dependencies {
76+
// This dependency is used only by :libs:core for null-checking interop with other tools
77+
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
78+
7679
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
7780
testCompile "junit:junit:${versions.junit}"
7881
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"

libs/core/src/main/java/org/elasticsearch/common/Nullable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.elasticsearch.common;
2121

22+
import javax.annotation.CheckForNull;
23+
import javax.annotation.meta.TypeQualifierNickname;
2224
import java.lang.annotation.Documented;
2325
import java.lang.annotation.ElementType;
2426
import java.lang.annotation.Retention;
@@ -33,6 +35,8 @@
3335
*
3436
*/
3537
@Documented
38+
@TypeQualifierNickname
39+
@CheckForNull
3640
@Retention(RetentionPolicy.RUNTIME)
3741
@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD})
3842
public @interface Nullable {

0 commit comments

Comments
 (0)