Skip to content

Support Java 25 runtime compatibility#424

Open
robertpatrick wants to merge 1 commit into
jython:masterfrom
robertpatrick:gh-413-jdk25-compat
Open

Support Java 25 runtime compatibility#424
robertpatrick wants to merge 1 commit into
jython:masterfrom
robertpatrick:gh-413-jdk25-compat

Conversation

@robertpatrick
Copy link
Copy Markdown

@robertpatrick robertpatrick commented May 9, 2026

Fixes #413

Summary

This PR updates Jython for runtime compatibility with JDK 25 while keeping the release built with the lowest supported JDK target. The release artifacts were built with JDK 8 and then tested on JDK 8, 11, 17, 21, and 25 from the same build output. No multi-release JAR was needed.

This builds on the already-merged jffi update from #409 and incorporates/adapts fixes from:

Changes

  • Add JDK 25 runtime launcher support:
    • --enable-native-access=ALL-UNNAMED
    • --sun-misc-unsafe-memory-access=allow
  • Add JDK 9+ launcher/module opens needed by current runtime dependencies:
    • java.base/java.io
    • java.base/sun.nio.ch
  • Add matching manifest attributes to runtime/test jars:
    • Enable-Native-Access: ALL-UNNAMED
    • Add-Opens: java.base/java.io java.base/sun.nio.ch
  • Update ASM from 9.7 to 9.9.1.
  • Add jython.test.java.opts so CI/test runs can pass Java proxy/system properties without editing build files.
  • Added new test-built Ant target that runs the tests without calling developer-build
  • Adjust version-sensitive tests for behavior changes in newer JDKs.
  • Skip SecurityManager and class-unloading leak tests where they are no longer valid on JDK 25.
  • Improve proxy-aware network tests while preserving direct localhost behavior.
  • Make modjy test failures propagate as process failures.
  • Suppress test-only noisy Netty logging from deliberate httplib socket error paths.
  • Release any partially consumed Netty socket buffer held in incoming_head during socket close.
  • Make test_mailbox.test_clean robust against stale deterministic tmp/foo and tmp/bar files.
  • Copy profile.properties into dist/javalib and adjust the bundled JIP profiler properties so the Java 8/11 --profile launcher tests produce output without noisy agent stack traces.
  • On Java 13+, report --profile as unsupported because the bundled Java Interactive Profiler agent is not compatible with modern class verification.

Proxy-sensitive network tests

When an external HTTP proxy is configured, this PR skips only the network cases that cannot work through an HTTP proxy:

  • test_urllib2net external FTP test is skipped when an external HTTP proxy is configured because it requires direct FTP access. Neither FTP-over-HTTP-proxy support nor Java FTP proxy property support is implemented in this PR.
  • test_ssl_jy raw external SSL socket tests are skipped because they open raw sockets and cannot use HTTP CONNECT.
  • test_smtpnet raw external SMTP SSL tests are skipped because they require direct SMTP-over-SSL socket access.

Higher-level external HTTPS tests were adjusted to use CONNECT where appropriate. Localhost/direct tests continue to run directly.

The relevant generic configuration surfaces for proxied test environments are:

  • Environment variables: http_proxy, https_proxy, no_proxy.
  • Java system properties passed through jython.test.java.opts system property:
    • http.proxyHost
    • http.proxyPort
    • http.nonProxyHosts
    • https.proxyHost
    • https.proxyPort
    • https.nonProxyHosts.

Validation

Release artifacts were built with JDK 8 using ant clean full-build:

  • dist/jython.jar
  • dist/jython-standalone.jar
  • dist/jython-installer.jar

The resulting artifacts still target JDK 8 bytecode/release metadata.

The regression matrix was run with:

  • JDK 8: ant test
  • JDK 11: ant test-built
  • JDK 17: ant test-built
  • JDK 21: ant test-built
  • JDK 25: ant test-built

Results:

  • JDK 8: 388 tests OK, 2 tests skipped; modjy OK (104 tests); BUILD SUCCESSFUL.
  • JDK 11: 388 tests OK, 2 tests skipped; modjy OK (104 tests); BUILD SUCCESSFUL.
  • JDK 17: 388 tests OK, 2 tests skipped; modjy OK (104 tests); BUILD SUCCESSFUL.
  • JDK 21: 388 tests OK, 2 tests skipped; modjy OK (104 tests); BUILD SUCCESSFUL.
  • JDK 25: 388 tests OK, 2 tests skipped; modjy OK (104 tests); BUILD SUCCESSFUL.

The two top-level skipped tests are existing resource-gated tests:

  • test_codecmaps_hk, requires urlfetch
  • test_curses, requires curses

They are not JDK 25 failures and are not proxy-related.

Additional focused checks used during development included JDK 25 command-line behavior, float behavior, imports, Java integration, subprocess/threading behavior, HTTP/URL handling, warning suppression, test_mailbox cleanup, and JDK 21/JDK 25 socket/SSL behavior.

@ohumbel
Copy link
Copy Markdown
Contributor

ohumbel commented May 10, 2026

This sounds promising!

On which platform, and with which exact command did you run the regression tests?
I'd like to reproduce them.

@robertpatrick
Copy link
Copy Markdown
Author

robertpatrick commented May 10, 2026

I ran this on my Mac laptop. Are there additional tests other than the CI tests Codex ran? Happy to run those if you point me in the right direction...

ant init regrtest-unix-ci

@robertpatrick robertpatrick force-pushed the gh-413-jdk25-compat branch from 777dcbc to 4e8bac7 Compare May 11, 2026 02:24
@robertpatrick
Copy link
Copy Markdown
Author

@ohumbel I expanded the scope of the PR. I ran the following commands:

  • JDK8: ant clean full-build and ant test
  • JDK11: ant test-built
  • JDK17: ant test-built
  • JDK21: ant test-built
  • JDK25: ant test-built

Let me know if there is anything else I can do to help.

@ohumbel
Copy link
Copy Markdown
Contributor

ohumbel commented May 11, 2026

@ohumbel I expanded the scope of the PR. I ran the following commands:

* JDK8: `ant clean full-build` and `ant test`

@robertpatrick When running ant test, I get:

launchertest-built:
     [exec] + '/var/folders/g9/t4tbc7x57jn74ch4g1978c3w0000gn/T/test-jython.XXXXXX.3PA6YJJSWP/directory with spaces/bin/jython' -J-version
     [exec] ++ egrep -c '^java version '
     [exec] + '[' 0 == 1 ']'

BUILD FAILED
/Users/oti/stuff/gitrepo/robertpatrick/jython/build.xml:1493: exec returned: 1

Total time: 1 minute 15 seconds

The same error both on Mac and Ubuntu, using Java 8:

java -version 
openjdk version "1.8.0_492"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_492-b09)
OpenJDK 64-Bit Server VM (Temurin)(build 25.492-b09, mixed mode)

@robertpatrick robertpatrick force-pushed the gh-413-jdk25-compat branch from 4e8bac7 to a4d3939 Compare May 11, 2026 13:16
@robertpatrick
Copy link
Copy Markdown
Author

@ohumbel Sorry, I don't use Open JDK. PR updated, please try again.

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.

Jython 2.7.5 release with Java 25 support

2 participants