From ae7132312680172d43d9918c593c4ea4cd2a23e0 Mon Sep 17 00:00:00 2001 From: Oleksandr Lazarenko Date: Tue, 28 Jul 2026 10:32:53 +0200 Subject: [PATCH 1/3] DOCS: Add native access flag to example run commands Documents --enable-native-access=ALL-UNNAMED for the fat-jar examples and the module path alternative, per 51Degrees/device-detection-java#476. --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index ce6beed..427546f 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,36 @@ Use them with relevant example class entrypoints like: ```bash java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar fiftyone.devicedetection.examples.console.OfflineProcessing ``` + +### Native library access + +The on-premise examples load a native library through `System.load`. Recent JDKs treat +that as a restricted method and warn unless native access has been granted +(see [JEP 472](https://openjdk.org/jeps/472)). The fat JARs above put everything on the +classpath, so the permission to use is `ALL-UNNAMED`: + +```bash +java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar --enable-native-access=ALL-UNNAMED fiftyone.devicedetection.examples.console.OfflineProcessing +``` + +If you run against the individual pipeline JARs on the module path instead, grant +access to the module that performs the load: + +```bash +java --module-path libs --enable-native-access=fiftyone.pipeline.engines.fiftyone -m your.app/com.example.Main +``` + +See the +[pipeline-java README](https://github.com/51Degrees/pipeline-java#java-modules-and-native-library-access) +for the module names and the caveats that apply on the module path. + +With the Maven exec plugin: + +```xml + + + --enable-native-access=ALL-UNNAMED + ... + + +``` From 9343feffbc1217ea73254bb045cf3f6c31322222 Mon Sep 17 00:00:00 2001 From: Oleksandr Lazarenko Date: Wed, 5 Aug 2026 14:21:21 +0200 Subject: [PATCH 2/3] DOCS: Rework native access guidance for fat jar examples Explains that a fat jar can only use ALL-UNNAMED, since everything inside it is part of the unnamed module, and points at the individual-jar layout that can be narrowed. Per 51Degrees/device-detection-java#476. --- README.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 427546f..fc9e1c8 100644 --- a/README.md +++ b/README.md @@ -103,26 +103,17 @@ java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with ### Native library access -The on-premise examples load a native library through `System.load`. Recent JDKs treat -that as a restricted method and warn unless native access has been granted -(see [JEP 472](https://openjdk.org/jeps/472)). The fat JARs above put everything on the -classpath, so the permission to use is `ALL-UNNAMED`: +The on-premise examples use a native library, and +[JEP 472](https://openjdk.org/jeps/472) restricts the operations needed to load it. +Java 24 and 25 warn once per calling module, and a later release will refuse the call. -```bash -java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar --enable-native-access=ALL-UNNAMED fiftyone.devicedetection.examples.console.OfflineProcessing -``` - -If you run against the individual pipeline JARs on the module path instead, grant -access to the module that performs the load: +The fat JARs above bundle everything into a single jar on the classpath, so the +permission to use is `ALL-UNNAMED`: ```bash -java --module-path libs --enable-native-access=fiftyone.pipeline.engines.fiftyone -m your.app/com.example.Main +java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar --enable-native-access=ALL-UNNAMED fiftyone.devicedetection.examples.console.OfflineProcessing ``` -See the -[pipeline-java README](https://github.com/51Degrees/pipeline-java#java-modules-and-native-library-access) -for the module names and the caveats that apply on the module path. - With the Maven exec plugin: ```xml @@ -133,3 +124,9 @@ With the Maven exec plugin: ``` + +A fat jar cannot narrow this any further, because everything inside it is part of the +unnamed module. To grant native access to 51Degrees code alone you need the individual +jars, with `pipeline.engines.fiftyone` and `device-detection.hash.engine.on-premise` on +the module path - see the +[device-detection-java README](https://github.com/51Degrees/device-detection-java#native-library-access). From 79e53bd4bdaeea9e743e12bb03740c2c1355c760 Mon Sep 17 00:00:00 2001 From: Eugene Dzhurinsky Date: Wed, 5 Aug 2026 21:34:30 +0200 Subject: [PATCH 3/3] DOCS: Correct the exec plugin snippet and command paths The snippet had no goal or executable. exec:java runs in the Maven JVM and passes to main, so --enable-native-access there is silently ignored; only exec:exec with java forks a JVM that takes the flag. The run commands used Windows-style backslashes inside a bash fence, where they are escapes rather than separators. --- README.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fc9e1c8..61a4c91 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ will produce "fat" JARs inside `target` subfolders. Use them with relevant example class entrypoints like: ```bash -java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar fiftyone.devicedetection.examples.console.OfflineProcessing +java -cp ./console/target/device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar fiftyone.devicedetection.examples.console.OfflineProcessing ``` ### Native library access @@ -111,18 +111,24 @@ The fat JARs above bundle everything into a single jar on the classpath, so the permission to use is `ALL-UNNAMED`: ```bash -java -cp .\console\target\device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar --enable-native-access=ALL-UNNAMED fiftyone.devicedetection.examples.console.OfflineProcessing +java -cp ./console/target/device-detection-java-examples.console-4.4.20-jar-with-dependencies.jar --enable-native-access=ALL-UNNAMED fiftyone.devicedetection.examples.console.OfflineProcessing ``` -With the Maven exec plugin: +With the Maven exec plugin, use the `exec:exec` goal. `exec:java` runs in the Maven JVM +and its `` are passed to `main`, so a JVM flag there has no effect: ```xml - - - --enable-native-access=ALL-UNNAMED - ... - - + + org.codehaus.mojo + exec-maven-plugin + + java + + --enable-native-access=ALL-UNNAMED + ... + + + ``` A fat jar cannot narrow this any further, because everything inside it is part of the