Repository navigation
[4.4.x] Add --add-opens java.base/sun.nio.ch=ALL-UNNAMED - #3144
Merged
Merged
Conversation
Code that reflects on sun.nio.ch internals, for example to tune NIO sockets or selectors, fails with InaccessibleObjectException on JDK 17+ unless the package is opened to the unnamed module. Add the flag next to the other java.base opens on every launch path: - bin/karaf and bin/karaf.bat - child instances started by instance:start (InstanceServiceImpl) - service wrapper configurations (unix, windows, windows64) - Pax Exam options in KarafTestSupport and KarafMinimalMonitoredTestSupport Backport of apache#3143.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #3143 to
karaf-4.4.x. Fixes #2299 on 4.4.x.Context
Code that reflects on
sun.nio.chinternals, for example to tune NIO sockets or selectors, fails withInaccessibleObjectExceptionon JDK 17+ unless the package is opened.karaf-4.4.xdoesn't open it on any launch path either. On JDK 11 the default--illegal-access=permitstill allows it with a warning, so the change matters for 4.4.x users on JDK 17 and 21.Changes
Same as #3143.
--add-opens java.base/sun.nio.ch=ALL-UNNAMEDis added next to the otherjava.baseopens in:bin/karafandbin/karaf.bat(in the JDK 9+ branch)InstanceServiceImpl, for child instances started byinstance:startunix,windowsandwindows64karaf-wrapper-java11.confKarafTestSupportandKarafMinimalMonitoredTestSupportThe cherry-pick conflicted only on context lines, because 4.4.x has the
--add-reads/--patch-moduleoptions and no--enable-native-access. The flag was re-applied at the same place in each list, andbin/karaf.batkeeps its CRLF line endings.Testing
apache-karaf4.4.13-SNAPSHOT distribution built from this branch (full reactor, compiled for Java 11). The probe, run from the console, is(($.context bundle 0) loadClass "sun.nio.ch.SelectorImpl") getDeclaredField "selectedKeys"followed bytrySetAccessible:trySetAccessiblebin/karafwithout the flag (control)falsebin/starttrueinstance:create+instance:starttruewrapper:install: generatedetc/karaf-wrapper.confJDK_JAVA_OPTIONS)bin/karafwithout the flag (control)true, plus anIllegal reflective access ... to field sun.nio.ch.SelectorImpl.selectedKeyswarningbin/starttrue, no warningThe bundled macOS wrapper binary is a PowerPC Mach-O, so the wrapper itself can't run on a current Mac. On
main(#3143), starting Karaf with the generatedJDK_JAVA_OPTIONSvalue gavetrue. That emulation doesn't work on 4.4.x, because the value repeats the--patch-moduleoptionsbin/karafalready passes.mvn test -pl instance: 32 tests, 0 failures.itests/test,-Dtest=InstanceTest,SystemTest,MavenResolverRegisteredBeforeConfigAdminTest,MavenResolverRegisteredOnlyAfterConfigAdminTest: 18 tests, 0 failures, 2 skipped (the two MavenResolver tests are@Ignored on 4.4.x).pson a running Pax Exam container shows the new option.