Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for JDK 11 #263

Merged
merged 9 commits into from Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion nullaway/build.gradle
Expand Up @@ -62,7 +62,9 @@ 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")
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 =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javax.annotation.Generated has disappeared in JDK 11 🙁

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an equivalent? What do people use instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is javax.annotation.processing.Generated now, though there is no consensus on what to use (see e.g. grpc/grpc-java#3633 for discussion). Here we just use javax.annotation.processing.Generated in our tests if we're on JDK 11

(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