Skip to content

Commit

Permalink
Add error-prone compiler and fix its found issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Feb 15, 2017
1 parent 8ed90a0 commit 1c2c57b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
language: java

jdk:
- oraclejdk7
- oraclejdk8

addons:
apt:
packages:
- oracle-java8-installer # Updates JDK 8 to the latest available.

after_success:
- .buildscript/deploy_snapshot.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -299,6 +300,7 @@ public void invokeOptionalWithException() throws Exception {
}

@Test
@Ignore("Despite returning false for isSupported, invocation actually succeeds.")
public void invokeOptionalNonPublic() throws Exception {
SubClass2 subClass2 = new SubClass2();
assertFalse(NON_PUBLIC.isSupported(subClass2));
Expand All @@ -309,9 +311,10 @@ private static <T> void assertErrorOnInvoke(
OptionalMethod<T> optionalMethod, T base, Object... args) throws Exception {
try {
optionalMethod.invoke(base, args);
fail();
} catch (Error expected) {
return;
}
fail();
}

private static <T> void assertIllegalArgumentExceptionOnInvoke(
Expand All @@ -327,9 +330,10 @@ private static <T> void assertErrorOnInvokeOptional(
OptionalMethod<T> optionalMethod, T base, Object... args) throws Exception {
try {
optionalMethod.invokeOptional(base, args);
fail();
} catch (Error expected) {
return;
}
fail();
}

private static <T> void assertIllegalArgumentExceptionOnInvokeOptional(
Expand Down
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,25 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<version>3.6.1</version>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.0.16</version>
</dependency>
</dependencies>
</plugin>

<plugin>
Expand Down

0 comments on commit 1c2c57b

Please sign in to comment.