Skip to content

Java type-level annotations do not emit reference edges #1486

Closed

Description

@oleksii-tumanov

Context

Code already emits references edges for annotations on Java methods, but annotations on classes, interfaces and records are skipped. In Spring, JPA and other similar projects this hides framework roles such as @Service and @Entity from the graph.

Reproduced on v8 (0.8.49).

Reproducer

@Service
@Entity(name = "checkout")
class CheckoutService {}

Cache result

The cache contains only this edge:

[
  {"source": "typeannotations_java", "target": "typeannotations_checkoutservice", "relation": "contains"}
]

No references edges to Service or Entity are emitted.

Expected

Emit references from CheckoutService to Service and Entity with context=attribute and confidence=EXTRACTED.

Activity

  1. safishamsi commented on Jun 27, 2026

    @safishamsi
    Member

    Fixed in 0.8.50 (PR #1487, thanks @oleksii-tumanov). Type-level annotations on Java classes/interfaces/records (@Service, @Entity, …) now emit references edges with the attribute context, matching method-level annotations.

  2. lvlaxim commented on Jul 31, 2026

    @lvlaxim

    @oleksii-tumanov thanks for adding Java type-level annotation references. The original goal of #1486 makes sense: framework roles such as @Service and @Entity should be represented in the graph.

    I noticed a possible symbol-resolution issue when testing this on a real Spring project.

    For 13 classes using:

    import org.springframework.stereotype.Service;
    
    @Service
    class SomeService {}

    the resulting graph contains 13 different target nodes labeled Service, with IDs scoped to the individual source files, rather than one canonical node representing:

    org.springframework.stereotype.Service
    

    Conceptually, the graph currently looks like:

    OrderService        -> Service_1
    TelegramUserService -> Service_2
    PhotoProcessor      -> Service_3
    

    rather than:

    OrderService        ─┐
    TelegramUserService ─┼-> org.springframework.stereotype.Service
    PhotoProcessor      ─┘
    

    Was the file-scoped target-node behavior intentional?

    My expectation would be that annotation references should resolve through the file's import table and reuse one canonical external-symbol node identified by the fully qualified name. Using only the short label would not be sufficient because different annotations may share the same simple name.

    For example:

    {
      "id": "external_java_org_springframework_stereotype_service",
      "label": "Service",
      "qualified_name": "org.springframework.stereotype.Service",
      "symbol_kind": "annotation",
      "external": true
    }

    The current test verifies the label pair:

    ("CheckoutService", "Service")

    but does not cover two files importing and referencing the same annotation.

    Would you consider the per-file duplication a bug in cross-file annotation-symbol resolution?
    If so, I can provide a minimal reproducer and open a focused follow-up issue for discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions