Skip to content

SONARJAVA-7302 Update JDT core to 3.47.0 from R4_41 - #170

Merged
aurelien-coet-sonarsource merged 3 commits into
masterfrom
ac/update-jdt
Nov 6, 2026
Merged

aurelien-coet-sonarsource merged 3 commits into
masterfrom
ac/update-jdt

Conversation

@aurelien-coet-sonarsource

@aurelien-coet-sonarsource aurelien-coet-sonarsource commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Dependency update:
    • Bumped org.eclipse.jdt.core from 3.46.0 to 3.47.0 in pom.xml
  • Error handling:
    • Non-reportable errors in ProblemHandler now abort compilation, while warnings are still ignored
  • Import messages:
    • Static field import errors in ProblemReporter now use the field name as the message argument
  • Preview API:
    • previewAPIUsed suppresses problems during feature lookup, skips null fields, and sets a default severity
  • ASTParser:
    • checkForSystemLibrary now runs even when the project is null

This will update automatically on new commits.

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

SONARJAVA-7302

gitar-bot[bot]

This comment was marked as resolved.

@gitar-bot
gitar-bot Bot dismissed their stale review November 5, 2026 09:15

✅ All code review findings resolved.

Configure merge blocking

@sonarqube-next

sonarqube-next Bot commented Nov 5, 2026

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 closed / 3 findings

🟡 Medium risk · Updating JDT core and changing compiler error and preview handling could alter diagnostics or abort compilations for affected Java projects.

Updates org.eclipse.jdt.core from 3.46.0 to 3.47.0 in pom.xml and carries over the Sonar-specific JDT patches, including the checkForSystemLibrary guard for null projects in ASTParser. Resolved this session: the Sonar patches were restored after being dropped, and the 'Missing system library' failure that hit every analyzer parse is addressed. No open issues remain.

✅ 3 closed
✅ Bug: Sonar-specific JDT patches dropped; only upstream fetch commit present

📄 src/main/java/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java:133-140 📄 src/main/java/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java:156-163 📄 src/main/java/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java:6838 📄 src/main/java/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java:12444-12447 📄 src/main/java/org/eclipse/jdt/core/dom/ASTParser.java:268-270
The PR has only the first commit made by overrideECJ.sh ("Update JDT core to 3.47.0 from R4_41"). The script then applies the previous "Override JDT core ... with custom changes" patch as a second commit, and that commit is missing. So the upstream R4_41 files replace every SonarJava patch the README lists under Modifications:

  1. referenceContext == null fix (3.37.0+): In ProblemHandler.handle, a null reference context with error severity now throws AbortCompilation where it used to return. ProblemReporter.close() also sets this.referenceContext = null again, which the README says ECJ calls by mistake. Together these bring back the bug where files with semantic problems are not analyzed, and where later files in the same compilation batch are skipped without any error.
  2. Missing system library fix: ASTParser.getClasspath now calls checkForSystemLibrary even when project == null. The Java analyzer always has project == null, and this check fails on Java >= 9 when there is no java.base module in allClasspaths.
  3. Missing-types assertion: ProblemReporter.missingTypeInMethod turns assert false : "... wrongly tagged as containing missing types" back on. This will fail sonar-java sanity tests whenever assertions are enabled.

Fix: apply the previous Override commit on top, e.g. git format-patch -1 <override_commit> | git apply --reject, and resolve any rejects, as step 3 of the README and overrideECJ.sh describe.

✅ Cross-Repo: sonar-java parser hits 'Missing system library' without project guard

📄 src/main/java/org/eclipse/jdt/core/dom/ASTParser.java:268-270
Fix here and in SonarSource/sonar-java

Breaks in: SonarSource/sonar-java - java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java - JParserConfig.astParser

SonarSource/sonar-java builds its parser in JParserConfig.astParser (java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java) and never calls ASTParser.setProject, so project is always null there. The earlier patch here skipped checkForSystemLibrary when project == null, and the README lists that patch as a required Sonar modification. This PR replaced ASTParser.java with the upstream R4_41 copy and dropped the this.project != null && guard. Now, at Java 9+ compliance with binding resolution on, sonar-java throws IllegalStateException("Missing system library") whenever no classpath entry provides a java.base module. That happens, for example, when the classpath contains rt.jar, android.jar or jrt-fs.jar (which turns off includeRunningVMBootclasspath), or when the JDK runtime is otherwise missing. The upgrade is meant to keep these patches (it is step 3 of overrideECJ.sh), so the fix belongs here: put the guard back.

Here: Restore the Sonar patch so that the system-library check is skipped when no project is set, as in the previous Override commit.

There: No change needed in sonar-java's JParserConfig.astParser once the guard is restored. Before bumping the jdt-package dependency, check with a Java 9+ project that has an rt.jar/android.jar-only classpath that it no longer throws 'Missing system library'.

✅ Cross-PR: Merged with #169, every analyzer parse can fail 'Missing system library'

📄 src/main/java/org/eclipse/jdt/core/dom/ASTParser.java:268-270
Breaks when this PR and #169 both merge, sonar-java uses the resulting jdt-package with compliance >= 9 and binding resolution on, and the release classpath from #169 (or a classpath with only rt.jar/android.jar) has no java.base module.

How

  1. This PR drops the this.project != null && guard in ASTParser.getClasspath, so checkForSystemLibrary now runs on every binding-resolving parse (src/main/java/org/eclipse/jdt/core/dom/ASTParser.java:268).
  2. SONARJAVA-7278 Override SystemReleaseClasspath to expose the JDK API of a requested release (JEP 247) #169 keeps that guard. When a release is requested, it replaces the running-VM bootclasspath with the single ct.sym classpath from SystemReleaseClasspath.resolve() (src/main/java/org/eclipse/jdt/core/dom/ASTParser.java:238).
  3. The analyzer never sets a project. Without the guard, checkForSystemLibrary throws IllegalStateException("Missing system library") unless some classpath returns a non-null getModule(java.base), so createAST/createASTs can fail for every file.
  4. Both PRs edit the same lines, so whichever merges second has to resolve the conflict by hand, and a careless resolution keeps this PR's unguarded line.

Fix

Compared 82a2e27 with #169 at fed37d2

Verification Rules 2/2 met PRs 3 inspected

Functional validation No results

Rules 2 passed 1 not applicable

✅ Internal artifact registries
✅ Repository license compliance

Broader impact PRs 3 inspected
Cross-PR 3 PRs inspected 0 open impacts

PR 169: SONARJAVA-7278 Override ASTParser to expose the JDK API of a requested release (JEP 247) Inspected
PR 6459: SONARJAVA-7279 Resolve the JDK API of the target release through the new jdt-package option Inspected
PR 6479: SONARJAVA-7297 Decouple Problems and Warnings from Eclipse JDT core specifics Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@aurelien-coet-sonarsource
aurelien-coet-sonarsource merged commit 3314062 into master Nov 6, 2026
11 checks passed
@aurelien-coet-sonarsource
aurelien-coet-sonarsource deleted the ac/update-jdt branch November 6, 2026 12:21
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