Skip to content

DOCS: Describe granting native library access - #563

Merged
oleksandrlazarenko-pi merged 4 commits into
mainfrom
feature/476-native-access-docs
Aug 5, 2026
Merged

DOCS: Describe granting native library access#563
oleksandrlazarenko-pi merged 4 commits into
mainfrom
feature/476-native-access-docs

Conversation

@oleksandrlazarenko-pi

@oleksandrlazarenko-pi oleksandrlazarenko-pi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Device detection half of #476.

JEP 472 restricts two operations that on-premise device
detection needs, and they are declared in different repositories:

Restricted operation Declared in Module name
System.load pipeline.engines.fiftyone fiftyone.pipeline.engines.fiftyone
JNI native methods device-detection.hash.engine.on-premise fiftyone.devicedetection.hash.engine.onpremise

All 264 native declarations in this repository are in
DeviceDetectionHashEngineModuleJNI, so granting only the pipeline module would leave a
second warning coming from device detection's own code.

Changes

Adds Automatic-Module-Name to all four packages. Only the on-premise engine needs one
for native access; the rest are named so that the name stays stable for anyone who puts
them on the module path, rather than being derived from the file name:

Package Declared Derived from filename if undeclared
device-detection fiftyone.devicedetection device.detection
device-detection.cloud fiftyone.devicedetection.cloud device.detection.cloud
device-detection.hash.engine.on-premise fiftyone.devicedetection.hash.engine.onpremise device.detection.hash.engine.on.premise
device-detection.shared fiftyone.devicedetection.shared device.detection.shared

Also adds a Native library access section to the README covering the classpath case
(--enable-native-access=ALL-UNNAMED, unchanged and still the default), the module path
case naming both restricted modules, and the module name table.

No source changes. Automatic-Module-Name is a plain manifest entry, so the jars stay
ordinary non-modular jars, build identically on every JDK from 8 upwards, and nothing
changes for consumers who stay on the classpath.

Verification

Built offline with -DskipNativeBuild=true; all four manifests confirmed with
jar --describe-module. Checked there are no split packages between the four packages,
so the distinct names are safe.

Not verified: the JNI binding restriction ships in JDK 24 and only JDK 17 was available,
so the second module name is added on the basis of where the native declarations live
rather than an observed warning.

Depends on the companion pipeline-java PR (51Degrees/pipeline-java#106), which adds the
README section this one links to; merge that first.

Documents --enable-native-access for classpath and module path setups, following the module names added in pipeline-java for #476.
@oleksandrlazarenko-pi oleksandrlazarenko-pi self-assigned this Jul 28, 2026
@justadreamer
justadreamer marked this pull request as ready for review August 5, 2026 11:35

@justadreamer justadreamer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we perhaps need to also name modules in device-detection-java too? not only in pipeline-java?

@justadreamer justadreamer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

requesting changes so the PR does not merge automatically

JEP 472 checks JNI method binding against the module declaring the native methods, which is this package rather than pipeline.engines.fiftyone, so both names are needed. Documents granting native access on the classpath and the module path.

Implements #476.
Adds Automatic-Module-Name to device-detection, device-detection.cloud and device-detection.shared. Only the on-premise engine needs a name for native access, but without a declared name the module system derives one from the file name, which changes if the artifact is renamed or shaded.

Implements #476.
@oleksandrlazarenko-pi

Copy link
Copy Markdown
Contributor Author

do we perhaps need to also name modules in device-detection-java too? not only in pipeline-java?

Yes - and more of them than I first had. Done in the latest push.

Needed. device-detection.hash.engine.on-premise has to be named. JEP 472 restricts
two operations, and they are declared in different repositories:

Restricted operation Declared in Module name
System.load pipeline.engines.fiftyone fiftyone.pipeline.engines.fiftyone
JNI native methods device-detection.hash.engine.on-premise fiftyone.devicedetection.hash.engine.onpremise

All 264 native declarations in this repository are in
DeviceDetectionHashEngineModuleJNI, so granting only the pipeline module would leave a
second warning coming from device detection's own code.

Worth doing anyway. I have named the other three as well, because without a declared
name the module system derives one from the file name. Built both ways to show the
difference:

Package Declared Derived from filename
device-detection fiftyone.devicedetection device.detection
device-detection.cloud fiftyone.devicedetection.cloud device.detection.cloud
device-detection.hash.engine.on-premise fiftyone.devicedetection.hash.engine.onpremise device.detection.hash.engine.on.premise
device-detection.shared fiftyone.devicedetection.shared device.detection.shared

The derived names are what anyone putting these jars on the module path gets today, and
they change if the artifact is ever renamed or shaded. Declaring them costs one manifest
entry per pom and nothing at runtime.

Checked there are no split packages between the four, so the distinct names are safe.
Built offline with -DskipNativeBuild=true and confirmed all four manifests.

The jars stay ordinary non-modular jars - Automatic-Module-Name is a plain manifest
entry, so it is produced identically by a JDK 8 build and a JDK 24 build, and nothing
changes for consumers who stay on the classpath.

One thing I could not verify: the JNI binding warning itself. Only JDK 17 is available
to me and JEP 472 ships in 24, so the second module name rests on where the native
declarations live rather than on an observed warning. Worth a JDK 24 run before we treat
that part of the docs as proven.

The companion pipeline-java PR (51Degrees/pipeline-java#106) has been reworked to
Automatic-Module-Name too, per your review there.

--module-path takes directories or jar files; the "*" wildcard is a
class-path-only feature of the launcher, so "mods/*" found nothing and
the command failed with FindException on the module named by
--add-modules.
@oleksandrlazarenko-pi
oleksandrlazarenko-pi merged commit 2a70c8c into main Aug 5, 2026
1 check passed
@oleksandrlazarenko-pi
oleksandrlazarenko-pi deleted the feature/476-native-access-docs branch August 5, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants