diff --git a/jar-infer/android-jarinfer-models-sdk28/src/main/resources/jarinfer.astubx b/jar-infer/android-jarinfer-models-sdk28/src/main/resources/jarinfer.astubx index 9d68dd31fd..5b65d63ff0 100644 Binary files a/jar-infer/android-jarinfer-models-sdk28/src/main/resources/jarinfer.astubx and b/jar-infer/android-jarinfer-models-sdk28/src/main/resources/jarinfer.astubx differ diff --git a/jar-infer/android-jarinfer-models-sdk29/src/main/resources/jarinfer.astubx b/jar-infer/android-jarinfer-models-sdk29/src/main/resources/jarinfer.astubx index 07f23d029e..e5331f0a6b 100644 Binary files a/jar-infer/android-jarinfer-models-sdk29/src/main/resources/jarinfer.astubx and b/jar-infer/android-jarinfer-models-sdk29/src/main/resources/jarinfer.astubx differ diff --git a/jar-infer/android-jarinfer-models-sdk30/src/main/resources/jarinfer.astubx b/jar-infer/android-jarinfer-models-sdk30/src/main/resources/jarinfer.astubx index b8350f2fa1..7050ad212d 100644 Binary files a/jar-infer/android-jarinfer-models-sdk30/src/main/resources/jarinfer.astubx and b/jar-infer/android-jarinfer-models-sdk30/src/main/resources/jarinfer.astubx differ diff --git a/jar-infer/nullaway-integration-test/build.gradle b/jar-infer/nullaway-integration-test/build.gradle index 94a880861a..a05316eca2 100644 --- a/jar-infer/nullaway-integration-test/build.gradle +++ b/jar-infer/nullaway-integration-test/build.gradle @@ -25,4 +25,11 @@ dependencies { } testImplementation project(":nullaway") testImplementation project(":jar-infer:test-java-lib-jarinfer") + + // For now we can only test one of the SDK models at a time; so exactly + // one of the following lines should be uncommented + //testImplementation project(":jar-infer:android-jarinfer-models-sdk28") + //testImplementation project(":jar-infer:android-jarinfer-models-sdk29") + testImplementation project(":jar-infer:android-jarinfer-models-sdk30") + //testImplementation project(":jar-infer:android-jarinfer-models-sdk31") } diff --git a/jar-infer/nullaway-integration-test/src/test/java/com/uber/nullaway/jarinfer/JarInferIntegrationTest.java b/jar-infer/nullaway-integration-test/src/test/java/com/uber/nullaway/jarinfer/JarInferIntegrationTest.java index f77ae54ae3..4965b907a9 100644 --- a/jar-infer/nullaway-integration-test/src/test/java/com/uber/nullaway/jarinfer/JarInferIntegrationTest.java +++ b/jar-infer/nullaway-integration-test/src/test/java/com/uber/nullaway/jarinfer/JarInferIntegrationTest.java @@ -116,4 +116,37 @@ public void jarinferNullableReturnsTest() { "}") .doTest(); } + + /** + * Tests our pre-generated models for Android SDK classes. See also the build.gradle file for this + * project which determines which SDK version's models are being tested. + */ + @Test + public void jarInferAndroidSDKModels() { + compilationHelper + .setArgs( + Arrays.asList( + "-d", + temporaryFolder.getRoot().getAbsolutePath(), + "-XepOpt:NullAway:AnnotatedPackages=com.uber", + "-XepOpt:NullAway:JarInferEnabled=true")) + // stub implementation of SpannableStringBuilder.append(CharSequence) which we know is + // modelled as having a @Nullable parameter + .addSourceLines( + "SpannableStringBuilder.java", + "package android.text;", + "public class SpannableStringBuilder {", + " public SpannableStringBuilder append(CharSequence text) { return this; }", + "}") + .addSourceLines( + "Test.java", + "package com.uber;", + "class Test {", + " void test1(android.text.SpannableStringBuilder builder) {", + " // BUG: Diagnostic contains: passing @Nullable parameter 'null'", + " builder.append(null);", + " }", + "}") + .doTest(); + } }