Skip to content

Revise the initialization flow of interface as per specs - #24567

Open
lzhou2025 wants to merge 1 commit into
eclipse-openj9:masterfrom
lzhou2025:initInterface
Open

Revise the initialization flow of interface as per specs#24567
lzhou2025 wants to merge 1 commit into
eclipse-openj9:masterfrom
lzhou2025:initInterface

Conversation

@lzhou2025

@lzhou2025 lzhou2025 commented Aug 17, 2026

Copy link
Copy Markdown
Member

As per Java Language and JVM Specs, the initialization is changed to initialize Java interface's super interfaces if applicable with default method.

Fixes: #24153

@lzhou2025 lzhou2025 changed the title Skip the init of Object if interfaces with default method Skip the init of Object as supertype of interfaces Aug 18, 2026
@lzhou2025 lzhou2025 changed the title Skip the init of Object as supertype of interfaces Skip the init of Object as the supertype of interfaces Aug 18, 2026
@lzhou2025
lzhou2025 marked this pull request as ready for review August 18, 2026 12:29
Comment thread runtime/vm/ClassInitialization.cpp Outdated
Comment thread runtime/vm/ClassInitialization.cpp Outdated
@hangshao0
hangshao0 requested a review from tajila August 18, 2026 15:06
Comment thread runtime/vm/ClassInitialization.cpp Outdated
if (VM_VMHelpers::exceptionPending(currentThread)) {
goto initFailed;

/* Do not initialize the superclass java.lang.Object of interfaces */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is this change needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It ensures that that part of codes is only applicable to java class, not interfaces.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The class java.lang.Object is initialized very early in the boot sequence and should be initialized before any interface would be considered. What problem does this address?

@lzhou2025 lzhou2025 Aug 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is correct. As a state machine implementation, if it's Object or any other Class, is already initialized in next loop check, it will come back with nothing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What problem does this address?

I don't think you answered my question.

@lzhou2025 lzhou2025 Aug 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In the context of interfaces with default method,

interface I {
        boolean v = out("I");
        default void i() {}
    }
interface J extends I {
        boolean v = out("J");
        default void j() {}
    }

J doesn't have Object as the superclass (but internally representation of data structure it's). The changes skip the block for the superclass initialization. Then proceed to next block is for the J's super interface (I) which is initialized first, then come back to J initialization.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The changes will initialize all super interfaces here https://github.com/eclipse-openj9/openj9/pull/24567/changes#diff-935d02710f1a4a3eeec9b2cae8ff8ef4bb33f0c28b0bee105ec9a42feb33eb26R734. But currently it's not used for the initialization of super interfaces of an interface, only applicable to a Java classes super interfaces.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps the interfaces are considered in the wrong order, but that's not my question. Skipping the (re-)initialization check for Object should make no difference. Why is that part of this change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The changes make the initialization of a class or an interface compliant with the spec.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From a regression test run there is no new issue so far.

@lzhou2025 lzhou2025 changed the title Skip the init of Object as the supertype of interfaces Change the inittialization of interface compliant with specs Aug 19, 2026
@lzhou2025 lzhou2025 changed the title Change the inittialization of interface compliant with specs Change the initialization of interface compliant with specs Aug 19, 2026
@lzhou2025
lzhou2025 force-pushed the initInterface branch 2 times, most recently from e9f4894 to 0a55a6b Compare August 19, 2026 20:22
@lzhou2025 lzhou2025 changed the title Change the initialization of interface compliant with specs Revise the initialization flow of interface as per specs Aug 20, 2026
Comment thread runtime/vm/ClassInitialization.cpp Outdated
@lzhou2025
lzhou2025 force-pushed the initInterface branch 2 times, most recently from 08ae828 to 8e380fa Compare August 27, 2026 13:03
@tajila

tajila commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

jenkins test sanity,extended.functional zlinux jdk11,jdk17,jdk25

Comment thread runtime/vm/ClassInitialization.cpp Outdated
Comment thread runtime/vm/ClassInitialization.cpp Outdated
@keithc-ca

Copy link
Copy Markdown
Contributor

For the record, the build in progress is https://openj9-jenkins.osuosl.org/job/PullRequest-OpenJ9/9862: The results should not be invalidated by recent changes. However, #24567 (review) has not been addressed.

@lzhou2025
lzhou2025 marked this pull request as draft August 27, 2026 17:28
@lzhou2025
lzhou2025 force-pushed the initInterface branch 2 times, most recently from 92d66d3 to 59d5d6f Compare August 27, 2026 20:33
As per Java Language and JVM Specs, the initialization is changed
to initialize Java interface's super interfaces if applicable
with default method.

Fixes: eclipse-openj9#24153
@lzhou2025
lzhou2025 marked this pull request as ready for review August 28, 2026 12:15
@eclipse-openj9 eclipse-openj9 deleted a comment from lzhou2025 Aug 28, 2026
@eclipse-openj9 eclipse-openj9 deleted a comment from lzhou2025 Aug 28, 2026
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.

[Compatibility] Incorrect initialization order of superinterfaces with default methods compared to HotSpot / JVMS

4 participants