JDK-8321514 : UTF16 string gets constructed incorrectly from codepoints if CompactStrings is not enabled
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 22,23
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-12-07
  • Updated: 2024-07-10
  • Resolved: 2023-12-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22 JDK 23
22Fixed 23 b03Fixed
Related Reports
Relates :  
Description
After the changes for JDK-8311906, an attempt to compile the following pattern: "ab(\\P{all})+" fails with: java.util.regex.PatternSyntaxException: Unknown character property name {} near index 9 if compact strings is not enabled.
As a result, javac won't work on a platform where compact strings are not enabled by default.
However, the problem itself is platform-independent, and can be reproduced on all platforms with -XX:-CompactStrings
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk22/pull/18 Date: 2023-12-18 11:56:50 +0000
18-12-2023

Changeset: fde5b168 Author: Aleksei Voitylov <avoitylov@openjdk.org> Committer: Roger Riggs <rriggs@openjdk.org> Date: 2023-12-14 14:39:04 +0000 URL: https://git.openjdk.org/jdk/commit/fde5b16817c3263236993f2e8c2d2469610d99bd
14-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17057 Date: 2023-12-11 13:48:18 +0000
11-12-2023

After initial investigation, the problem was narrowed down to j.u.regex.Pattern::family method that attempts to build String from an array of integers. The problem can be reproduced with the following code: int temp[] = new int[]{ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 }; String st = new String(temp, 3, 3); The st is empty if compact strings is disabled, instead of expected value 456.
07-12-2023