Skip to content

Improve encapsulation of AnnotatedTypeScanner.visitedNodes #1642

@wmdietl

Description

@wmdietl

For performance reasons, we made the field non-final.
We should further encapsulate the field to prevent abuse.

visitedNodes is protected and reset() now reassigns it instead of clearing. Any subclass (including external users) that cached a reference to the map (or passes it elsewhere) will observe stale state after reset(), which is a behavioral/API change from the previous clear() behavior. If reassignment is required for performance, consider encapsulating the map (e.g., make it private and expose protected helper methods) so subclasses cannot retain aliases, or keep clearing semantics.

        visitedNodes.clear();

Originally posted by @Copilot in #1641

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions