Skip to content

Commit

Permalink
Update some Android astubx models (#1052)
Browse files Browse the repository at this point in the history
Update SDKs 28-30 as our astubx format has changed. SDK 31 to come in a
follow-up PR. Also add a minimal integration test to ensure things
aren't completely broken (at least for one SDK model version, which
typically should be the latest one).
  • Loading branch information
msridhar authored Oct 7, 2024
1 parent 69b8e4c commit 4eaf484
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions jar-infer/nullaway-integration-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 4eaf484

Please sign in to comment.