Skip to content

Commit 2691a86

Browse files
authored
Merge pull request #29 from cryptomator/feature/jdk20
migrated to new JEP 434 API (JDK20)
2 parents bf62274 + e22011a commit 2691a86

File tree

158 files changed

+12416
-4770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+12416
-4770
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v3
1313
- uses: actions/setup-java@v3
1414
with:
15-
java-version: 19
15+
java-version: 20
1616
distribution: 'zulu'
1717
cache: 'maven'
1818
- name: Setup fuse
@@ -35,7 +35,7 @@ jobs:
3535
- uses: actions/checkout@v3
3636
- uses: actions/setup-java@v3
3737
with:
38-
java-version: 19
38+
java-version: 20
3939
distribution: 'zulu'
4040
cache: 'maven'
4141
- name: Setup fuse
@@ -59,11 +59,11 @@ jobs:
5959
- uses: actions/checkout@v3
6060
- uses: actions/setup-java@v3
6161
with:
62-
java-version: 19
62+
java-version: 20
6363
distribution: 'zulu'
6464
cache: 'maven'
6565
- name: Setup fuse
66-
run: choco install winfsp --version 1.11.22176 -y
66+
run: choco install winfsp --version 1.12.22339 -y
6767
- name: Maven build
6868
shell: bash # surprise, running maven in pwsh is crappy, see https://stackoverflow.com/q/6347985/4014509
6969
run: mvn -B verify -Dfuse.lib.path="C:\Program Files (x86)\WinFsp\bin\winfsp-x64.dll"
@@ -83,7 +83,7 @@ jobs:
8383
fetch-depth: 0
8484
- uses: actions/setup-java@v3
8585
with:
86-
java-version: 19
86+
java-version: 20
8787
distribution: 'zulu'
8888
cache: 'maven'
8989
- name: Cache SonarCloud packages

.github/workflows/publish-central.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
ref: "refs/tags/${{ github.event.inputs.tag }}"
1616
- uses: actions/setup-java@v3
1717
with:
18-
java-version: 19
18+
java-version: 20
1919
distribution: 'zulu'
2020
cache: 'maven'
2121
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml

.github/workflows/publish-github.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v3
1111
- uses: actions/setup-java@v3
1212
with:
13-
java-version: 19
13+
java-version: 20
1414
distribution: 'zulu'
1515
cache: 'maven'
1616
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/HelloWorldFileSystem.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/HelloWorldFileSystem__Windows_.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
# jFUSE
88

