From 4e82e62eaa549d1f63a6548aa0a6ea1687de618f Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 28 Mar 2018 17:13:39 -0700 Subject: [PATCH] Fix compilation in Java 9 --- .travis.yml | 7 ++++++- benchmarks/build.gradle | 1 + build.gradle | 1 + core/src/test/java/io/grpc/AttributesTest.java | 17 +++++++++++++---- examples/build.gradle | 1 + grpclb/build.gradle | 1 + interop-testing/build.gradle | 1 + services/build.gradle | 1 + testing-proto/build.gradle | 1 + 9 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa15eea7b7..7ea9aee3d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,12 +36,17 @@ script: - ./gradlew check :grpc-all:jacocoTestReport after_success: - - if \[ "$TRAVIS_OS_NAME" = linux \]; then ./gradlew :grpc-all:coveralls; fi + # Upload to coveralls once, instead of for each job in the matrix + - if \[\[ "$TRAVIS_JOB_NUMBER" == *.1 \]\]; then ./gradlew :grpc-all:coveralls; fi - bash <(curl -s https://codecov.io/bash) os: - linux +jdk: + - oraclejdk8 + - oraclejdk9 + notifications: email: false diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 77727d0cd4..57115747aa 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -37,6 +37,7 @@ dependencies { libraries.netty_tcnative, libraries.netty_epoll, libraries.math + compileOnly libraries.javax_annotation } compileJava { diff --git a/build.gradle b/build.gradle index 03f2309b74..b231c3c101 100644 --- a/build.gradle +++ b/build.gradle @@ -192,6 +192,7 @@ subprojects { gson: "com.google.code.gson:gson:2.7", guava: "com.google.guava:guava:${guavaVersion}", hpack: 'com.twitter:hpack:0.10.1', + javax_annotation: 'javax.annotation:javax.annotation-api:1.2', jsr305: 'com.google.code.findbugs:jsr305:3.0.0', oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0', google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0', diff --git a/core/src/test/java/io/grpc/AttributesTest.java b/core/src/test/java/io/grpc/AttributesTest.java index db4e86a324..ab0bc79fee 100644 --- a/core/src/test/java/io/grpc/AttributesTest.java +++ b/core/src/test/java/io/grpc/AttributesTest.java @@ -53,11 +53,20 @@ public class AttributesTest { } @Test - @SuppressWarnings("BoxedPrimitiveConstructor") public void valueEquality() { - Attributes.Key key = Attributes.Key.of("ints"); - Integer v1 = new Integer(100000); - Integer v2 = new Integer(100000); + class EqualObject { + @Override public boolean equals(Object o) { + return o instanceof EqualObject; + } + + @Override public int hashCode() { + return 42; + } + } + + Attributes.Key key = Attributes.Key.of("ints"); + EqualObject v1 = new EqualObject(); + EqualObject v2 = new EqualObject(); assertNotSame(v1, v2); assertEquals(v1, v2); diff --git a/examples/build.gradle b/examples/build.gradle index 3d5888b9e2..068a9029a4 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -37,6 +37,7 @@ dependencies { compile "io.grpc:grpc-netty:${grpcVersion}" compile "io.grpc:grpc-protobuf:${grpcVersion}" compile "io.grpc:grpc-stub:${grpcVersion}" + compileOnly "javax.annotation:javax.annotation-api:1.2" // Used for TLS in HelloWorldServerTls compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}" diff --git a/grpclb/build.gradle b/grpclb/build.gradle index f1d3164fc1..95ca0a6e0a 100644 --- a/grpclb/build.gradle +++ b/grpclb/build.gradle @@ -17,6 +17,7 @@ dependencies { project(':grpc-protobuf'), project(':grpc-stub'), libraries.protobuf + compileOnly libraries.javax_annotation testCompile libraries.truth, project(':grpc-core').sourceSets.test.output } diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index ce3c611042..0e9888ead2 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -29,6 +29,7 @@ dependencies { libraries.mockito, libraries.oauth_client, libraries.truth + compileOnly libraries.javax_annotation runtime libraries.opencensus_impl, libraries.netty_tcnative testCompile project(':grpc-context').sourceSets.test.output diff --git a/services/build.gradle b/services/build.gradle index 559ce5797f..ba7cb1ab9e 100644 --- a/services/build.gradle +++ b/services/build.gradle @@ -24,6 +24,7 @@ dependencies { // we'll always be more up-to-date exclude group: 'io.grpc', module: 'grpc-context' } + compileOnly libraries.javax_annotation testCompile project(':grpc-testing'), libraries.netty_epoll // for DomainSocketAddress signature "org.codehaus.mojo.signature:java16:1.1@signature" diff --git a/testing-proto/build.gradle b/testing-proto/build.gradle index da07f65afe..675351d75a 100644 --- a/testing-proto/build.gradle +++ b/testing-proto/build.gradle @@ -16,6 +16,7 @@ buildscript { dependencies { compile project(':grpc-protobuf'), project(':grpc-stub') + compileOnly libraries.javax_annotation testCompile libraries.truth }