Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…hecker) for Maven builds.

We already have it on for our builds inside Google, but Maven checking provides an additional line of defense against #3990.

Because this CL enables checking for our _tests_, too (which is hard not to do, as discussed in the existing `pom.xml` comment about NullArgumentForNonNullParameter), I had to edit a couple benchmarks to avoid using what are _in a limited sense_ "Java 9+ APIs." They wouldn't be practical problems, though.

RELNOTES=n/a
PiperOrigin-RevId: 511830560
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Feb 23, 2023
1 parent dc56d52 commit 6405852
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
Expand Up @@ -63,7 +63,7 @@ byte crc32Checksum(int reps) throws Exception {
byte result = 0x01;
for (int i = 0; i < reps; i++) {
CRC32 checksum = new CRC32();
checksum.update(testBytes);
checksum.update(testBytes, 0, testBytes.length);
result = (byte) (result ^ checksum.getValue());
}
return result;
Expand All @@ -81,7 +81,7 @@ byte adler32Checksum(int reps) throws Exception {
byte result = 0x01;
for (int i = 0; i < reps; i++) {
Adler32 checksum = new Adler32();
checksum.update(testBytes);
checksum.update(testBytes, 0, testBytes.length);
result = (byte) (result ^ checksum.getValue());
}
return result;
Expand Down
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.Buffer;
import java.nio.CharBuffer;
import java.util.Random;

Expand All @@ -40,10 +41,10 @@ long copy(Readable from, Appendable to) throws IOException {
CharBuffer buf = CharStreams.createBuffer();
long total = 0;
while (from.read(buf) != -1) {
buf.flip();
((Buffer) buf).flip();
to.append(buf);
total += buf.remaining();
buf.clear();
((Buffer) buf).clear();
}
return total;
}
Expand Down
2 changes: 1 addition & 1 deletion android/pom.xml
Expand Up @@ -508,7 +508,7 @@
be passed as part of the same <arg> as -Xplugin:ErrorProne,
and I gave up trying to figure out how to do that for test
compilation only. -->
<arg>-Xplugin:ErrorProne -Xep:NullArgumentForNonNullParameter:OFF</arg>
<arg>-Xplugin:ErrorProne -Xep:NullArgumentForNonNullParameter:OFF -Xep:Java8ApiChecker:ERROR</arg>
<!-- https://github.com/google/error-prone/blob/f8e33bc460be82ab22256a7ef8b979d7a2cacaba/docs/installation.md#jdk-16 -->
<!-- TODO(cpovirk): Use .mvn/jvm.config instead (per
https://errorprone.info/docs/installation#maven) if it can
Expand Down
Expand Up @@ -63,7 +63,7 @@ byte crc32Checksum(int reps) throws Exception {
byte result = 0x01;
for (int i = 0; i < reps; i++) {
CRC32 checksum = new CRC32();
checksum.update(testBytes);
checksum.update(testBytes, 0, testBytes.length);
result = (byte) (result ^ checksum.getValue());
}
return result;
Expand All @@ -81,7 +81,7 @@ byte adler32Checksum(int reps) throws Exception {
byte result = 0x01;
for (int i = 0; i < reps; i++) {
Adler32 checksum = new Adler32();
checksum.update(testBytes);
checksum.update(testBytes, 0, testBytes.length);
result = (byte) (result ^ checksum.getValue());
}
return result;
Expand Down
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.Buffer;
import java.nio.CharBuffer;
import java.util.Random;

Expand All @@ -40,10 +41,10 @@ long copy(Readable from, Appendable to) throws IOException {
CharBuffer buf = CharStreams.createBuffer();
long total = 0;
while (from.read(buf) != -1) {
buf.flip();
((Buffer) buf).flip();
to.append(buf);
total += buf.remaining();
buf.clear();
((Buffer) buf).clear();
}
return total;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -515,7 +515,7 @@
be passed as part of the same <arg> as -Xplugin:ErrorProne,
and I gave up trying to figure out how to do that for test
compilation only. -->
<arg>-Xplugin:ErrorProne -Xep:NullArgumentForNonNullParameter:OFF</arg>
<arg>-Xplugin:ErrorProne -Xep:NullArgumentForNonNullParameter:OFF -Xep:Java8ApiChecker:ERROR</arg>
<!-- https://github.com/google/error-prone/blob/f8e33bc460be82ab22256a7ef8b979d7a2cacaba/docs/installation.md#jdk-16 -->
<!-- TODO(cpovirk): Use .mvn/jvm.config instead (per
https://errorprone.info/docs/installation#maven) if it can
Expand Down

0 comments on commit 6405852

Please sign in to comment.