9-
Zero-Dependency Java bindings for FUSE using [JEP 424](https://openjdk.org/jeps/424).
9+
Zero-Dependency Java bindings for FUSE using [JEP 434](https://openjdk.org/jeps/434).
1010

1111
## Status
1212

13-
This is currently an experimental library requiring JDK 19. As long as the [Foreign Function & Memory API](https://openjdk.org/jeps/424) is incubating, the required JDK will increase.
13+
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.
14+
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!
1415

1516
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.
1617

jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.jetbrains.annotations.VisibleForTesting;
88

99
import java.io.IOException;
10+
import java.lang.foreign.Arena;
1011
import java.lang.foreign.MemorySegment;
11-
import java.lang.foreign.MemorySession;
1212
import java.lang.foreign.SegmentAllocator;
1313
import java.nio.file.Files;
1414
import java.nio.file.Path;
@@ -43,7 +43,7 @@ public abstract class Fuse implements AutoCloseable {
4343
/**
4444
* The memory session associated with the lifecycle of this Fuse instance.
4545
*/
46-
protected final MemorySession fuseScope = MemorySession.openShared();
46+
protected final Arena fuseArena = Arena.openShared();
4747

4848
/**
4949
* The file system operations invoked by this FUSE file system.
@@ -66,7 +66,7 @@ public abstract class Fuse implements AutoCloseable {
6666
*/
6767
protected Fuse(FuseOperations fuseOperations, Function<SegmentAllocator, MemorySegment> structAllocator) {
6868
this.fuseOperations = new MountProbeObserver(fuseOperations, mountProbeSucceeded::countDown);
69-
this.fuseOperationsStruct = structAllocator.apply(fuseScope);
69+
this.fuseOperationsStruct = structAllocator.apply(fuseArena);
7070
fuseOperations.supportedOperations().forEach(this::bind);
7171
}
7272

@@ -108,7 +108,7 @@ public static FuseBuilder builder() {
108108
@Blocking
109109
@MustBeInvokedByOverriders
110110
public synchronized void mount(String progName, Path mountPoint, String... flags) throws FuseMountFailedException, IllegalArgumentException {
111-
if (!fuseScope.isAlive()) {
111+
if (!fuseArena.scope().isAlive()) {
112112
throw new IllegalStateException("Already closed"); //TODO: throw specialized exception
113113
}
114114

@@ -156,8 +156,9 @@ void waitForMountingToComplete(Path mountPoint, Future<Integer> fuseLoop) throws
156156
@Blocking
157157
private int fuseLoop(FuseMount mount) {
158158
AtomicInteger result = new AtomicInteger();
159-
fuseScope.whileAlive(() -> {
160-
result.set(mount.loop());
159+
fuseArena.scope().whileAlive(() -> {
160+
int r = mount.loop();
161+
result.set(r);
161162
});
162163
return result.get();
163164
}
@@ -184,7 +185,7 @@ private int fuseLoop(FuseMount mount) {
184185
@Blocking
185186
@MustBeInvokedByOverriders
186187
public synchronized void close() throws TimeoutException {
187-
if (!fuseScope.isAlive()) {
188+
if (!fuseArena.scope().isAlive()) {
188189
return; // already closed
189190
}
190191
try {
@@ -199,13 +200,13 @@ public synchronized void close() throws TimeoutException {
199200
} catch (InterruptedException e) {
200201
Thread.currentThread().interrupt();
201202
} finally {
202-
fuseScope.close();
203+
fuseArena.close();
203204
}
204205
}
205206

206207
/**
207208
* Decorates the {@link FuseOperations#getattr(String, Stat, FileInfo) getattr} call of a FuseOperations object
208-
* in order to detect accesses to {@value MOUNT_PROBE} system during {@link #waitForMountingToComplete(Path)}.
209+
* in order to detect accesses to {@value MOUNT_PROBE} system during {@link #waitForMountingToComplete(Path, Future)}}.
209210
*
210211
* @param delegate The original FuseOperations object
211212
* @param onObserve Handler to invoke as soon as the desired call is detected

jfuse-linux-aarch64/pom.xml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@
6969
<plugin>
7070
<groupId>io.github.coffeelibs</groupId>
7171
<artifactId>jextract-maven-plugin</artifactId>
72-
<version>0.2.0</version>
72+
<version>0.3.0</version>
7373
<configuration>
74-
<executable>${user.home}/.sdkman/candidates/java/19.ea.jextract/bin/jextract</executable>
74+
<executable>/Users/sebastian/Documents/Cryptomator/jextract/build/jextract/bin/jextract</executable>
7575
<headerSearchPaths>${linux.headerSearchPath}</headerSearchPaths>
7676
<outputDirectory>${project.build.sourceDirectory}</outputDirectory>
7777
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr</targetPackage>
@@ -147,24 +147,24 @@
147147
<configuration>
148148
<headerFile>${linux.headerSearchPath}/errno.h</headerFile>
149149
<headerClassName>errno_h</headerClassName>
150-
<includeMacros>
151-
<includeMacro>ENOENT</includeMacro>
152-
<includeMacro>ENOSYS</includeMacro>
153-
<includeMacro>ENOMEM</includeMacro>
154-
<includeMacro>EACCES</includeMacro>
155-
<includeMacro>EIO</includeMacro>
156-
<includeMacro>EROFS</includeMacro>
157-
<includeMacro>EBADF</includeMacro>
158-
<includeMacro>EEXIST</includeMacro>
159-
<includeMacro>ENOTDIR</includeMacro>
160-
<includeMacro>EISDIR</includeMacro>
161-
<includeMacro>ENOTEMPTY</includeMacro>
162-
<includeMacro>ENOTSUP</includeMacro>
163-
<includeMacro>EINVAL</includeMacro>
164-
<includeMacro>ERANGE</includeMacro>
165-
<includeMacro>ENOLCK</includeMacro>
166-
<includeMacro>ENAMETOOLONG</includeMacro>
167-
</includeMacros>
150+
<includeConstants>
151+
<includeConstant>ENOENT</includeConstant>
152+
<includeConstant>ENOSYS</includeConstant>
153+
<includeConstant>ENOMEM</includeConstant>
154+
<includeConstant>EACCES</includeConstant>
155+
<includeConstant>EIO</includeConstant>
156+
<includeConstant>EROFS</includeConstant>
157+
<includeConstant>EBADF</includeConstant>
158+
<includeConstant>EEXIST</includeConstant>
159+
<includeConstant>ENOTDIR</includeConstant>
160+
<includeConstant>EISDIR</includeConstant>
161+
<includeConstant>ENOTEMPTY</includeConstant>
162+
<includeConstant>ENOTSUP</includeConstant>
163+
<includeConstant>EINVAL</includeConstant>
164+
<includeConstant>ERANGE</includeConstant>
165+
<includeConstant>ENOLCK</includeConstant>
166+
<includeConstant>ENAMETOOLONG</includeConstant>
167+
</includeConstants>
168168
</configuration>
169169
</execution>
170170
<execution>
@@ -175,10 +175,10 @@
175175
<configuration>
176176
<headerFile>${linux.headerSearchPath}/sys/stat.h</headerFile>
177177
<headerClassName>stat_h</headerClassName>
178-
<includeMacros>
179-
<includeMacro>UTIME_NOW</includeMacro>
180-
<includeMacro>UTIME_OMIT</includeMacro>
181-
</includeMacros>
178+
<includeConstants>
179+
<includeConstant>UTIME_NOW</includeConstant>
180+
<includeConstant>UTIME_OMIT</includeConstant>
181+
</includeConstants>
182182
</configuration>
183183
</execution>
184184
<execution>
@@ -189,17 +189,17 @@
189189
<configuration>
190190
<headerFile>${linux.headerSearchPath}/fcntl.h</headerFile>
191191
<headerClassName>fcntl_h</headerClassName>
192-
<includeMacros>
193-
<includeMacro>O_RDONLY</includeMacro>
194-
<includeMacro>O_WRONLY</includeMacro>
195-
<includeMacro>O_RDWR</includeMacro>
196-
<includeMacro>O_APPEND</includeMacro>
197-
<includeMacro>O_CREAT</includeMacro>
198-
<includeMacro>O_TRUNC</includeMacro>
199-
<includeMacro>O_EXCL</includeMacro>
200-
<includeMacro>O_DSYNC</includeMacro>
201-
<includeMacro>O_SYNC</includeMacro>
202-
</includeMacros>
192+
<includeConstants>
193+
<includeConstant>O_RDONLY</includeConstant>
194+
<includeConstant>O_WRONLY</includeConstant>
195+
<includeConstant>O_RDWR</includeConstant>
196+
<includeConstant>O_APPEND</includeConstant>
197+
<includeConstant>O_CREAT</includeConstant>
198+
<includeConstant>O_TRUNC</includeConstant>
199+
<includeConstant>O_EXCL</includeConstant>
200+
<includeConstant>O_DSYNC</includeConstant>
201+
<includeConstant>O_SYNC</includeConstant>
202+
</includeConstants>
203203
</configuration>
204204
</execution>
205205
<execution>
@@ -213,12 +213,12 @@
213213
<cPreprocessorMacros>
214214
<cPreprocessorMacro>_GNU_SOURCE=1</cPreprocessorMacro>
215215
</cPreprocessorMacros>
216-
<includeMacros>
216+
<includeConstants>
217217
<!-- GNU-specific flags for rename: -->
218-
<includeMacro>RENAME_NOREPLACE</includeMacro>
219-
<includeMacro>RENAME_EXCHANGE</includeMacro>
220-
<includeMacro>RENAME_WHITEOUT</includeMacro>
221-
</includeMacros>
218+
<includeConstant>RENAME_NOREPLACE</includeConstant>
219+
<includeConstant>RENAME_EXCHANGE</includeConstant>
220+
<includeConstant>RENAME_WHITEOUT</includeConstant>
221+
</includeConstants>
222222
</configuration>
223223
</execution>
224224
</executions>

jfuse-linux-aarch64/src/main/java/org/cryptomator/jfuse/linux/aarch64/DirFillerImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_fill_dir_t;
66
import org.cryptomator.jfuse.linux.aarch64.extr.stat;
77

8-
import java.lang.foreign.MemoryAddress;
9-
import java.lang.foreign.MemorySession;
8+
import java.lang.foreign.Arena;
9+
import java.lang.foreign.MemorySegment;
10+
import java.lang.foreign.SegmentScope;
1011
import java.util.function.Consumer;
1112

12-
record DirFillerImpl(MemoryAddress buf, fuse_fill_dir_t callback, MemorySession scope) implements DirFiller {
13+
record DirFillerImpl(MemorySegment buf, fuse_fill_dir_t callback, Arena arena) implements DirFiller {
1314

14-
DirFillerImpl(MemoryAddress buf, MemoryAddress callback, MemorySession scope) {
15-
this(buf, fuse_fill_dir_t.ofAddress(callback, scope), scope);
15+
DirFillerImpl(MemorySegment buf, MemorySegment callback, Arena arena) {
16+
this(buf, fuse_fill_dir_t.ofAddress(callback, arena.scope()), arena);
1617
}
1718

1819
@Override
1920
public int fill(String name, Consumer<Stat> statFiller, long offset, int flags) {
20-
var statSegment = stat.allocate(scope);
21+
var statSegment = stat.allocate(arena);
2122
statFiller.accept(new StatImpl(statSegment));
22-
return callback.apply(buf, scope.allocateUtf8String(name).address(), statSegment.address(), offset, flags);
23+
return callback.apply(buf, arena.allocateUtf8String(name), statSegment, offset, flags);
2324
}
2425

2526
}

0 commit comments

Comments
 (0)