Skip to content

SONARJAVA-7252 Decouple the Java frontend from Eclipse JDT core - #6416

Closed
aurelien-coet-sonarsource wants to merge 5 commits into
masterfrom
ac/java-psi-frontend
Closed

aurelien-coet-sonarsource wants to merge 5 commits into
masterfrom
ac/java-psi-frontend

Conversation

@aurelien-coet-sonarsource

@aurelien-coet-sonarsource aurelien-coet-sonarsource commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Decoupled ECJ bindings:
    • Replaced shared-tree ECJ bindings with lazy semantic attachments in EcjTreeBindings and EcjSemanticAttachment
    • Moved ECJ diagnostic production into EcjDiagnosticProvider and annotation handling into EcjSymbolMetadata
  • New semantic API:
    • Added Type.directSuperTypes() and Symbol.MethodSymbol.defaultValue() with Sema.getEnvironmentCleaner() default
  • Shared state:
    • Added SemanticValues supplier constants for unknown types and symbols
    • Moved undefinedTypes from JSema onto CompilationUnitTreeImpl

This will update automatically on new commits.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Decouple the Java frontend from Eclipse JDT core SONARJAVA-7252 Decouple the Java frontend from Eclipse JDT core Oct 27, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

SONARJAVA-7252

@aurelien-coet-sonarsource
aurelien-coet-sonarsource marked this pull request as ready for review October 27, 2026 12:53
@datadog-sonarsource

datadog-sonarsource Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 47d2a02 | Docs | Give us feedback!

@rombirli

Copy link
Copy Markdown
Contributor

gitar review this PR

@gitar-bot

gitar-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

gitar review this PR

Review queued. Results will appear in the dashboard comment once it completes.

@aurelien-coet-sonarsource

Copy link
Copy Markdown
Contributor Author

/pvf

@hashicorp-vault-sonar-prod

Copy link
Copy Markdown
Contributor

📊 Performance Validation complete
🆕 174 new · 🗑️ 0 lost issues
View dashboard

@gitar-bot

gitar-bot Bot commented Nov 2, 2026

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

🟡 Medium risk · Replacing ECJ bindings with lazy semantic attachments across Java parsing could misresolve symbols or types and distort downstream analysis results.

Decouples the Java frontend from Eclipse JDT core by replacing shared-tree ECJ bindings with lazy semantic attachments and moving diagnostic production and annotation handling into dedicated ECJ classes. Resolved the abstract Type.directSuperTypes() API break for implementors and the exposure of the internal JProblem type in the public Sema API. No open issues remain.

✅ 2 closed
✅ Quality: New abstract Type.directSuperTypes() breaks public API implementors

📄 java-frontend/src/main/java/org/sonar/plugins/java/api/semantic/Type.java:34-38 📄 java-frontend/src/main/java/org/sonar/java/model/JUtils.java:146-151
org.sonar.plugins.java.api.semantic.Type is part of the plugin API, and this PR adds Set<Type> directSuperTypes(); to it as an abstract method (Type.java:38). Any Type implementation outside this repo (custom-rule plugins, other analyzers built on the frontend, hand-written test doubles) will no longer compile. Already-compiled implementations will throw AbstractMethodError once JUtils.directSuperTypes (JUtils.java:150) calls the method on them. The same PR adds Symbol.MethodSymbol.defaultValue() and the new Sema methods as default methods, so Type is the one API change here that breaks compatibility. Fix: give it a default body, e.g. default Set<Type> directSuperTypes() { return Collections.emptySet(); }, and keep the overrides in JType and UnknownType.

✅ Quality: Public Sema API now exposes internal JProblem type

📄 java-frontend/src/main/java/org/sonar/plugins/java/api/semantic/Sema.java:19-31 📄 java-frontend/src/main/java/org/sonar/java/model/JavaTree.java:165
The PR's goal is to separate the shared API from compiler internals. However, the public org.sonar.plugins.java.api.semantic.Sema interface now imports org.sonar.java.model.JProblem and returns Set<JProblem> from undefinedTypes() (Sema.java:20,29). That ties the plugin API package to an internal model class, so any external Sema implementation or caller now depends on JProblem and its nested Type enum. The only callers are internal (JavaAstScanner via ast.sema). Fix: keep undefinedTypes() on an internal interface or on CompilationUnitTreeImpl, and leave the public Sema contract unchanged.

Verification Rules 1/1 met Repos 3 inspected · PRs 1 inspected

Functional validation No results

Rules 1 passed 2 not applicable

✅ Repository license compliance

Broader impact Repos 3 inspected PRs 1 inspected
Cross-repo 3 repositories inspected 0 open impacts

SonarSource/sonar-java-symbolic-execution Inspected
SonarSource/sonarlint-intellij Inspected
SonarSource/sonarlint-vscode Inspected

Cross-PR 1 PR inspected 0 open impacts

PR 6394: SONARJAVA-7229 Add telemetry for Java semantic degradation and classpath configuration 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

@sonarqube-next

sonarqube-next Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@aurelien-coet-sonarsource
aurelien-coet-sonarsource deleted the ac/java-psi-frontend branch November 3, 2026 09:48
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