Skip to content

Commit

Permalink
Target Java 8:
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
cpovirk authored and Jimfs Team committed May 30, 2023
1 parent faf8ec0 commit 5b60a42
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Jimfs
=====

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2020 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package com.google.common.jimfs;

import java.nio.Buffer;

/**
* Wrappers around {@link Buffer} methods that are covariantly overridden in Java 9+. See
* https://github.com/google/guava/issues/3990
*/
final class Java8Compatibility {
static void clear(Buffer b) {
b.clear();
}

private Java8Compatibility() {}
}
4 changes: 2 additions & 2 deletions jimfs/src/main/java/com/google/common/jimfs/RegularFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public long transferTo(long pos, long count, WritableByteChannel dest) throws IO
while (buf.hasRemaining()) {
remaining -= dest.write(buf);
}
buf.clear();
Java8Compatibility.clear(buf);

while (remaining > 0) {
int index = ++blockIndex;
Expand All @@ -589,7 +589,7 @@ public long transferTo(long pos, long count, WritableByteChannel dest) throws IO
while (buf.hasRemaining()) {
remaining -= dest.write(buf);
}
buf.clear();
Java8Compatibility.clear(buf);
}
}

Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<auto-service.version>1.0.1</auto-service.version>
<auto-common.version>1.2.1</auto-common.version>
<java.version>1.7</java.version>
<java.version>1.8</java.version>
<guava.version>31.1-android</guava.version>
<!--
NOTE: When updating errorprone.version, also update javac.version to the
Expand Down Expand Up @@ -182,6 +182,7 @@
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<charset>UTF-8</charset>
<source>${java.version}</source>
<detectJavaApiLink>false</detectJavaApiLink>
<links>
<link>https://checkerframework.org/api/</link>
Expand Down Expand Up @@ -304,7 +305,7 @@
<compilerArgs>
<!-- https://errorprone.info/docs/installation#maven -->
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-Xplugin:ErrorProne -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 5b60a42

Please sign in to comment.