Skip to content

Commit 5b60a42

Browse files
cpovirkJimfs Team
authored andcommitted
Target Java 8:
- Set `-source 8 -target 8`. We already have a depencdency on `guava-android`, which began requiring Java 8 a while back, so we might as well unlock the ability to use Java 8 language features ourselves. (I also found I had to set `-source 8` in `maven-javadoc-plugin` to prevent it from trying to pass a `--module-path`, which leads to problems with our usages of `@NullableDecl`, which isn't in a module. That's probably unrelated: We probably just haven't run Javadoc since some `maven-javadoc-plugin` upgrade.) Work toward #240, and fixes #229 - Don't refer to Java 9+ `ByteBuffer` methods, and set up Error Prone enforcement of future such mistakes. Compare google/guava#6334. Fixes #113 RELNOTES=Officially dropped support for Java 7, and restored accidentally dropped support for Java 8. PiperOrigin-RevId: 536468340
1 parent faf8ec0 commit 5b60a42

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Jimfs
22
=====
33

4-
Jimfs is an in-memory file system for Java 7 and above, implementing the
4+
Jimfs is an in-memory file system for Java 8 and above, implementing the
55
[java.nio.file](http://docs.oracle.com/javase/7/docs/api/java/nio/file/package-summary.html)
66
abstract file system APIs.
77

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2020 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
package com.google.common.jimfs;
16+
17+
import java.nio.Buffer;
18+
19+
/**
20+
* Wrappers around {@link Buffer} methods that are covariantly overridden in Java 9+. See
21+
* https://github.com/google/guava/issues/3990
22+
*/
23+
final class Java8Compatibility {
24+
static void clear(Buffer b) {
25+
b.clear();
26+
}
27+
28+
private Java8Compatibility() {}
29+
}

jimfs/src/main/java/com/google/common/jimfs/RegularFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public long transferTo(long pos, long count, WritableByteChannel dest) throws IO
579579
while (buf.hasRemaining()) {
580580
remaining -= dest.write(buf);
581581
}
582-
buf.clear();
582+
Java8Compatibility.clear(buf);
583583

584584
while (remaining > 0) {
585585
int index = ++blockIndex;
@@ -589,7 +589,7 @@ public long transferTo(long pos, long count, WritableByteChannel dest) throws IO
589589
while (buf.hasRemaining()) {
590590
remaining -= dest.write(buf);
591591
}
592-
buf.clear();
592+
Java8Compatibility.clear(buf);
593593
}
594594
}
595595

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9797
<auto-service.version>1.0.1</auto-service.version>
9898
<auto-common.version>1.2.1</auto-common.version>
99-
<java.version>1.7</java.version>
99+
<java.version>1.8</java.version>
100100
<guava.version>31.1-android</guava.version>
101101
<!--
102102
NOTE: When updating errorprone.version, also update javac.version to the
@@ -182,6 +182,7 @@
182182
<encoding>UTF-8</encoding>
183183
<docencoding>UTF-8</docencoding>
184184
<charset>UTF-8</charset>
185+
<source>${java.version}</source>
185186
<detectJavaApiLink>false</detectJavaApiLink>
186187
<links>
187188
<link>https://checkerframework.org/api/</link>
@@ -304,7 +305,7 @@
304305
<compilerArgs>
305306
<!-- https://errorprone.info/docs/installation#maven -->
306307
<arg>-XDcompilePolicy=simple</arg>
307-
<arg>-Xplugin:ErrorProne</arg>
308+
<arg>-Xplugin:ErrorProne -Xep:Java8ApiChecker:ERROR</arg>
308309
<!-- https://github.com/google/error-prone/blob/f8e33bc460be82ab22256a7ef8b979d7a2cacaba/docs/installation.md#jdk-16 -->
309310
<!-- TODO(cpovirk): Use .mvn/jvm.config instead (per
310311
https://errorprone.info/docs/installation#maven) if it can

0 commit comments

Comments
 (0)