Skip to content

Approach Java 25 compatibility by stages - #435

Merged
jeff5 merged 12 commits into
jython:masterfrom
jeff5:java25-in-stages
Jul 8, 2026
Merged

jeff5 merged 12 commits into
jython:masterfrom
jeff5:java25-in-stages

Conversation

@jeff5

@jeff5 jeff5 commented Jun 15, 2026

Copy link
Copy Markdown
Member

The objective is to break #424 into sections with a purpose. I have already dealt with JAR updates in #431 and #432, and we have a way of testing against Java 17 and 25 in the CI that currently fails (of course) but may be run on demand.

The first stage is the changes affecting tests that improve stability and allow them to run in an environment where Internet access is via a proxy.

These changes improve stability of network tests, especially the impact of tear-down, and our ability to run network tests behind an HTTP proxy. These changes are cherry-picked from PR 424 whose author we credit as author here.

We update lib-python/2.7/test/test_urllib2net.py from CPython 2.7.18 because the modified Lib/test/test_urllib2net.py is based on that.
Comment thread lib-python/2.7/test/test_urllib2net.py Resolved
@jeff5

jeff5 commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

The "Java versions regrtest 2.7" action runs the usual regression test on Java 17 and 25, on Ubuntu and Windows. With the stability and proxy change in place, the baseline results are:
17, Ubuntu:

     [exec] 4 fails unexpected:
     [exec]     test_httplib test_os test_posix test_socket

17, Windows:

     [exec] 1 fail unexpected:
     [exec]     test_httplib

25, Ubuntu:

     [exec] 11 fails unexpected:
     [exec]     test_cmd_line test_float_jy test_httplib test_java_integration
     [exec]     test_json test_jy_internals test_os test_posix test_socket
     [exec]     test_subprocess test_threading

25, Windows:

     [exec] 8 fails unexpected:
     [exec]     test_cmd_line test_float_jy test_httplib test_java_integration
     [exec]     test_json test_jy_internals test_subprocess test_threading

This is the baseline against which to measure progress adding the changes specific to Java 25 from #424.

robertpatrick and others added 2 commits June 16, 2026 17:37
This change is cherry-picked from PR 424.

We'll regenerate the Windows laucher (compiled from jython.py)
in a second step.
This was created from jython.py with PyInstaller.
@jeff5

jeff5 commented Jun 16, 2026 •

Copy link
Copy Markdown
Member Author

Here I've taken just the improvements to the jython launcher script (used on Unix-like systems) and the jython.py launcher from #424, then regenerated the jython.exe launcher by steps described here but which we should add to the process docs. This ought to close #426, probably after compatible changes to the launcher test.

Some of the changes in #424 seem to be compensating the absence of this windows launcher in compiled form, or or any launcher (e.g. in the Ant script), providing options that the launcher(s) will supply. So let's see what additional passes we get just by fixing the launchers.

@jeff5

jeff5 commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

That's a lot better. New results are:
17, Ubuntu:

     [exec] 1 fail unexpected:
     [exec]     test_socket

17, Windows: passes
25, Ubuntu:

     [exec] 4 fails unexpected:
     [exec]     test_float_jy test_java_integration test_jy_internals test_socket

25, Windows:

     [exec] 3 fails unexpected:
     [exec]     test_float_jy test_java_integration test_jy_internals

The test_socket failures are all [Errno 98] Address already in use, which is often flakiness in tear-down of a test.

Comment thread src/shell/jython.py
return [self.java_mem, self.java_stack]

@property
def java_major_version(self):

@Stewori Stewori Jun 18, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See #426 (comment)
Parsing output of java -version is not reliable, there are better ways.
Parsing output of java -XshowSettings:properties is recommended if a java call is deemed acceptible at all. Perhaps cleaner, cheaper, more lightweight is to read java_home/release. calling java could be a fallback if that file does not exist.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The bit in quotes output by the standard option -version seems to be exactly java.version, output by the non-standard option -XshowSettings:properties. It's hard to favour the latter, and for now, I'd leave it.

@Stewori Stewori Jul 7, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my comment here: #426 (comment)
I acknowledged that -X is non-standard and should not be used. It's a pity that Java has no standard way of version detection. -version does not count because its output is unspecified. A de-facto standard, not a standard. It looks like the new intended standard way to do this is indeed the java_home/release file, so that way should be preferred.
If you don't want this tackled for 2.7.5, this is fine (although I offered to do it when I wrote that comment). But we should move to the standard way on this matter eventually.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's still open to you to give a better response to #426 than I have by compiling jython.py as Robert has provided it.

