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

Avoid the static initialization of class in getCPMethodHandleAt #10410

Conversation

ChengJin01
Copy link

The change is to avoid initializing the specified class
in getCPMethodHandleAt so as to postpone the static
initialization to the invocation of the method of this class.

Fixes: #10356

Signed-off-by: Cheng Jin jincheng@ca.ibm.com

@ChengJin01
Copy link
Author

Reviewer: @DanHeidinga
FYI: @gacholio

@ChengJin01
Copy link
Author

ChengJin01 commented Aug 18, 2020

Currently have some issue with personal builds (Joe is working on that). Will wait till the problem out there gets resolved.

Copy link
Member

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick but overall this looks like the right change to me

runtime/jcl/common/sun_reflect_ConstantPool.c Outdated Show resolved Hide resolved
The change is to avoid initializing the specified class
in getCPMethodHandleAt so as to postpone the static
initialization to the invocation of the method of this class.

Fixes: eclipse-openj9#10356

Signed-off-by: Cheng Jin <jincheng@ca.ibm.com>
@ChengJin01 ChengJin01 force-pushed the mh_avoid_init_class_getCPMethodHandleAt branch from 960d8e8 to ac3cd72 Compare August 18, 2020 18:53
Copy link
Member

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@DanHeidinga
Copy link
Member

@ChengJin01 can you confirm this matches the RI's behaviour in JDK8 & 11 as well?

@DanHeidinga
Copy link
Member

Jenkins test sanity zlinux jdk8

@DanHeidinga
Copy link
Member

Jenkins test sanity xlinux jdk11

@DanHeidinga
Copy link
Member

Jenkins test sanity win jdk15

@DanHeidinga DanHeidinga self-assigned this Aug 18, 2020
@ChengJin01
Copy link
Author

ChengJin01 commented Aug 18, 2020

@DanHeidinga , I just checked Java 8 & 11/Hotspot with the testcases (Test, Test2 and Test3) verified in #10356, which ended up with the same results as our build with my fix.

[1] The latest nightly build for Java 8/Hotspot downloaded from AdoptOpenJDK at https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u-2020-08-17-17-05/OpenJDK8U-jdk_x64_linux_hotspot_2020-08-17-17-05.tar.gz

$ ../jdk8u272-b02_hotspot/bin/java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-202008161719-b02)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b02, mixed mode)

$ ../jdk8u272-b02_hotspot/bin/java  Test2
prepared to invoke intHandle
calling BaseExample.<clinit> <-------
intValue = 1

$ ../jdk8u272-b02_hotspot/bin/java  Test3
prepared to invoke addHandle
calling BaseExample3.<clinit>  <-------
sum = 3

 $../jdk8u272-b02_hotspot/bin/java  Test
Class2.<clinit> called
obtaining method reference to Class1.dummyMethod
incrementing Class2.a
running Class1.dummyMethod via method reference
Class1.<clinit>: Class2.a is 1.0
Class1.dummyMethod: Class2.a is 1.0

[2] The latest nightly build for Java 11/Hotspot downloaded from AdoptOpenJDK at https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk11u-2020-08-12-08-12/OpenJDK11U-jdk_x64_linux_hotspot_2020-08-12-08-12.tar.gz

$ jdk_11.0.8_9_hotspot/bin/java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+9-202008112346)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+9-202008112346, mixed mode)

$ ../jdk_11.0.8_9_hotspot/bin/java  Test2
prepared to invoke intHandle
calling BaseExample.<clinit>  <-------
intValue = 1

$ ../jdk_11.0.8_9_hotspot/bin/java  Test3
prepared to invoke addHandle
calling BaseExample3.<clinit>  <-------
sum = 3

$ ../jdk_11.0.8_9_hotspot/bin/java  Test
Class2.<clinit> called
obtaining method reference to Class1.dummyMethod
incrementing Class2.a
running Class1.dummyMethod via method reference
Class1.<clinit>: Class2.a is 1.0
Class1.dummyMethod: Class2.a is 1.0

@gacholio gacholio merged commit 97b0de9 into eclipse-openj9:master Aug 18, 2020
@ChengJin01 ChengJin01 deleted the mh_avoid_init_class_getCPMethodHandleAt branch March 17, 2022 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not load Minecraft snapshot
3 participants