Skip to content

Allow native access in JDK 25#410

Open
wfouche wants to merge 1 commit intojython:masterfrom
wfouche:dev/enable-native-access
Open

Allow native access in JDK 25#410
wfouche wants to merge 1 commit intojython:masterfrom
wfouche:dev/enable-native-access

Conversation

@wfouche
Copy link
Copy Markdown
Member

@wfouche wfouche commented Dec 20, 2025

Without this PR fix applied, Jython displays the following warning when using Java 25:

$ java -jar dist/jython-standalone.jar
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::loadLibrary has been called by org.fusesource.hawtjni.runtime.Library in an unnamed module (file:/C:/Users/wfouche/IdeaProjects/jython/dist/jython-standalone.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

Jython 2.7.5a1-SNAPSHOT (heads/dev/console-utf8:26b2e12c0, Mar 11 2026, 11:27:16)
[OpenJDK 64-Bit Server VM (Eclipse Adoptium)] on java25.0.2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

With the fix applied, the warning is suppressed.

$ java -jar dist/jython-standalone.jar
Jython 2.7.5a1-SNAPSHOT (heads/dev/enable-native-access:524cabda9, Mar 11 2026, 11:40:02)
[OpenJDK 64-Bit Server VM (Eclipse Adoptium)] on java25.0.2
Type "help", "copyright", "credits" or "license" for more information.
>>>

To be considered for inclusion in Jython 2.7.5

@wfouche
Copy link
Copy Markdown
Member Author

wfouche commented Dec 20, 2025

@jeff5 , please review this PR.

@wfouche
Copy link
Copy Markdown
Member Author

wfouche commented Mar 11, 2026

@Stewori , please review this PR.

@Stewori
Copy link
Copy Markdown
Member

Stewori commented Mar 11, 2026

Yes, I took a look. IIRC we discussed the idea somewhere else earlier. I was concerned to simply bypass this safety measure in Java, at least as long as it's just a warning. Given that they announce to block it more strictly it is probably indeed the most future-proof decision to adjust this as you suggest. To keep for Jython the "business as usual". I am certain, Jeff will find time to look at this before release. It won't be forgotten, I just won't merge it right now without a second opinion.

@jeff5 jeff5 added this to the 2.7.5 milestone Apr 4, 2026
@jeff5
Copy link
Copy Markdown
Member

jeff5 commented Apr 5, 2026

I tagged this to cover the "not forgetting" part of Stefan's promise.

@jeff5
Copy link
Copy Markdown
Member

jeff5 commented Apr 5, 2026

@Stewori We had a similar conversation about access to private members under python.security.respectJavaAccessibility=false, and there we thought we should fix the cause where we could and leave the noise where we couldn't fix the cause, rather than suppress the warning. The threat was that it would stop working altogether sometime, and we didn't want that to be a surprise.

The logic here is different. Here, we seem to have a (permanent) option to enable the behaviour. I would not do that in the JARs we offer as Java dependencies, since it should be up to the consuming application. For the standalone JAR, that feels ok.

A bit of hunting around shows that the cause is our use of a long superseded JLine version. (I've never had the stomach for the changes necessary to update it.) However, if you don't use JLine, it just happens somewhere else.

PS 274-trial> java "-Dpython.console=org.python.core.PlainConsole" -jar .\kit\jython-standalone.jar
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in an unnamed module (file:/C:/Users/Jeff/Documents/Jython/274-trial/kit/jython-standalone.jar)
...

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.

3 participants