Skip to content

Fix wrong line on step into constructor reading a field before super() - #1052

Merged
SougandhS merged 1 commit into
eclipse-jdt:BETA_JAVA28from
SougandhS:BETA_JAVA28-Fix-Step_In
Nov 3, 2026
Merged

SougandhS merged 1 commit into
eclipse-jdt:BETA_JAVA28from
SougandhS:BETA_JAVA28-Fix-Step_In

Conversation

@SougandhS

@SougandhS SougandhS commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

JEP 401 (Java 28, preview) allows instance fields to be read in the early construction phase of a constructor, i.e. before super invocation: https://openjdk.org/jeps/401#Other-construction-enhancements

When stepping into such a constructor on a Java 28, the first step suspends at a line after the first statement (e.g. the closing brace). A second step is needed to reach the first statement.

Part of : #1051

What it does

How to test

Author checklist

Copilot AI left a comment

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.

🟡 Changes recommended

The workaround also matches ordinary constructors, so its extra STEP_INTO can execute the real super() call and suspend in the superclass rather than the selected constructor.

1 open issue
What changed in this PR

This PR addresses incorrect initial debugger stops when stepping into constructors that read instance fields before super() under Java 28 preview features.

Changes:

  • Adds an extra step when constructor-entry line information matches the reported pattern.
  • Enables preview features in the Java 28 test project and adds an early-field-read fixture.
  • Registers regression coverage for step into, step over, and drop to frame.
File Description
org.eclipse.jdt.debug/​model/​org/​eclipse/​jdt/​internal/​debug/​core/​model/​JDIThread.java Adds constructor-entry detection and corrective stepping for Java 28+.
org.eclipse.jdt.debug.tests/​tests/​org/​eclipse/​jdt/​debug/​tests/​AutomatedSuite.java Registers the Java 28 stepping tests.
org.eclipse.jdt.debug.tests/​tests/​org/​eclipse/​jdt/​debug/​tests/​AbstractDebugTest.java Enables Java 28 preview features and configures the fixture launch.
org.eclipse.jdt.debug.tests/​tests/​org/​eclipse/​jdt/​debug/​test/​stepping/​SteppingTestsForJava28.java Tests constructor stepping and drop-to-frame line positions.
org.eclipse.jdt.debug.tests/​java28/​EarlyRead.java Adds a constructor fixture that reads a field before super().

Review effort: Balanced

Copilot AI left a comment

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.

🟡 Changes recommended

Constructor stepping lacks a bytecode-capability check, allowing UnsupportedOperationException to escape and potentially skip the expected suspension on unsupported Java 28+ targets.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

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.

🟡 Changes recommended

The constructor workaround can misclassify a real first statement as synthetic initialization, causing Step Into to skip seed++ when line numbers legitimately decrease.

1 open issue
1 resolved since last review

Review effort: Balanced

JEP 401 (Java 28, preview) allows instance fields to be read in the
early construction phase of a constructor, i.e. before super invocation:
https://openjdk.org/jeps/401#Other-construction-enhancements

When stepping into such a constructor on a Java 28, the first step
suspends at a line after the first statement (e.g. the closing
brace). A second step is needed to reach the first statement.

Part of : eclipse-jdt#1051

Copilot AI left a comment

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.

🔵 Needs a closer look

The shared stepping workaround depends on Java 28 preview bytecode and line-table patterns requiring live ECJ and javac validation of constructor entry, frame re-entry, and legitimate decreasing line numbers.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@SougandhS
SougandhS merged commit 724df40 into eclipse-jdt:BETA_JAVA28 Nov 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants