Skip to content

Cache @Computed/@Derived method descriptors in Record.StaticAnalysis #136

Description

@jtnelson

Summary

Record.$computed() (Record.java:2377) and $derived()
(Record.java:2428) memoize their results per instance, but the work
they cache -- scanning the full method hierarchy
(getAllNonOverriddenDefaultInterfaceMethods + getAllDeclaredMethods)
and probing each method for @Computed / @Derived -- produces a
class-level fact. A bulk load of N records of the same class pays N
identical reflective scans.

Implementation Plan

  1. Move descriptor discovery (which methods are @Computed/@derived, their
    resolved keys, and isDefault) into the existing class-keyed
    Record.StaticAnalysis inner class, computed once per class.
  2. Per instance, only bind the suppliers (computed) / evaluate the values
    (derived) from the cached descriptors.

Acceptance Criteria

  • The method hierarchy is scanned at most once per class, not per
    instance.
  • Computed suppliers still bind to the instance; derived values still
    evaluate per instance.
  • Existing computed/derived tests pass.

Effort

Small-Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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