Skip to content

Commit

Permalink
Merge branch 'master' into remove-jarinfer-return-annotations-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar authored Oct 7, 2024
2 parents a354901 + 4eaf484 commit b81796d
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
epVersion: 2.31.0
- os: macos-latest
java: 17
epVersion: 2.32.0
epVersion: 2.33.0
- os: windows-latest
java: 17
epVersion: 2.32.0
epVersion: 2.33.0
- os: ubuntu-latest
java: 17
epVersion: 2.32.0
epVersion: 2.33.0
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
run: ./gradlew codeCoverageReport
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.32.0' && github.repository == 'uber/NullAway'
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.33.0' && github.repository == 'uber/NullAway'
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ subprojects { project ->
project.apply plugin: "com.diffplug.spotless"
spotless {
java {
googleJavaFormat()
googleJavaFormat(deps.versions.googlejavaformat)
}
}
}
Expand All @@ -129,7 +129,7 @@ spotless {
}
}
spotlessPredeclare {
java { googleJavaFormat('1.19.2') }
java { googleJavaFormat(deps.versions.googlejavaformat) }
groovyGradle {
greclipse()
}
Expand Down
3 changes: 2 additions & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.util.VersionNumber
// The oldest version of Error Prone that we support running on
def oldestErrorProneVersion = "2.14.0"
// Latest released Error Prone version that we've tested with
def latestErrorProneVersion = "2.32.0"
def latestErrorProneVersion = "2.33.0"
// Default to using latest tested Error Prone version
def defaultErrorProneVersion = latestErrorProneVersion
def errorProneVersionToCompileAgainst = defaultErrorProneVersion
Expand Down Expand Up @@ -53,6 +53,7 @@ def versions = [
autoValue : "1.10.2",
autoService : "1.1.1",
javaparser : "3.26.2",
googlejavaformat : "1.24.0",
]

def apt = [
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
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 @@ -115,4 +115,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();
}
}
8 changes: 4 additions & 4 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -2366,10 +2366,11 @@ private boolean mayBeNullExpr(VisitorState state, ExpressionTree expr) {
case NEW_CLASS:
case NEW_ARRAY:
case ARRAY_TYPE:
// Lambdas may return null, but the lambda literal itself should not be null
case LAMBDA_EXPRESSION:
// Lambdas may return null, but the lambda literal itself should not be null
// These cannot be null; the compiler would catch it
case MEMBER_REFERENCE:
// These cannot be null; the compiler would catch it
// result of compound assignment cannot be null
case MULTIPLY_ASSIGNMENT:
case DIVIDE_ASSIGNMENT:
case REMAINDER_ASSIGNMENT:
Expand All @@ -2381,9 +2382,8 @@ private boolean mayBeNullExpr(VisitorState state, ExpressionTree expr) {
case AND_ASSIGNMENT:
case XOR_ASSIGNMENT:
case OR_ASSIGNMENT:
// result of compound assignment cannot be null
// rest are for auto-boxing
case PLUS:
// rest are for auto-boxing
case MINUS:
case MULTIPLY:
case DIVIDE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ && castToNonNull(receiver.getTree()).getKind().equals(Tree.Kind.IDENTIFIER)
&& (receiver.toString().equals("Integer") || receiver.toString().equals("Long"))) {
return argumentToMapKeySpecifier(arguments.get(0), state, apContext);
}
// Fine to fallthrough:
// Fine to fallthrough:
default:
// Every other type of expression, including variables, field accesses, new A(...), etc.
return getAccessPathForNode(argument, state, apContext); // Every AP is a MapKey too
Expand Down Expand Up @@ -488,8 +488,8 @@ && isBoxingMethod(ASTHelpers.getSymbol(methodInvocationTree))) {
break;
}
}
// Cascade to default, symbol is not a constant field
// fall through
// Cascade to default, symbol is not a constant field
// fall through
default:
return null; // Not an AP
}
Expand Down

0 comments on commit b81796d

Please sign in to comment.