Skip to content

Commit

Permalink
Initial support for JDK 11 (#263)
Browse files Browse the repository at this point in the history
For now, only the `:nullaway:test` target is passing on CI.  We need to address issues outlined in #259 to get everything working, and it may be a while before the sample Android app can easily be built.  That said, I think this initial level of support is useful and worth landing.
  • Loading branch information
msridhar committed Dec 4, 2018
1 parent cf8b704 commit f1a8751
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Expand Up @@ -2,6 +2,7 @@ language: android

jdk:
- oraclejdk8
- openjdk11

android:
components:
Expand All @@ -11,10 +12,11 @@ android:
- android-28

before_install:
- yes | sdkmanager "platforms;android-28"
- if [[ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]]; then yes | sdkmanager "platforms;android-28"; fi

script:
- ./gradlew verGJF build
- if [[ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]]; then ./gradlew verGJF build; fi
- if [[ "$TRAVIS_JDK_VERSION" == "openjdk11" ]]; then ./gradlew :nullaway:test; fi

after_success:
- .buildscript/deploy_snapshot.sh
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Expand Up @@ -52,6 +52,12 @@ subprojects { project ->
}
}

if (JavaVersion.current().java9Compatible) {
tasks.withType(JavaCompile) {
options.compilerArgs += [ "--release", "8" ]
}
}

repositories {
maven {
url "https://raw.githubusercontent.com/lazaroclapp/WALA/repository/"
Expand Down
8 changes: 7 additions & 1 deletion nullaway/build.gradle
Expand Up @@ -62,11 +62,17 @@ javadoc {

test {
maxHeapSize = "1024m"
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
}
}

apply from: rootProject.file("gradle/gradle-mvn-push.gradle")

jacoco {
toolVersion = "0.8.2"
}

// From https://github.com/kt3k/coveralls-gradle-plugin
jacocoTestReport {
reports {
Expand Down
13 changes: 11 additions & 2 deletions nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java
Expand Up @@ -294,6 +294,11 @@ public void externalInitexternalInitSupportFields() {

@Test
public void generatedAsUnannotated() {
String generatedAnnot =
(Double.parseDouble(System.getProperty("java.specification.version")) >= 11)
? "@javax.annotation.processing.Generated"
: "@javax.annotation.Generated";
System.err.println();
compilationHelper
.setArgs(
Arrays.asList(
Expand All @@ -304,7 +309,7 @@ public void generatedAsUnannotated() {
.addSourceLines(
"Generated.java",
"package com.uber;",
"@javax.annotation.Generated(\"foo\")",
generatedAnnot + "(\"foo\")",
"public class Generated { public void takeObj(Object o) {} }")
.addSourceLines(
"Test.java",
Expand All @@ -317,6 +322,10 @@ public void generatedAsUnannotated() {

@Test
public void generatedAsUnannotatedPlusRestrictive() {
String generatedAnnot =
(Double.parseDouble(System.getProperty("java.specification.version")) >= 11)
? "@javax.annotation.processing.Generated"
: "@javax.annotation.Generated";
compilationHelper
.setArgs(
Arrays.asList(
Expand All @@ -328,7 +337,7 @@ public void generatedAsUnannotatedPlusRestrictive() {
.addSourceLines(
"Generated.java",
"package com.uber;",
"@javax.annotation.Generated(\"foo\")",
generatedAnnot + "(\"foo\")",
"public class Generated {",
" @javax.annotation.Nullable",
" public Object retNull() {",
Expand Down
Expand Up @@ -253,8 +253,9 @@ static void arrayDequeStuff() {
d.offer(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.push(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.toArray(null);
Object[] o = null;
// BUG: Diagnostic contains: passing @Nullable parameter 'o' where @NonNull is required
d.toArray(o);
// this should be fine
d.toArray();
}
Expand All @@ -275,8 +276,9 @@ static void dequeStuff() {
d.offer(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.push(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.toArray(null);
Object[] o = null;
// BUG: Diagnostic contains: passing @Nullable parameter 'o' where @NonNull is required
d.toArray(o);
}

static void guavaStuff() {
Expand Down

0 comments on commit f1a8751

Please sign in to comment.