Skip to content

[fix][cli] Set --enable-native-access=ALL-UNNAMED for the CLI tools on Java 24+ - #26365

Merged
lhotari merged 1 commit into
apache:masterfrom
lhotari:lh-fix-cli-enable-native-access
Aug 19, 2026
Merged

lhotari merged 1 commit into
apache:masterfrom
lhotari:lh-fix-cli-enable-native-access

Conversation

@lhotari

@lhotari lhotari commented Aug 18, 2026

Copy link
Copy Markdown
Member

Motivation

bin/pulsar passes --enable-native-access=ALL-UNNAMED, but the client-side entry points do
not: bin/pulsar-admin, bin/pulsar-client and bin/pulsar-shell (all of which source
bin/pulsar-admin-common.sh), and bin/pulsar-perf.

Netty loads its native libraries (epoll, io_uring, tcnative) through
java.lang.System::loadLibrary, which became a restricted method in Java 24. Without the flag,
every CLI invocation that ends up loading a Netty native library prints to stderr:

WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::loadLibrary has been called by io.netty.util.internal.NativeLibraryUtil
         in an unnamed module (file:/pulsar/lib/io.netty-netty-common-4.2.17.Final.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

Three reasons this is worth fixing:

  1. It is noise on every affected CLI invocation, and it goes to stderr, so it pollutes scripted
    usage that captures CLI output.
  2. It breaks integration and system tests that assert the CLI writes nothing to stderr
    (ContainerExecResult.assertNoStderr()). This surfaced on the networking dependency update
    [improve][build] Upgrade networking and infrastructure client libraries #26358, where CI - Integration - Cli, CI - System - Function and both
    CI - System - Pulsar Connectors jobs failed on exactly this warning.
  3. As the warning itself says, restricted methods will be blocked in a future release, so
    the CLI tools need this regardless.

Modifications

Added to bin/pulsar-admin-common.sh (covering pulsar-admin, pulsar-client and
pulsar-shell) and to bin/pulsar-perf, which duplicates the same option-building logic:

if [[ $JAVA_MAJOR_VERSION -ge 24 ]]; then
  OPTS="$OPTS --enable-native-access=ALL-UNNAMED"
fi

The Java 24 gate is deliberate, and differs from bin/pulsar, which sets the flag
unconditionally:

  • these CLI scripts still support older Java versions (they carry -gt 8 and -ge 11
    conditionals), and the option is not accepted on Java 8 or 11, so an ungated flag would stop
    the CLI from starting there;
  • the restricted-method warning was only introduced in Java 24, so gating there targets exactly
    the versions where the flag has an effect;
  • bin/pulsar can set it unconditionally because the server requires a newer JVM.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests: the CLI, Function and Connectors
integration/system suites assert that CLI invocations produce no stderr output, which is the
assertion this warning was breaking.

Verified locally:

  • bash -n bin/pulsar-admin-common.sh and bash -n bin/pulsar-perf — both parse cleanly
  • ./gradlew quickCheck
  • Confirmed the JVM accepts --enable-native-access=ALL-UNNAMED

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

The JVM options used by the bundled CLI tools change on Java 24 and later.

…n Java 24+

bin/pulsar passes --enable-native-access=ALL-UNNAMED, but the client-side entry points do
not: bin/pulsar-admin, bin/pulsar-client and bin/pulsar-shell (all of which source
bin/pulsar-admin-common.sh), and bin/pulsar-perf.

Netty loads its native libraries (epoll, io_uring, tcnative) through
java.lang.System::loadLibrary. That is a restricted method as of Java 24, so without the
flag the JVM prints to stderr on every invocation:

  WARNING: A restricted method in java.lang.System has been called
  WARNING: java.lang.System::loadLibrary has been called by
           io.netty.util.internal.NativeLibraryUtil in an unnamed module
  WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
  WARNING: Restricted methods will be blocked in a future release unless native access is enabled

Besides being noise on every CLI invocation, this breaks integration and system tests that
assert the CLI writes nothing to stderr, and the JDK will block restricted methods
outright in a future release.

The flag is gated on Java 24 or later because these scripts still support older Java
versions, where the option is not accepted, and because the warning was only introduced in
Java 24. bin/pulsar can set it unconditionally since the server requires a newer JVM.

Assisted-by: Claude Code (Opus 5)
@lhotari lhotari added this to the 5.0.0-M2 milestone Aug 18, 2026
@lhotari lhotari added the area/dependency Pull requests that update a dependency file label Aug 18, 2026
@lhotari lhotari removed the area/dependency Pull requests that update a dependency file label Aug 18, 2026
@lhotari
lhotari merged commit 68aa11c into apache:master Aug 19, 2026
43 checks passed
lhotari added a commit that referenced this pull request Aug 19, 2026
lhotari added a commit that referenced this pull request Aug 19, 2026
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 28, 2026
Radiancebobo pushed a commit to Radiancebobo/pulsar that referenced this pull request Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants