Skip to content

JAVA-7396 Add the SemSitter semantic model of types, symbols and members - #6573

Open
rombirli wants to merge 11 commits into
rombirli/semsitter-parsing-sessionfrom
rombirli/semsitter-semantic-model
Open

rombirli wants to merge 11 commits into
rombirli/semsitter-parsing-sessionfrom
rombirli/semsitter-semantic-model

Conversation

@rombirli

@rombirli rombirli commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part 4 of 17 of JAVA-7392. Ticket: JAVA-7396.

Intent

JSema is the SemSitter semantic model: the Type and Symbol API the checks already use, built from what the server sends instead of from ECJ bindings. Nothing translates documents yet, so nothing uses it outside tests.

flowchart LR
  D[document facts and symbols] -->|ingestDocument| S[JSema]
  T[type declarations from get-types] -->|ingestTypes| S
  S --> Y[JType: classes, arrays, type variables, wildcards, captures]
  S --> M[JTypeSymbol, JMethodSymbol, JVariableSymbol, JPackageSymbol]
  M --> L[MemberLookup, Substitution, Subtyping, OverriddenMethods]
Loading
JSema sema = new JSema();
sema.loadTypes(names -> client.getTypes(names));   // lazy, once per session
sema.ingestDocument(document);
Type list = sema.getClassType("java.util.List");   // same contract as the ECJ Sema

An unresolved name in an annotation has no value, as with ECJ. A separate commit makes SpringUtils read bean and qualifier names only from String values: an unresolved constant (@Component(TASK_TYPE_DECISION) in netflix-conductor) used to throw a NullPointerException with ECJ too, and failed the whole analysis.

Inference, overload ranking and annotation metadata are stubs here (declared types, first candidate, Symbols.EMPTY_METADATA). Later PRs replace each stub, so each one can be reviewed against its own tests.

State on master

Nothing creates a JSema. ECJ parses exactly as today.

Test plan

  • One unit test per model class, using the JDK types a real server recorded in replay/types.json.gz
  • SpringUtilsTest: unresolved bean and qualifier names fall back to the default name, failing with a NullPointerException before the fix

@hashicorp-vault-sonar-prod

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

Copy link
Copy Markdown
Contributor

JAVA-7396

@rombirli
rombirli added this pull request to stack #6570 November 25, 2026 11:48
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from 81f3bdd to 6dd9e36 Compare November 25, 2026 12:00
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from 6dd9e36 to 55ab14c Compare November 25, 2026 12:03
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch 4 times, most recently from 7e47c30 to 9bff8b5 Compare November 25, 2026 16:31
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from 9bff8b5 to d0c465a Compare November 25, 2026 17:16
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from d0c465a to e1dc9b0 Compare November 25, 2026 20:45
@rombirli
rombirli removed this pull request from stack #6570 November 25, 2026 20:47
@rombirli
rombirli added this pull request to stack #6589 November 25, 2026 20:48
@datadog-sonarsource

datadog-sonarsource Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Pipelines

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

@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch 2 times, most recently from 4adcb80 to 8580d86 Compare November 27, 2026 09:24
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from 8580d86 to 9cb055c Compare November 27, 2026 10:46
@rombirli
rombirli removed this pull request from stack #6589 December 1, 2026 11:07
@rombirli
rombirli added this pull request to stack #6607 December 1, 2026 11:08
@rombirli

rombirli commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Caching candidates to investigate in this PR. Found by reading the code only, nothing was profiled. Line numbers are at c40281e. Same idea as the superTypes() comment: the work below is recomputed on every call.

High

  • JType.isSubtypeOf → Subtyping.isSubtype (JType.java:221, Subtyping.java:34): new HashSet and one fqn + ">" + fqn string per step, and it recursively walks superClass() / interfaces() (rebuilt each time, see below). This is the main check API and it does not use superTypes(), so caching superTypes() does not help it. A per-JSema memo on (type, superType) could.
  • JType.symbol() (JType.java:350): for a parameterized type it returns typeSymbol(fqn).parameterizedAs(this), a new JTypeSymbol view that copies state on every call. A superTypes cache on JTypeSymbol would be lost for every List<String>-like type. Cache the view per JType, or keep the cache on the generic symbol.
  • MemberLookup.declaredMethod (MemberLookup.java:99): scans every member fact of the owner and all its parents and parses each, per method invocation, then checks candidates in 3 phases (List.add walks List, Collection, Iterable, Object). An index per (type, name) would avoid the scan.
  • JTypeSymbol.superClass() (:167): inheritsFrom walks the superclass chain, then interfaceDeclaredAsSuper, then builds the type from the fact. Called by superTypes, Subtyping.inheritsFrom and OverriddenMethods.
  • JTypeSymbol.interfaces() / ownInterfaces() (:212, :220): rebuilds the list, filters unresolved ones with a nested noneMatch (O(n²)), and calls instantiateSupertype on each for parameterized types. Same callers as superClass().

Medium

  • MemberLookup.functionalMethod (:147): re-collects all abstract methods of the interface hierarchy, called per candidate and per function argument from takesNoFunction. Cache per erased fqn.
  • JTypeSymbol.membersNamed (:374): for library types, scans all member facts on each lookup (mayBeNamed parses each). lookupSymbols also allocates a new HashSet. Index by name.
  • LibraryMembers.memberFromTypeInfo / projectMember (:102, :119): called for the same facts on every lookup. For project members it re-runs resolve and declaredAnnotations(...).anyMatch. Memoize per fact.
  • JType.isUnknown() (JType.java:300): declaredSymbol() plus a recursive args.stream().anyMatch(isUnknown), called in almost every loop above.
  • JType.isParameterized() / isGenericSelf() (:384, :389): builds a string and runs allMatch on each call.
  • MemberLookup.findMember / matches (:263, :298): for facts without an id, parameterTypesOf(descriptor) is parsed on every member for every lookup. Used by linkDumpSymbol for each library member of the file.
  • LibraryMembers.servedConstant (:285): linear scan of the owner's members on each call. Index by id.
  • FactTypes.declaredVariables (:228): scans all dumpSymbols for each type-variable name, once more per $ nesting level. Called from typeFromName via typeParameterItem.
  • Substitution.lookupGenericMember (:409): linear scan with descriptor parsing. Callers cache the result, but only per method.

Low (cheap each time, called often)

  • JType.name() (:326): lastIndexOf and substring per call.
  • JType.erasure() builds a new array type each time for arrays. JType.intersection sorts names on each build.
  • JMethodSymbol.declarationParameters() and thrownTypes() (:250, :271) rebuild their lists. thrownTypes() also maps names through typeFromName each time via projectThrown.
  • JMethodSymbol.withSignature (:189): modifiersCopy() and declaresTypeVariable() for every invocation view.
  • Substitution.typeArgumentsOf / classSubstitution (:260, :182) rebuild a HashMap per call.
  • JSema.knowsPackage (:375): stream over all typeInfos keys when the package loader has no answer.
  • JSymbol.implicitRecordAccessor: streams the record components on each isPublic() of a method without a declaration.

Already cached

overriddenSymbols(), signature(), memberSymbols(), declaringType, rawTypes, typesByName, symbols, declaredParameters / parameterVariables / declaredReturn, and SemaFacts.parseMember. The last one is a static map shared across JSema instances, cleared at 200k entries, unlike the per-file caches above.

To settle for each

  • Lifetime: per file (one JSema), except parseMember.
  • Lazy loading: getClassType / typeSymbol can still load or mark types unknown, so caches depending on isUnknown() must fill in after that settles or be invalidated on ingestTypes.
  • Mutable returns: superTypes() and lookupSymbols() return mutable collections, check that no caller mutates them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LibraryMembers builds the symbols of members the file does not declare (java.util.List#get, a jar method, a method of another source file) from the server data.

flowchart LR
  TI["types answer: members JSON per type"] -->|"memberFromTypeInfo"| LM["LibraryMembers"]
  TI -->|"registerProjectMembers"| LM
  DOC["document: dump symbols and facts"] -->|"createDumpSymbol, then linkDumpSymbol"| LM
  LM --> S["JMethodSymbol / JVariableSymbol, cached in sema.symbols"]
  LM --> D["sema.declaredMembers: annotations, throws, varargs"]
Loading

A member fact of the types answer, like this one for List.get:

{"k":"m","name":"get","desc":"(I)Ljava/lang/Object;","vis":"public","abstract":true,"retType":{"id":"E","kind":"typevar"}}

becomes a JMethodSymbol with id java.util.List#get(I)Ljava/lang/Object;: parameter and return types from the descriptor, modifiers from vis / abstract / static, plus throws, varargs and annotations.

The document side works in two passes: createDumpSymbol creates every symbol, then linkDumpSymbol sets owners and types, so an owner never has to exist before its members. applyLibraryMember then copies flags, annotations and throws from the matching member fact.

registerProjectMembers records the annotations, throws and varargs of other source files' members in sema.declaredMembers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MemberFactory creates the symbol JSema.resolve(id) cannot find, and fills symbols in from facts and type info.

flowchart TD
  R["sema.resolve(id)"] --> A{"in sema.symbols?"}
  A -->|yes| X["return it"]
  A -->|no| B{"in dumpSymbols?"}
  B -->|yes| LM["LibraryMembers: createDumpSymbol, linkDumpSymbol"]
  B -->|no| C{"id contains #?"}
  C -->|yes| CM["MemberFactory.createMember"]
  C -->|no| D{"id contains &lt;?"}
  D -->|yes| TP["MemberFactory.typeParameter"]
  D -->|no| TS["sema.typeSymbol"]
Loading

createMember parses an id like com.acme.Owner#foo(int,String) into owner, name and params, then:

  • a member fact of the owner or its parents is found (matched typed, then by arity, then as varargs): LibraryMembers.memberFromTypeInfo builds it
  • otherwise a method is built from the facts and the parsed params
  • otherwise it is field-like: a lambda ($lambda$), a local or anonymous class (Owner#create()$Local$1), or a plain field

The rest fills symbols in: applyFact and fillMethod (from this file's graph facts), applyTypeInfo (from a types answer), plus the cached array, primitive and type variable symbols.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MemberLookup finds the member a name refers to, by walking a type and its supertypes in the member facts.

flowchart TD
  Q["findMember(owner, id, match)"] --> O["owner's member facts"]
  O --> M{"matches name and params?"}
  M -->|yes| R["return that fact"]
  M -->|no| P["each parent: superclass, then interfaces"]
  P --> O
Loading

Match sets how strict the match is:

  • TYPED: same name and erased parameter types
  • ARITY: same name and parameter count
  • VARARGS: same name, last parameter is an array, arity fits

MemberFactory tries them in that order, and LibraryMembers uses TYPED.

declaredMethod, declaredField, functionalMethod, receiverSymbol, takesNoFunction and arityMatches pick overloads and fields. They have no caller in this PR, so they belong with the PR that first uses them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Finds the methods a method overrides, by walking the supertypes of its class.

flowchart LR
  C["Child.run()"] -->|overrides| P["Parent.run()"]
  C -->|overrides| R["Runnable.run()"]
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This file contains static helpers to read SemSitter ids, JSON and facts.

@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from dab1c91 to a67367e Compare December 2, 2026 13:33
@rombirli
rombirli force-pushed the rombirli/semsitter-semantic-model branch from a67367e to 39a2cdd Compare December 2, 2026 14:01
@gitar-bot

gitar-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 7 closed / 7 findings

The substantial new JSema type and member resolution is not yet used by production parsing; only localized Spring name fallbacks alter current behavior.

Adds the SemSitter semantic model (JSema) with types, symbols, members, and caching, built from server-provided facts instead of ECJ bindings. Six issues raised in review were resolved, including nullable type loader handling, inherited member owners, unresolved type symbol reporting, long and char annotation literals, stale subtype cache entries, and generic method matching in findMember. Unicode and octal char literals still return source text; this is closed without a fix in this PR. No open issues remain.

✅ 7 closed
✅ Bug: Type loader's nullable result is handled in one call site only

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:237-243 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:259 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:274-276 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:384-388 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:424-430 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemaAnnotations.java:112-113
DocumentTranslator.types(Set<String>) is @Nullable. SemSitterParser's session returns null once it is closed (if (!open) return null;). JSema.typeSymbol handles this: it checks loaded == null and returns early. The other lazy loads hand the result straight on without a check:

  • declaresType (line 427), markUndeclared (line 259) and loadTypes (line 241) all call ingestTypes(...), which dereferences types.entrySet().
  • SemaAnnotations.packageAnnotations calls loaded.get(key).

loadTypes keeps the loader on purpose to "fetch the types reached later". So if a check asks the model for a type after the session has closed (Substitution.lookupGenericMember → declaresType, or a package-annotation lookup), it throws an NPE instead of treating the type as unknown. Fix: treat a null answer as empty in one place, e.g. normalise it inside ingestTypes or wrap the loader in loadTypes.

✅ Bug: Inherited library members get the receiver type as their owner

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/MemberLookup.java:230-244 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/MemberFactory.java:118-132 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/LibraryMembers.java:108-122
MemberFactory.createMemberOnce resolves Child#m() through MemberLookup.findMember. That method walks the parent types (lines 243-248) but returns only the member's JSON, not the type that declares it. The caller then passes the original owner (Child) to LibraryMembers.memberFromTypeInfo. For a classpath member with no id, that method builds the symbol id as Child#m()V and sets owner(owner).

So ArrayList#containsAll(...) ends up owned by ArrayList, not AbstractCollection:

  • signature(), owner() and Substitution.declaringType/classSubstitution (which look up typeVars on the owner) are all wrong.
  • The same method gets a separate symbol for each receiver type.

This also disagrees with MemberLookup.declaredField/collectMethods, which keep the type they traversed (the test checks declaredField("lib.Calls", "inherited").owner() is Parent). Fix: have findMember also return the type that declares the match, or resolve it there, and pass that type to memberFromTypeInfo.

✅ Bug: Unresolved type symbols still report isTypeSymbol() == true

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSymbol.java:176-179 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:393-396
JSema.typeSymbol marks a referenced type that no answer declares as unknown (created.unknown(true)). JSymbol.isTypeSymbol() checks only kind == Kind.TYPE, so it still returns true for that unknown symbol. The ECJ implementation the checks were written against (JDTSymbol.isTypeSymbol) returns !isUnknown() && kind == TYPE.

Checks that guard with isTypeSymbol() before treating a symbol as resolved will act differently under SemSitter for missing classpath types. Fix: mirror ECJ with return !isUnknown() && kind == Kind.TYPE;.

✅ Edge Case: Long and char annotation literals come back as source text, not Long/Character

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/TreeAnnotation.java:93-106 📄 java-frontend-semsitter/src/test/java/org/sonar/java/semsitter/TreeAnnotationTest.java:101-109
TreeAnnotation.constantValue converts only strings, booleans and int values that fit. Any other literal is returned as its source text, so big = 3L gives the String "3L" and letter = 'z' gives "'z'". The ECJ metadata passes the binding's compile-time values through unchanged (Long, Character, Double, ...), so a check that compares an annotation value against a number gets different results here.

TreeAnnotationTest.literal_values_keep_their_java_type asserts these strings. It locks in the mismatch while its name claims the Java type is kept. Fix: convert LONG_LITERAL, CHAR_LITERAL, FLOAT_LITERAL and DOUBLE_LITERAL to their boxed values, and update the test.

✅ Edge Case: Subtype cache keeps stale results for types nested around type variables

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JSema.java:134-147 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/JTypeSymbol.java:144-146
JSema.isSubtype does not cache a check whose top-level side is a TYPEVAR or CAPTURE. That exclusion exists because a type variable's answer depends on its bounds. Subtyping.hasSubtypeBound reads those bounds through MemberFactory.typeVariableBounds, which in turn reads JTypeSymbol.boundTrees or falls back to Object when the parameter symbol does not exist yet.

The exclusion only checks the outermost type, though. Arrays like T[] and parameterizations like List<T> reach the cache:

  • T[] <: Number[] goes through isArraySubtype and then element.isSubtypeOf.
  • List<T> <: List<? extends Number> goes through contains, then mine.isSubtypeOf(wanted.element).

In both cases the outer pair is stored in subtypeCache under the bounds that existed at the time of the query.

Neither JTypeSymbol.boundTrees(...) nor creating a type-parameter symbol calls invalidateTypeCaches(). So if such a check runs before a type parameter's bounds are attached, the false answer stays cached for the whole session, even after T extends Number is known.

Fix: skip the cache whenever either type contains a type variable or capture anywhere, not just at the top level. Alternatively, have boundTrees(...) call sema.invalidateTypeCaches().

...and 2 more closed from earlier reviews

Verification Rules 3/3 met Knowledge 🔎 2 PRs 3 inspected

Functional validation No results

Rules 3 passed 2 not applicable

✅ Internal artifact registries
✅ Release secrets usage
✅ Repository license compliance

Knowledge 🔎 2 informed a finding

🔎 Inherited members use their declaring type as owner informed a finding, resolved -> findMember can't match generic project methods once indexed by name
🔎 Typed annotation literal values informed a finding, won't fix -> Unicode and octal char literals still come back as source text

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

PR 6575: JAVA-7398 Translate SemSitter documents into the Java syntax tree Inspected
PR 6553: SONARJAVA-7339 Parse with the SemSitter translator behind the feature flag Inspected
PR 6578: JAVA-7401 Rank library overloads to pick the most specific method 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 Dec 2, 2026

Copy link
Copy Markdown
Contributor

@david-schroeter david-schroeter 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.

I did a first round of review on this PR, there is a few things that I think are worth addressing.

String id = element.getId();
if (!id.isEmpty()) {
dumpSymbols.put(id, element);
if ("type".equals(element.getKind()) && id.indexOf('<') < 0) {

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.

SemSitter emits a class declared inside a constructor as kind: "type" with an ID like p.C#()$Local. The < is part of the enclosing constructor’s name, not a type-parameter suffix. Checking for < anywhere in the ID makes JSema skip binary-name registration and makes LibraryMembers treat the class as a type variable. Could both checks distinguish <init> from a trailing type-parameter suffix like <T>?
Here’s a failing regression test for JSemaEdgesTest:

@Test
@EnabledIfSystemProperty(named = "semsitter.executable", matches = ".+")
void serializable_local_class_is_recognized_inside_a_constructor(@TempDir Path project) throws IOException {
    Path pkg = Files.createDirectories(project.resolve("p"));
    Files.writeString(pkg.resolve("C.java"), """
    package p;
    
        import java.io.Serializable;
    
        class C {
          C() {
            class Local implements Serializable {
              transient int cachedValue;
            }
          }
    
          void method() {
            class Local implements Serializable {
              transient int cachedValue;
            }
          }
        }
        """);

    try (SemSitterClient client = SemSitterClient.start(Path.of(System.getProperty("semsitter.executable")), project)) {
        client.setSettings(Map.of("jvm.java_version", List.of("17")));
        client.fullGen(List.of());
        Document document = client.getFile("p/C.java", 0);
        assertThat(document.getSemantic()).isTrue();
        assertThat(document.getHasError()).isFalse();
    
        sema.ingestDocument(document);
        assertThat(sema.resolve("p.C#method()$Local").type().isSubtypeOf("java.io.Serializable"))
          .as("method-local class (control)").isTrue();
        assertThat(sema.resolve("p.C#<init>()$Local").type().isSubtypeOf("java.io.Serializable"))
          .as("constructor-local class").isTrue();
    }
}

With the real server, the method-local class passes and the constructor-local class fails, even though both declare implements Serializable. The test checks the semantic predicate, not the rule output: S2057 uses that predicate to decide whether to check for a missing serialVersionUID, so it can skip the constructor-local class.

for (String id : dumpSymbols.keySet()) {
libraryMembers().createDumpSymbol(id);
}
for (String id : new ArrayList<>(dumpSymbols.keySet())) {

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.

Nit: Could we get rid of the new ArrayList<>(...) here or is there a reason to specially create an new list?

Comment on lines +187 to +189
for (String id : dumpSymbols.keySet()) {
libraryMembers().createDumpSymbol(id);
}

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.

Could we create each symbols in the first loop to avoid a second traversal of the symbols list?

* Loads the declarations of every type the document references, then keeps {@code loader} to
* fetch the types reached later, like the return type of a library method.
*/
void loadTypes(Function<Set<String>, JsonObject> loader) {

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.

Could we create JSema from the document and loader in one step? getClassType() can return an apparently known symbol before loadTypes(), and loadTypes() only collects references already ingested. A single entry point would make that order explicit.

symbols.putIfAbsent(fqn, created);
if (typesLoaded && caches.requestedTypes.add(fqn)) {
JsonObject loaded = typeLoader.apply(Set.of(fqn));
if (loaded == null) {

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.

Could we make typeLoader private and remove this null branch? The default loader and the wrapper in loadTypes() never return null. JSemaEdgesTest only reaches it by replacing the field; MemberLookupTest already covers a missing answer through loadTypes().

Optional<String> name = attrs.stream()
.filter(v -> VALUE_ATTRIBUTE.equals(v.name()) || "name".equals(v.name()))
.map(v -> (String) v.value())
.map(SymbolMetadata.AnnotationValue::value)

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.

Could we move this fix and its regression tests into a small separate PR? Unresolved annotation values can already fail bean-name and qualifier lookup under ECJ, and this PR doesn't wire SemSitter into production yet. The fix looks useful on its own.

modifiers.addAll(other.modifiers);
}

void addModifiers(Collection<String> values) {

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.

Could addModifiers() take one modifier per entry and just call modifiers.addAll(values)? MemberFactory already uses SemaFacts.flat() to split comma-separated wire values, and the other callers already pass individual modifiers.

}
}

Set<String> referencedTypeNames() {

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.

Nit: Could referencedTypeNames() be private? loadTypes() is the only production caller. The test can capture the names passed to the loader instead of calling the helper directly.

markUndeclared();
}

void ingestTypes(JsonObject types) {

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.

Nit: Could ingestTypes() be private? The tests can provide type answers through loadTypes() rather than call the internal merge directly. That keeps the model's loading API easier to understand.

this.typeParameter = typeParameter;
}

private List<TypeTree> boundTrees = List.of();

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.

Nit: Could we move boundTrees up with the other fields?

This branch has not been deployed

No deployments
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