Fix JDK 26 compatibility in CharsetsTest for ArrayEncoder API change#6902
Merged
JasonFengJ9 merged 1 commit intoadoptium:masterfrom Feb 13, 2026
Merged
Conversation
Adapt CharsetsTest to support both JDK 26+ (new encodeFromUTF16 API) and earlier JDK versions (old encode API) using version-aware method selection. JDK 26 removed the unused sun.nio.cs.ArrayEncoder::encode method and replaced it with encodeFromUTF16 which accepts UTF-16 encoded byte arrays instead of char arrays (JDK-8363925). Changes: - Add JavaVersion utility for JDK version detection - Update static initialization to load appropriate method based on JDK version - Modify encode_data to use encodeFromUTF16 for JDK 26+ and encode for earlier versions - Convert char[] to UTF-16 LE byte array when using new API Files Modified: - functional/MBCS_Tests/charsets/src/CharsetsTest.java Files Created: - functional/MBCS_Tests/charsets/src/JavaVersion.java Fixes test failures caused by JDK 26's ArrayEncoder API change (JDK-8363925). Reference: https://bugs.openjdk.org/browse/JDK-8363925 Signed-off-by: Rishabh Thakur <rishabh@ibm.com>
Contributor
Author
|
This fixes Charsets test case for JDK26. We have added JavaVersion class to detect which encode method to use. Detailed information is present in the PR. |
Contributor
|
Grinder was triggered and test passed: https://hyc-runtimes-jenkins.swg-devops.com/job/Grinder/58338/ |
pshipton
approved these changes
Feb 13, 2026
Member
|
jdk21 grinder also passed https://hyc-runtimes-jenkins.swg-devops.com/job/Grinder/58344 |
JasonFengJ9
approved these changes
Feb 13, 2026
Member
|
Pls port this to the v1.0.12-release branch. |
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.
This PR updates CharsetsTest to support both JDK 26+ (with new
encodeFromUTF16API) and earlier JDK versions (with oldencodeAPI) using version-aware method selection.Problem
JDK 26 removed the unused
sun.nio.cs.ArrayEncoder::encodemethod as part of cleanup, causing CharsetsTest to fail.API Change in JDK 26
JDK-8363925: Remove unused sun.nio.cs.ArrayEncoder::encode
🔗 https://bugs.openjdk.org/browse/JDK-8363925
encode()encodeFromUTF16()char[]arraybyte[]arrayencode(char[] src, int srcOff, int srcLen, byte[] dst)encodeFromUTF16(byte[] src, int srcOff, int srcLen, byte[] dst, int dstOff)Why the Change?
The old
encode(char[])method was unused in the JDK codebase and was removed as part of code cleanup. The newencodeFromUTF16(byte[])method provides better performance and more control over encoding by working directly with UTF-16 encoded bytes.Solution
1. Created
JavaVersion.javaVersion detection utility to determine JDK feature version at runtime.