I thought the little class providing version in the optimum form was simplest and certain to find the same java executable we're about to use for Jython. (It could be in the Jython JAR, even if other code in there could not run with the same options.)

Something that requires JAVA_HOME to be right, doesn't sound as reliable, and running java to find property java.home begins to get circular.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we're all happy with the rest of this, I'll merge it.

@robertpatrick robertpatrick Jul 7, 2026 •

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.

And then you go to MacOS where java is /usr/bin/java and the JAVA_HOME is in /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home... :-)

Personally, I would throw an error if JAVA_HOME does not point to a valid Java installation...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, readlink -f $(which java). Does that work on MacOS, too?

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.

It "works" but I'm not sure it helps...

rpatrick@rpatrick-mac1 ~ % readlink -f $(which java)
/usr/bin/java
rpatrick@rpatrick-mac1 ~ % 

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Windows cmd does not have something similar?

It's where (or where.exe). It isn't a shell built-in.

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.

Yes, Windows has a where command but it works differently than which. where returns all paths to the program in the PATH but which only returns the first entry in the path.

C:\Users\rpatrick>where java
c:\java\jdk1.8.0_491\bin\java.exe
c:\java\jdk-11.0.9\bin\java.exe
c:\java\jdk-17.0.16\bin\java.exe
c:\java\jdk-21.0.8\bin\java.exe
c:\java\jdk-25.0.4\bin\java.exe
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe

C:\Users\rpatrick>

@robertpatrick

Copy link
Copy Markdown
Contributor

The test_socket failures are all [Errno 98] Address already in use, which is often flakiness in tear-down of a test.

This is what I was trying to fix in the tests. In many of these tests, the previous test is relying on garbage collection rather than explicit cleanup of sockets listening on a port. That creates a race condition when a subsequent test tries to bind to the same port, making the tests flaky...

@jeff5

jeff5 commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

The test_socket failures are all [Errno 98] Address already in use, which is often flakiness in tear-down of a test.

This is what I was trying to fix in the tests. In many of these tests, the previous test is relying on garbage collection rather than explicit cleanup of sockets listening on a port. That creates a race condition when a subsequent test tries to bind to the same port, making the tests flaky...

I was disappointed too. I thought I had incorporated all such changes into the first commit on this branch, but have I missed something?

@robertpatrick

robertpatrick commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Some of the changes in #424 seem to be compensating the absence of this windows launcher in compiled form

No. Not everyone uses (or can use) this compiled Windows launcher; for example, WLST doesn't. We can get by without this compiled Windows launcher. I filed the issue simply for completeness.

@robertpatrick

Copy link
Copy Markdown
Contributor

I was disappointed too. I thought I had incorporated all such changes into the first commit on this branch, but have I missed something?

If you look back at the comments on #424, you will see that I said that I tried to fix the race conditions I ran into but that there are likely others. It is not easy to find race conditions without running into them.

@jeff5

jeff5 commented Jun 20, 2026

Copy link
Copy Markdown
Member Author

On further thought, I think the re-run of test_socket is misleading. Sure test_socket fails, and fails to close a socket I expect, but when regrtest runs that suite again verbose, they all fail for that reason. The original cause is buried. I need to run the failing suites verbose on a fresh machine.

@jeff5

jeff5 commented Jun 20, 2026 •

Copy link
Copy Markdown
Member Author

Some of the changes in #424 seem to be compensating the absence of this windows launcher in compiled form

No. Not everyone uses (or can use) this compiled Windows launcher; for example, WLST doesn't. We can get by without this compiled Windows launcher. I filed the issue simply for completeness.

By "some of them" I mean where a test does use the launcher, including in build.xml, we don't need to add those arguments.

@robertpatrick

Copy link
Copy Markdown
Contributor

@jeff5 any ETA on getting all of the JDK 25 changes merged? My company needs a version of Jython supporting JDK 25 before the end of July. It seems unlikely to me that even a first alpha version of jython will be tagged and ready by that point. If not, that leaves us with only bad options...

@jeff5

jeff5 commented Jun 28, 2026 •

Copy link
Copy Markdown
Member Author

@robertpatrick It deserves a more credible estimate, it is true. Unfortunately, a few hard to ignore issues/PRs (not just yours) came in after that estimate.

@robertpatrick

Copy link
Copy Markdown
Contributor

@jeff5 well...that is what professional software development is all about.

I gave you a PR that completed the JDK25 support but you chose not to use it because it didn't meet some arbitrary metric. You claimed you would merge it in pieces but that was 6 weeks ago. I see little evidence that this will be merged in the next 5 weeks.

My company will be forced to fork Jython in order to maintain our release schedules for JDK 25 support. I feel sorry that it came to this.

This brings in an action for verbose tests on Linux.
@jeff5

jeff5 commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Annoyingly, the focussed verbose tests didn't explain why test_socket fails on Ubuntu. https://github.com/jeff5/jython/actions/runs/28575947697/job/84724433340

No surprises in the others so I'll knock them off next with Robert's code.

This change is cherry-picked from PR 424.

We are able to add this having regenerated the Windows laucher
(compiled from jython.py).
These adapt to Java 17 and 25 differences. We only need what the launchers themselves do not add.

This change is cherry-picked from PR 424.
A long-standing Java bug has been fixed in Java 19.

This change is cherry-picked from PR 424.
The currency symbol in the Chinese mainland locale has changed.
We also bring in the Java 25 changes to build.gradle at this point,
since it runs the Java tests.

This change is cherry-picked from PR 424 with improvements.
@jeff5

jeff5 commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

The latest change, to address a change to the currency symbol in the Chinese mainland locale, includes an addition I made because our parsing of the major version number was failing. My fault if it is still wrong. (I wonder why we take this approach? But I've kept the change minimal.)

At first the additional --enable-native-access=ALL-UNNAMED in the Gradle build seemed to have no effect: I still got the warning about it on running .\gradlew test. However, I find that to be a result of keeping a rather old Gradle version that doesn't believe in Java after 21. Force the decision logic and it works as expected on Java 25, but I'm not leaving that hack in. (I've left in the debug output that reveals the problem.)

Updating Gradle is the right course but has always entailed a lot of painful change, so not right now thanks.

@jeff5

jeff5 commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

I am getting good conformance now in tests I launch maually to run on Java 17 and 25. https://github.com/jeff5/jython/actions/runs/28709014459, although test_socket fails most of the time with error: [Errno 98] Address already in use. However, from the focussed verbose tests I can see that it does not always fail first in the same test:
https://github.com/jeff5/jython/actions/runs/28708482162/job/85137979475#step:11:652
https://github.com/jeff5/jython/actions/runs/28705796950/job/85136377020#step:11:652
I think this tells me that the failures are due to races.

The change adds a test tearDown() to remove the proxy_handler.
(Suspect the one in lib-python/2.7 to be erroneously modified.)

This change is cherry-picked from PR 424.
@jeff5

jeff5 commented Jul 5, 2026 •

Copy link
Copy Markdown
Member Author

The only things I think are left to include from #424 are the shadowing of test_urllib2_localnet, and the extensive changes to build.xml. Plus there is some modjy-related change I'll pick into another PR.

I think the new test_urllib2_localnet includes is a necessary correction to a defective test_urllib2_localnet in lib-python/2.7. (I suspect that isn't a CPython original and there should've been a shadow all along.) So just pushed that.

I'm accepting the changes to build.xml that affect the JAR manifests, and a few other small things. The stuff involving JAVA_OPTS is not necessary now the Windows launcher has been updated from the Python one. (The build file works as it is.) The splitting of many targets into X and X-built isn't wrong but it's churn.

This change is cherry-picked from PR 424.
@jeff5
jeff5 marked this pull request as ready for review July 5, 2026 19:57
@jeff5

jeff5 commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

I would probably merge this with a merge commit. Not a squash, since that defeats the objective of unpacking it so carefully.

@jeff5

jeff5 commented Jul 6, 2026 •

Copy link
Copy Markdown
Member Author

The splitting of many targets into X and X-built isn't wrong but it's churn.

Ok, I see how this benefits us building on Java 8 and testing on other versions. (Without it, there is always a tiny amount of recompilation.) I'll add.

Also NEWS updated.

This change is cherry-picked from PR 424.
@jeff5 jeff5 added this to the 2.7.5 milestone Jul 7, 2026
@jeff5
jeff5 merged commit 48595b2 into jython:master Jul 8, 2026
8 checks passed
ohumbel pushed a commit to ohumbel/jython that referenced this pull request Aug 20, 2026
This merges a series of change sets, each addressing some aspect of Java 25 support in Jython. They were provided originally as one large change set in PR 424. We prefer this presentation because it makes the changes easier to understand for subsequent maintainers.

Conflicts:
 build.gradle
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.

Windows native launcher should auto-add JDK 9+/25 compatibility args Jython 2.7.5 release with Java 25 support

3 participants