Repository navigation
DO NOT MERGE SemSitter front-end: align unused imports, enum constant annotations and generic cast operands with ECJ - #6620
Conversation
… one it applies to
…perand cases against ECJ
|
/pvf |
|
📊 Performance Validation complete |
This reverts commit a6a8113.
…ng on unresolved names The unresolved-name gate silenced imports the compiler reports whenever the semantic model leaves a name unknown. Only a single-type import of a type the unit itself declares is left out.
|
/pvf |
|
@antonioaversa ❌ Your
|
|
/pvf |
| @@ -378,12 +396,38 @@ private void reportUnusedImports(JavaTree.CompilationUnitTreeImpl unit) { | |||
| String name = dotted(importTree.qualifiedIdentifier()); | |||
| String key = (importTree.isStatic() ? "static " : "") + name; | |||
| boolean duplicate = !seen.add(key); | |||
There was a problem hiding this comment.
💡 Quality: PR description still claims unresolved-name units report no unused import
This commit removes the hasUnresolvedNames(unit) check from reportUnusedImports, and adds the ownType check in its place. A unit with an unresolved name now gets unused-import warnings again. The PR description table still has the row "a unit with an unresolved name reports no unused import" (S1128, 2 → 0). The row "a used single-type import of the unit's own package counts as used" is also still there, even though commit f21dae2 reverted that behaviour: isOwnPackage applies to single-type imports again. Please update both rows to say that imports of a type the unit itself declares are skipped, and give the before/after numbers measured for that case.
Was this helpful? React with 👍 / 👎
|
📊 Performance Validation complete |
…the calls in its body The supertypes are now bound before the members are translated, a member type inherited from a compiled supertype is found by name, and a supertype fact without arguments no longer hides the ones the header spells out. An unqualified call to a method of a generic parent then returns the substituted type instead of the type variable.
…ss the bound holds A Class<?> cast to Class<? super T> narrows, so the cast is not redundant.
Like the compiler, a level above 8 sees the API of that release, where a member deprecated in a later release is not deprecated yet.
An anonymous class of an interface whose only abstract method is generic is no longer reported as convertible to a lambda.
| /** Without any library, a method of a type nothing declares is unknown instead of named after its written owner. */ | ||
| void release(int release) { | ||
| caches.release = release; | ||
| } | ||
|
|
||
| /** The configured language level, or 0 when the project sets none. */ | ||
| int release() { | ||
| return caches.release; | ||
| } | ||
|
|
||
| void noLibraries(boolean noLibraries) { | ||
| caches.noLibraries = noLibraries; | ||
| } |
There was a problem hiding this comment.
💡 Quality: JSema release(): javadoc moved off noLibraries and wrong default
The new release(int) setter went in between the existing noLibraries javadoc and noLibraries(boolean). That comment ("Without any library, a method of a type nothing declares is unknown…") now documents release(int), and noLibraries has no doc. The getter's doc is also wrong. It says the level is "0 when the project sets none", but SemSitterParser passes Integer.MAX_VALUE when javaVersion.isNotSet(). Behaviour is the same either way: neither 0 nor Integer.MAX_VALUE drops a deprecation. Still, a reader who trusts the doc will misread the release <= 8 guard in SemaAnnotations.deprecatedAfterRelease. The fix is to move the comment back onto noLibraries and describe the unset case correctly.
Move the noLibraries javadoc back and document the unset value accurately:
/** Sets the configured language level. */
void release(int release) {
caches.release = release;
}
/** The configured language level, or Integer.MAX_VALUE when the project sets none. */
int release() {
return caches.release;
}
/** Without any library, a method of a type nothing declares is unknown instead of named after its written owner. */
void noLibraries(boolean noLibraries) {
caches.noLibraries = noLibraries;
}
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 🟡 Medium risk 1 closed / 3 findingsSemSitter front-end changes to name resolution, type inference, and warning metadata could alter Java analyzer findings across analyzed projects. Stacks client-side fixes in 💡 Quality: PR description still claims unresolved-name units report no unused import📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/CompilerWarnings.java:384-398 This commit removes the 💡 Quality: JSema release(): javadoc moved off noLibraries and wrong default📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:322-334 The new Move the noLibraries javadoc back and document the unset value accurately✅ 1 closed✅ Bug: Any labeled statement now silences every unused-import warning
🤖 Prompt for agentsVerification Rules 2/3 met Repos 3 inspected · PRs 3 inspectedRules 1 failed 2 passed 3 not applicable
Functional validation No results Broader impact Repos 3 inspected PRs 3 inspectedCross-repo 3 repositories inspected 0 open impacts
Cross-PR 3 PRs inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




DO NOT MERGE
Stacks on #6584 (
rombirli/semsitter-pvf, which sits on top of the SemSitter front-end stack). Client-side fixes injava-frontend-semsitterfor divergences between the ECJ and SemSitter front-ends found in the PVF report of #6584. No change to the analyzer server or to the bundled binaries.Each fix is its own commit. "Before/after" is the number of differing results (ECJ vs SemSitter) on a minimal repro, measured with the same bundled server pair as #6584.
@SuppressWarnings("unused"/"all")on the first type suppresses unused imports<@NonNull T>)new Nested<>(...)@Deprecatedconstant)ObjectNew replay samples compare the warnings against ECJ (they fail without these commits); a unit test covers the enum constant annotation.
Not fixed here: a unit that the ECJ run cannot compile (missing test jars, preview syntax) reports no unused import with ECJ, while the SemSitter front-end resolves it. A gate on unresolved names was tried and removed: it silenced about 1350 imports ECJ does report.
PVF (same bundled server as #6584), run 47415770056 against DEV 9.1.0.60630, versus the #6584 run of 2 Dec 2026:
The S1905 and S5738 gains are small on the real projects: the jOOQ casts and the
@Support({ ..., DERBY, ... })uses of a deprecated enum constant are not covered by the repros of this PR.Summary by Gitar
@Deprecated(since)entries newer than the configured language levelThis will update automatically on new commits.