Skip to content

Fixed for Bug4986#4993

Open
RagiGeorge wants to merge 1 commit into
eclipse-jdt:masterfrom
RagiGeorge:Bug4986_fix
Open

Fixed for Bug4986#4993
RagiGeorge wants to merge 1 commit into
eclipse-jdt:masterfrom
RagiGeorge:Bug4986_fix

Conversation

@RagiGeorge
Copy link
Copy Markdown
Contributor

@RagiGeorge RagiGeorge commented Apr 12, 2026

Fix #4986

What it does

Fixes a malformed error message shown for inaccessible fields used via static imports and adds a regression test.

How to test

Reproduce with a private static field referenced via import static; verify the error text matches the expected output.

##Before fix
Screenshot 2026-04-12 at 11 53 03 AM

after fix

Screenshot 2026-04-12 at 11 24 03 AM Screenshot 2026-04-12 at 11 23 52 AM

@RagiGeorge
Copy link
Copy Markdown
Contributor Author

RagiGeorge commented Apr 12, 2026

@srikanth-sankaran @noopur2507
Could you please review. Thanks

@srikanth-sankaran srikanth-sankaran self-requested a review April 20, 2026 05:15
@srikanth-sankaran
Copy link
Copy Markdown
Contributor

@srikanth-sankaran @noopur2507
Could you please review. Thanks

I'll take a look, Thanks for PR @RagiGeorge

@RagiGeorge
Copy link
Copy Markdown
Contributor Author

@iloveeclipse
Could you please review. Thanks

Copy link
Copy Markdown
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

Just some code styling issues, I haven't checked if the code actually does something meaningful

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets Eclipse JDT compiler diagnostics by correcting a malformed error message emitted when a statically imported field is inaccessible (issue #4986), and adds a regression test to lock in the expected wording.

Changes:

  • Adjust ProblemReporter#importProblem to special-case certain static-import field visibility errors and build cleaner message arguments.
  • Add a new regression test covering the inaccessible static-import field message formatting.
  • Introduce a helper (isSelfImport) to detect when the imported field originates from the same compilation unit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java Adds regression test asserting the corrected error message for an inaccessible statically imported field.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java Tweaks argument construction for field-import problems and adds isSelfImport(FieldBinding) helper to scope the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RagiGeorge RagiGeorge force-pushed the Bug4986_fix branch 2 times, most recently from a7675a8 to 8a60791 Compare April 27, 2026 08:56
@RagiGeorge
Copy link
Copy Markdown
Contributor Author

Hi @iloveeclipse
Thanks for the earlier reviews. After addressing the diagnostic fix for Bug 4986, a few additional test updates were required.The change corrects the error message emitted for static field imports (removing duplicated type qualification such as Z.p2.Z.Zint). Several existing compiler regression tests were asserting this previous, incorrect diagnostic text. These tests have now been updated to reflect the corrected and intended compiler output.

Please review. Thanks

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.

Malformed error message for inaccessible field in static import

4 participants