Skip to content

Add ClassResolverCache for valid constructor lookup #117

Description

@MessiasLima

Description

Create a ClassResolverCache to cache valid constructor lookup results used by ClassResolver. This should reduce repeated reflection and constructor-selection work when the same classes are resolved multiple times.

Scope and constraints

  • Preserve constructor declaration order and first-success behavior.
  • Preserve fallback from failed constructors to later constructors.
  • Do not cache generated constructor arguments or instantiated objects.
  • Account for requested generic types, default-value strategy, property factories, and constructor failures when determining cache validity.
  • Preserve existing circular-reference and instantiation-exception behavior.

References

Scope

Add ClassResolverCache, integrate it with ClassResolver, and add tests verifying constructor-cache reuse and behavior preservation.

Out of scope: changing constructor ordering, constructor argument-generation rules, resolver precedence, or the public Resolver API.

Acceptance criteria

  • ClassResolverCache stores and returns valid constructor lookup results for supported classes.
  • Repeated resolution of the same compatible class reuses cached constructor information without repeating the full constructor-discovery process.
  • Constructor selection continues to use declaration order and returns the first constructor that succeeds.
  • If a constructor fails, later constructors remain eligible and existing fallback behavior is preserved.
  • Cache entries do not incorrectly reuse constructor selections across incompatible generic types or configuration contexts.
  • Existing behavior for private constructors, empty constructors, default parameters, property factories, circular references, and SomeInstantiationException remains unchanged.
  • Tests verify cache reuse, constructor fallback, cache isolation, and existing failure behavior.

Activity

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

    Projects

    • Status
      Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions