Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
38371bc
Working on Rust JNI version
DavyLandman Jul 14, 2025
152fab8
Working on running it on remote machine
DavyLandman Jul 14, 2025
b18a6ef
Working on running it on remote machine
DavyLandman Jul 14, 2025
490ea8d
Making rust more default
DavyLandman Jul 14, 2025
f6bd2be
Rust is already there
DavyLandman Jul 14, 2025
4981531
Removing ARC from the fs_monitor
DavyLandman Jul 15, 2025
3cab37a
Try fix FSEventStreamCreate issue
sungshik Jul 15, 2025
df8174b
Fix FSEventStreamCreate issue with context creation
sungshik Jul 15, 2025
f528e93
Update .editorconfig for Rust
sungshik Jul 16, 2025
9769201
Exclude resources dir from editorconfig check
sungshik Jul 16, 2025
cf4aebc
Re-enable all tests in Github Actions
sungshik Jul 16, 2025
48cb1ab
Add default method to NativeEventHandler to work with ints and String…
sungshik Jul 16, 2025
6f72a15
Simplify the files in the `jni` folder into one and move the resultin…
sungshik Jul 16, 2025
0b4b615
Change NativeEventStream to use JNI+Rust instead of JNA with the leas…
sungshik Jul 16, 2025
f8276de
Update simple test to check if JNI+Rust works
sungshik Jul 16, 2025
a58eed6
Reenable full test matrix in GHA
sungshik Aug 13, 2025
afa9242
Remove JNA
sungshik Aug 13, 2025
3a48dde
Simplify conversion from Rust events to NIO events
sungshik Aug 13, 2025
d9eb323
Re-enable special file attributes (`PRIVATE_FILE`) for temporarily co…
sungshik Aug 13, 2025
31b9d09
Remove unneeded Rust dependencies
sungshik Aug 13, 2025
b75b0ac
Add a few comments
sungshik Aug 13, 2025
8e8e54a
Merge branch 'main' into feat/use-rust-and-jni-on-mac-wip
sungshik Aug 13, 2025
0bda05f
Add support for adding license headers to Rust files using `license:f…
sungshik Aug 13, 2025
589811d
Disable macOS-specific tests on non-macOS platforms
sungshik Aug 13, 2025
9ee1391
Add option to script to build libs in release mode (and set it in the…
sungshik Aug 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ end_of_line = lf
[*.java]
indent_size = 4
max_line_length = 120

[*.rs]
indent_size = 4
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
cache: 'maven'
#- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: ./update-rust-jni-libs.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: we should publish these libs in a way that it's available for the release build of the maven lib.

or maybe just run maven package on a osx runner.

if: ${{ matrix.os.image == 'macos-latest' }}

- name: test
run: mvn -B clean test "-Dwatch.mac.backend=${{ matrix.os.mac-backend }}"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ replay_pid*

# release plugin state files
/pom.xml.releaseBackup
/release.properties
/release.properties
24 changes: 13 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,20 @@
<checkerframework.version>3.49.5</checkerframework.version>
<junit.version>5.13.4</junit.version>
<log4j.version>2.25.1</log4j.version>
<jna.version>5.17.0</jna.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<watch.mac.backend>fsevents</watch.mac.backend>
</properties>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>src/main/rust/**/*.*</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin> <!-- configure java compiler -->
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -170,6 +177,11 @@
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>src/main/resources/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin> <!-- use a new version of maven -->
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -229,16 +241,6 @@
<version>${log4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>${jna.version}</version>
</dependency>
</dependencies>

<profiles>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/engineering/swat/watch/impl/jdk/JDKPoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

import engineering.swat.watch.DaemonThreadPool;
import engineering.swat.watch.impl.mac.MacWatchService;
import engineering.swat.watch.impl.mac.NativeLibrary;
import engineering.swat.watch.impl.util.SubscriptionKey;

/**
Expand Down Expand Up @@ -189,7 +190,7 @@ public Watchable newWatchable(Path path) {
static final Platform CURRENT = current(); // Assumption: the platform doesn't change

private static Platform current() {
if (com.sun.jna.Platform.isMac()) {
if (NativeLibrary.isMac()) {
var key = "engineering.swat.java-watch.mac";
var val = System.getProperty(key);
if (val != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
*/
package engineering.swat.watch.impl.mac;

import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import static java.nio.file.StandardWatchEventKinds.OVERFLOW;

import java.nio.file.Path;
import java.nio.file.WatchEvent;
import java.nio.file.WatchEvent.Kind;

import org.checkerframework.checker.nullness.qual.Nullable;

Expand All @@ -51,5 +56,36 @@
*/
@FunctionalInterface
interface NativeEventHandler {
<T> void handle(Kind<T> kind, @Nullable T context);
<T> void handle(java.nio.file.WatchEvent.Kind<T> kind, @Nullable T context);

default void handle(int kindOrdinal, String rootPath, String relativePath) {
if (kindOrdinal < Kind.values().length) {
var kind = Kind.values()[kindOrdinal];
switch (kind) {
case CREATE:
handle(ENTRY_CREATE, toContext(rootPath, relativePath));
break;
case MODIFY:
handle(ENTRY_MODIFY, toContext(rootPath, relativePath));
break;
case DELETE:
handle(ENTRY_DELETE, toContext(rootPath, relativePath));
break;
case OVERFLOW:
handle(OVERFLOW, null);
break;
}
}
}

static Path toContext(String rootPath, String relativePath) {
return Path.of(rootPath).relativize(Path.of(relativePath));
}
}

enum Kind { // Order of values needs to be consistent with enum `Kind` in Rust
OVERFLOW,
CREATE,
DELETE,
MODIFY;
}
Loading
Loading