Skip to content

Commit

Permalink
Merge pull request #32 from cryptomator/feature/jdk21
Browse files Browse the repository at this point in the history
Update project to JDK 21 and JEP 442
  • Loading branch information
infeo authored Aug 30, 2023
2 parents c2588b1 + f7c6ab1 commit 0a465a4
Show file tree
Hide file tree
Showing 347 changed files with 20,562 additions and 15,192 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 20
java-version: 21-ea
distribution: 'zulu'
cache: 'maven'
- name: Setup fuse
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 20
java-version: 21-ea
distribution: 'zulu'
cache: 'maven'
- name: Setup fuse
Expand All @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 20
java-version: 21-ea
distribution: 'zulu'
cache: 'maven'
- name: Setup fuse
Expand All @@ -83,7 +83,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: 20
java-version: 21-ea
distribution: 'zulu'
cache: 'maven'
- name: Cache SonarCloud packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ref: "refs/tags/${{ github.event.inputs.tag }}"
- uses: actions/setup-java@v3
with:
java-version: 20
java-version: 21-ea
distribution: 'zulu'
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 20
java-version: 21-ea
distribution: 'zulu'
cache: 'maven'
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

# jFUSE

Zero-Dependency Java bindings for FUSE using [JEP 434](https://openjdk.org/jeps/434).
Zero-Dependency Java bindings for FUSE using [JEP 4442](https://openjdk.org/jeps/442).

## Status

This is currently an experimental library requiring JDK 20. As long as the [Foreign Function & Memory API](https://openjdk.org/jeps/434) is incubating, the required JDK will increase.
This is currently an experimental library requiring JDK 21. As long as the [Foreign Function & Memory API](https://openjdk.org/jeps/442) is incubating, the required JDK will increase.
Older JDK versions are *not supported*. Please refer to an older version of this lib, if you are interested in using it with an older JDK. Older versions will not receive patches or any kind of support, though!

We attempt to support libfuse 3.x on Linux and Windows while also remaining compatible with libfuse 2.x on macOS, leading to some compromises in the API.
Expand Down
15 changes: 2 additions & 13 deletions jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;

Expand All @@ -43,7 +42,7 @@ public abstract class Fuse implements AutoCloseable {
/**
* The memory session associated with the lifecycle of this Fuse instance.
*/
protected final Arena fuseArena = Arena.openShared();
protected final Arena fuseArena = Arena.ofShared();

/**
* The file system operations invoked by this FUSE file system.
Expand Down Expand Up @@ -125,7 +124,7 @@ public synchronized void mount(String progName, Path mountPoint, String... flags

try {
var fuseMount = this.mount(args);
Future<Integer> fuseLoop = executor.submit(() -> fuseLoop(fuseMount));
Future<Integer> fuseLoop = executor.submit(fuseMount::loop);
waitForMountingToComplete(mountPoint, fuseLoop);
if (fuseLoop.isDone()) {
throw new FuseMountFailedException("fuse_loop() returned prematurely with non-zero exit code " + fuseLoop.get());
Expand Down Expand Up @@ -153,16 +152,6 @@ void waitForMountingToComplete(Path mountPoint, Future<Integer> fuseLoop) throws
} while (!fuseLoop.isDone() && !mountProbeSucceeded.await(200, TimeUnit.MILLISECONDS));
}

@Blocking
private int fuseLoop(FuseMount mount) {
AtomicInteger result = new AtomicInteger();
fuseArena.scope().whileAlive(() -> {
int r = mount.loop();
result.set(r);
});
return result.get();
}

/**
* Mounts the fuse file system.
*
Expand Down
13 changes: 8 additions & 5 deletions jfuse-linux-aarch64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@
<artifactId>jextract-maven-plugin</artifactId>
<version>0.3.0</version>
<configuration>
<executable>/Users/sebastian/Documents/Cryptomator/jextract/build/jextract/bin/jextract</executable>
<executable>/Users/sebastian/git/github.com/openjdk/jextract/build/jextract/bin/jextract</executable>
<headerSearchPaths>${linux.headerSearchPath}</headerSearchPaths>
<outputDirectory>${project.build.sourceDirectory}</outputDirectory>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr</targetPackage>
</configuration>
<executions>
<execution>
Expand All @@ -84,6 +83,7 @@
</goals>
<configuration>
<headerFile>${project.parent.basedir}/libfuse3/include/fuse.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.fuse3</targetPackage>
<headerClassName>fuse_h</headerClassName>
<cPreprocessorMacros>
<cPreprocessorMacro>_FILE_OFFSET_BITS=64</cPreprocessorMacro>
Expand Down Expand Up @@ -128,7 +128,7 @@
</goals>
<configuration>
<headerFile>${project.parent.basedir}/libfuse3/include/fuse_lowlevel.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr</targetPackage>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.fuse3_lowlevel</targetPackage>
<headerClassName>fuse_lowlevel_h</headerClassName>
<cPreprocessorMacros>
<cPreprocessorMacro>_FILE_OFFSET_BITS=64</cPreprocessorMacro>
Expand All @@ -146,6 +146,7 @@
</goals>
<configuration>
<headerFile>${linux.headerSearchPath}/errno.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.errno</targetPackage>
<headerClassName>errno_h</headerClassName>
<includeConstants>
<includeConstant>ENOENT</includeConstant>
Expand Down Expand Up @@ -174,6 +175,7 @@
</goals>
<configuration>
<headerFile>${linux.headerSearchPath}/sys/stat.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.stat</targetPackage>
<headerClassName>stat_h</headerClassName>
<includeConstants>
<includeConstant>UTIME_NOW</includeConstant>
Expand All @@ -188,6 +190,7 @@
</goals>
<configuration>
<headerFile>${linux.headerSearchPath}/fcntl.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.fcntl</targetPackage>
<headerClassName>fcntl_h</headerClassName>
<includeConstants>
<includeConstant>O_RDONLY</includeConstant>
Expand All @@ -209,6 +212,7 @@
</goals>
<configuration>
<headerFile>${linux.headerSearchPath}/stdio.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.stdio</targetPackage>
<headerClassName>stdio_h</headerClassName>
<cPreprocessorMacros>
<cPreprocessorMacro>_GNU_SOURCE=1</cPreprocessorMacro>
Expand All @@ -227,5 +231,4 @@
</build>
</profile>
</profiles>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import org.cryptomator.jfuse.api.DirFiller;
import org.cryptomator.jfuse.api.Stat;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_fill_dir_t;
import org.cryptomator.jfuse.linux.aarch64.extr.stat;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3.fuse_fill_dir_t;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3.stat;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.SegmentScope;
import java.util.function.Consumer;

record DirFillerImpl(MemorySegment buf, fuse_fill_dir_t callback, Arena arena) implements DirFiller {

DirFillerImpl(MemorySegment buf, MemorySegment callback, Arena arena) {
this(buf, fuse_fill_dir_t.ofAddress(callback, arena.scope()), arena);
this(buf, fuse_fill_dir_t.ofAddress(callback, arena), arena);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.cryptomator.jfuse.linux.aarch64;

import org.cryptomator.jfuse.api.FileInfo;
import org.cryptomator.jfuse.linux.aarch64.extr.fcntl_h;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_file_info;
import org.cryptomator.jfuse.linux.aarch64.extr.fcntl.fcntl_h;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3.fuse_file_info;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.SegmentScope;
import java.nio.file.StandardOpenOption;
import java.util.EnumSet;
import java.util.Set;
Expand All @@ -22,7 +22,7 @@ record FileInfoImpl(MemorySegment segment) implements FileInfo {
private static final int O_SYNC = fcntl_h.O_SYNC();
private static final int O_DSYNC = fcntl_h.O_DSYNC();

public FileInfoImpl(MemorySegment address, SegmentScope scope) {
public FileInfoImpl(MemorySegment address, Arena scope) {
this(fuse_file_info.ofAddress(address, scope));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.cryptomator.jfuse.linux.aarch64;

import org.cryptomator.jfuse.linux.aarch64.extr.fuse_args;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_cmdline_opts;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3.fuse_args;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3_lowlevel.fuse_cmdline_opts;

import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
Expand All @@ -14,7 +14,7 @@ public String toString() {
var argc = fuse_args.argc$get(args);
var argv = fuse_args.argv$get(args);
for (int i = 0; i < argc; i++) {
var cString = argv.getAtIndex(ValueLayout.ADDRESS.asUnbounded(), i);
var cString = argv.getAtIndex(ValueLayout.ADDRESS, i).reinterpret(Long.MAX_VALUE);
sb.append("arg[").append(i).append("] = ").append(cString.getUtf8String(0)).append(", ");
}
sb.append("mountPoint = ").append(mountPoint().getUtf8String(0));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.cryptomator.jfuse.linux.aarch64;

import org.cryptomator.jfuse.api.FuseConfig;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_config;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3.fuse_config;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.SegmentScope;

record FuseConfigImpl(MemorySegment segment) implements FuseConfig {

public FuseConfigImpl(MemorySegment address, SegmentScope scope) {
public FuseConfigImpl(MemorySegment address, Arena scope) {
this(fuse_config.ofAddress(address, scope));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.cryptomator.jfuse.linux.aarch64;

import org.cryptomator.jfuse.api.FuseConnInfo;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_conn_info;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse3.fuse_conn_info;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.SegmentScope;

record FuseConnInfoImpl(MemorySegment segment) implements FuseConnInfo {

public FuseConnInfoImpl(MemorySegment address, SegmentScope scope) {
public FuseConnInfoImpl(MemorySegment address, Arena scope) {
this(fuse_conn_info.ofAddress(address, scope));
}

Expand Down
Loading

0 comments on commit 0a465a4

Please sign in to comment.