eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.27k stars 721 forks source link

OpenJ9-8 works fine, but other versions consider the changes incompatible. #18609

Closed TheSail28 closed 9 months ago

TheSail28 commented 9 months ago

Affected versions

We found a test case with execution problems. To facilitate analysis, we simplified the test case and the simplified class file can ben found at attachment.

Java -version output

openjdk version "1.8.0_382"
IBM Semeru Runtime Open Edition (build 1.8.0_382-b05)
Eclipse OpenJ9 VM (build openj9-0.40.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20230810_729 (JIT enabled, AOT enabled)
OpenJ9   - d12d10c9e
OMR      - e80bff83b
JCL      - c4d2c2bafb based on jdk8u382-b05)
openjdk version "11.0.20.1" 2023-08-24
IBM Semeru Runtime Open Edition 11.0.20.1 (build 11.0.20.1+1)
Eclipse OpenJ9 VM 11.0.20.1 (build openj9-0.40.0, JRE 11 Linux amd64-64-Bit Compressed References 20230824_836 (JIT enabled, AOT enabled)
OpenJ9   - d12d10c9e
OMR      - e80bff83b
JCL      - 0880e8df04 based on jdk-11.0.20.1+1)
openjdk version "17.0.8.1" 2023-08-24
IBM Semeru Runtime Open Edition 17.0.8.1 (build 17.0.8.1+1)
Eclipse OpenJ9 VM 17.0.8.1 (build openj9-0.40.0, JRE 17 Linux amd64-64-Bit Compressed References 20230824_549 (JIT enabled, AOT enabled)
OpenJ9   - d12d10c9e
OMR      - e80bff83b
JCL      - 8ecf238a124 based on jdk-17.0.8.1+1)

Reproduce

jdk_linux_8_openj9/bin/java -cp ./lib/commons-text-1.10.0.jar:./lib/commons-lang3-3.12.0.jar:./lib/bcprov-jdk15on-1.70.jar:./lib/bctls-jdk18on-1.72.jar:./ cn.ponfee.commons.jce.PBECryptorTest

jdk_linux_11_openj9/bin/java -cp ./lib/commons-text-1.10.0.jar:./lib/commons-lang3-3.12.0.jar:./lib/bcprov-jdk15on-1.70.jar:./lib/bctls-jdk18on-1.72.jar:./ cn.ponfee.commons.jce.PBECryptorTest

jdk_linux_17_openj9/bin/java -cp ./lib/commons-text-1.10.0.jar:./lib/commons-lang3-3.12.0.jar:./lib/bcprov-jdk15on-1.70.jar:./lib/bctls-jdk18on-1.72.jar:./ cn.ponfee.commons.jce.PBECryptorTest

Expected Result

---------------jdk_linux_8_openj9---------------
nothing
---------------jdk_linux_11_openj9---------------
nothing
---------------jdk_linux_17_openj9---------------
nothing

Actual Result

---------------jdk_linux_8_openj9---------------
nothing
---------------jdk_linux_11_openj9---------------
Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 'javax.crypto.SecretKeyFactory cn.ponfee.commons.jce.Providers.getSecretKeyFactory(java.lang.String, java.security.Provider)' must be InterfaceMethodref constant
    at cn.ponfee.commons.jce.symmetric.PBECryptorBuilder.<init>(Unknown Source)
    at cn.ponfee.commons.jce.symmetric.PBECryptorBuilder.newBuilder(Unknown Source)
    at cn.ponfee.commons.jce.PBECryptorTest.main(Unknown Source)
---------------jdk_linux_17_openj9---------------
Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 'javax.crypto.SecretKeyFactory cn.ponfee.commons.jce.Providers.getSecretKeyFactory(java.lang.String, java.security.Provider)' must be InterfaceMethodref constant
    at cn.ponfee.commons.jce.symmetric.PBECryptorBuilder.<init>(Unknown Source)
    at cn.ponfee.commons.jce.symmetric.PBECryptorBuilder.newBuilder(Unknown Source)
    at cn.ponfee.commons.jce.PBECryptorTest.main(Unknown Source)

Problem summary

cn.ponfee.commons.jce.PBECryptorTest after a series of calls, ends up pointing to Providers.getSecretKeyFactory(String algorithm, Provider provider). Why is the output of OpenJ9-8 different from other versions of the JVM?

Attachment

testcase2.zip

pshipton commented 9 months ago

The behavior is no different with Hotspot,

pshipton commented 9 months ago

Perhaps you can find some reason for the change in the migration guide. https://docs.oracle.com/en/java/javase/11/migrate/index.html

Regardless, the behavior comes from OpenJDK and you should peruse it with the OpenJDK project.