Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure compatibility with JDK 20 #30185

Closed
sbrannen opened this issue Mar 24, 2023 · 2 comments
Closed

Ensure compatibility with JDK 20 #30185

sbrannen opened this issue Mar 24, 2023 · 2 comments
Assignees
Labels
type: task A general task

Comments

@sbrannen
Copy link
Member

sbrannen commented Mar 24, 2023

Overview

We need to ensure that the core Spring Framework is compatible with JDK 20.

CI Builds

We have introduced a JDK 20 CI build pipeline to test compatibility with JDK 20.

Failing Tests

We have discovered that numerous tests begin to fail on JDK 20.

The ones related to JPA have been failing since JDK 18 but should still be investigated to determine why they no longer pass (and eventually better documented).

Other tests related to date/time parsing and formatting fail because of a switch from a normal space to a narrow non-breaking space (NNBSP) between a time and an AM/PM unit (for example, the whitespace in 12:00 AM). See commit 84714fb for details.

Related Resources

@sbrannen sbrannen added the type: task A general task label Mar 24, 2023
@sbrannen sbrannen added this to the 6.0.8 milestone Mar 24, 2023
@sbrannen sbrannen changed the title Run test suite against JDK 20 Test compatibilty with JDK 20 Mar 24, 2023
sbrannen referenced this issue Mar 24, 2023
This commit configures Java 20 for compatibility tests in our CI,
replacing Java 19.
sbrannen added a commit that referenced this issue Mar 24, 2023
sbrannen added a commit that referenced this issue Mar 24, 2023
After setting up a JDK 20 CI build pipeline, numerous tests involving
date/time parsing and formatting began to fail [0]. (The failing JPA
tests are not specific to JDK 20.)

For example, we encounter visually confusing assertion failures such as
the following.

org.opentest4j.AssertionFailedError:
	expected: "12:00 PM"
	but was:  "12:00 PM"

The expected string contains a normal space (which has always been the
case prior to JDK 20); whereas, the actual string now contains a narrow
non-breaking space.

The cause of this is mentioned in the JDK 20 Release Notes [1] as "NBSP
prefixed to a, instead of a normal space". Note, however, that the
links for the first two bullet points in that section are mixed up.
"NBSP prefixed to a, instead of a normal space" should point to [2].
Furthermore, the new whitespace character is not a non-breaking space
(NBSP) but rather a narrow non-breaking space (NNBSP). In addition, the
second bullet point should technically read "NNBSP prefixed to `a`,
instead of a normal space" -- even though `a` provides limited value to
most readers.

The downside for the Java community is that this constitutes a breaking
change for parsing and formatting date/time values that include "AM"
and "PM" units (any may potentially apply to other date/time
parsing/formatting scenarios). In Spring Framework's test suite we have
witnessed this in conjunction with Spring's @DateTimeFormat and
DateTimeFormatterFactory infrastructure as well as with Google's
Gson-to-JSON support.

A colleague who works at Oracle graciously informed me that one can use
"legacy locale data" by supplying `-Djava.locale.providers=COMPAT` as a
JVM argument, noting however that this option limits some newer
functionalities (but without enumerating which new functionalities one
might be missing when using this option).

In any case, this commit adds that JVM argument to our Gradle toolchain
builds so that our test suite passes on JDK 20, and we will continue to
investigate further options for our builds and for our users.

Note, however, that one must manually configure the
`-Djava.locale.providers=COMPAT` JVM argument when running affected
tests within an IDE.

See gh-30185

[0] https://ge.spring.io/s/kmiq2bz2afafs/tests/overview?outcome=failed
[1] https://jdk.java.net/20/release-notes#JDK-8284840
[2] https://unicode-org.atlassian.net/browse/CLDR-14032
@sbrannen sbrannen changed the title Test compatibilty with JDK 20 Ensure compatibilty with JDK 20 Mar 24, 2023
@NPException
Copy link

Just commenting to add another bug report with the same cause: https://bugs.openjdk.org/browse/JDK-8304925

@jhoeller jhoeller changed the title Ensure compatibilty with JDK 20 Ensure compatibility with JDK 20 Mar 28, 2023
@sbrannen sbrannen modified the milestones: 6.0.8, 6.0.9 Apr 4, 2023
@snicoll snicoll modified the milestones: 6.0.9, 6.0.x Apr 7, 2023
@bclozel bclozel removed their assignment May 22, 2023
@sbrannen
Copy link
Member Author

Issues with the build have already been addressed, and I've created the following two follow-up issues.

I am therefore closing this issue as superseded.

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2023
@sbrannen sbrannen removed this from the 6.0.x milestone Jun 12, 2023
sbrannen added a commit that referenced this issue Jul 4, 2024
Commit 84714fb introduced usage of the
-Djava.locale.providers=COMPAT command-line argument for javac in order
to allow our JDK 20 builds to pass by using legacy locale data.

That was done to ensure that Date/Time formats using AM/PM produced a
standard space (" ") before the "AM" or "PM" instead of a narrow
non-breaking space (NNBSP "\u202F"), which was introduced in Java 20
due to adoption of Unicode Common Locale Data Repository (CLDR-14032).

This commit removes usage of the -Djava.locale.providers=COMPAT
command-line argument and updates all affected tests to:

- Use an NNBSP before "AM" or "PM" in input text when running on Java 20
  or higher.

- Leniently match against any Unicode space character in formatted
  values containing "AM" or "PM".

See https://jdk.java.net/20/release-notes#JDK-8284840
See https://unicode-org.atlassian.net/browse/CLDR-14032
See gh-30185
Closes gh-33144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants