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

IndexOf method of String file fails using Eclipse OpenJ9 VM 11.0.22.0 #19334

Closed
gpezzini opened this issue Apr 18, 2024 · 9 comments
Closed

IndexOf method of String file fails using Eclipse OpenJ9 VM 11.0.22.0 #19334

gpezzini opened this issue Apr 18, 2024 · 9 comments

Comments

@gpezzini
Copy link

Java -version output

openjdk version "11.0.22" 2024-01-16
IBM Semeru Runtime Open Edition 11.0.22.0 (build 11.0.22+7)
Eclipse OpenJ9 VM 11.0.22.0 (build openj9-0.43.0, JRE 11 Windows 11 amd64-64-Bit Compressed References 20240131_835 (JIT enabled, AOT enabled)
OpenJ9 - 2c3d78b
OMR - ea8124dbc
JCL - 7876cac747 based on jdk-11.0.22+7)

Summary of problem

The attached simple class demonstrates that the 'indexOf' method fails after reading a string stored in an xml property file.

After execution with the above5ra indicated jsk the output is:
The string: Field1ç°^§|Field2 does NOT contains ç°^§|

Attention:

  1. using JDK
    openjdk version "11.0.20" 2023-07-18
    IBM Semeru Runtime Open Edition 11.0.20.0 (build 11.0.20+8)
    Eclipse OpenJ9 VM 11.0.20.0 (build openj9-0.40.0, JRE 11 Windows 11 amd64-64-Bit Compressed References 20230810_700 (JIT enabled, AOT enabled)
    OpenJ9 - d12d10c
    OMR - e80bff83b
    JCL - f53b132192 based on jdk-11.0.20+8)

and older jdk version, it works.

The output is:
The string: Field1ç°^§|Field2 contains ç°^§|

  1. Also using jdk
    openjdk version "17.0.10" 2024-01-16
    IBM Semeru Runtime Open Edition 17.0.10.0 (build 17.0.10+7)
    Eclipse OpenJ9 VM 17.0.10.0 (build openj9-0.43.0, JRE 17 Windows 11 amd64-64-Bit Compressed References 20240116_624 (JIT enabled, AOT enabled)
    OpenJ9 - 2c3d78b
    OMR - ea8124dbc
    JCL - 2aad089841f based on jdk-17.0.10+7)

The output is:
The string: Field1ç°^§|Field2 contains ç°^§|

So it works with 17 too

TestIndexOf.java.txt

@gpezzini
Copy link
Author

I further simplified the example class
The same results described above can also be reproduced with the class attached here.
In practice, the problem can be reproduced even without switching between writing and reading an xml property file.
TestIndexOf2.java.txt

@pshipton
Copy link
Member

Running with -XX:-CompactStrings is a workaround for the bug.

@patric42
Copy link

It's even worse: any String longer than 1 character including anything needing UTF-8 multibyte encoding will not be found. So "ä!", "!ä" or "wörd" won't work. Yikes!

@gpezzini
Copy link
Author

Thanks and pardon me: we are only talking about the .indexOf() method.
I personally haven't tested other methods like .split() or similar that require a scan of the string.
I hope the fix covers all the scenarios involved.

pshipton added a commit to pshipton/openj9 that referenced this issue Apr 18, 2024
LATIN1 String constants were only created in jdk17 and later. The JCL
for jdk11 creates LATIN1 Strings and the VM needs to match.

Issue eclipse-openj9#19334

Signed-off-by: Peter Shipton <[email protected]>
pshipton added a commit to pshipton/openj9 that referenced this issue Apr 18, 2024
LATIN1 String constants were only created in jdk17 and later. The JCL
for jdk11 creates LATIN1 Strings and the VM needs to match.

Issue eclipse-openj9#19334

Signed-off-by: Peter Shipton <[email protected]>
@pshipton
Copy link
Member

The fix is released into the upcoming 0.44 release, expected by early May.

@pshipton
Copy link
Member

@patric42
Copy link

patric42 commented Apr 19, 2024

Linux amd64 and arm64 build please?

@patric42
Copy link

thank you very much :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants