Skip to content

Add @Borrowed canned exception for @NoEscape retention - #12650

Closed
dougqh wants to merge 1 commit into
dougqh/perf-contract-suppressfrom
dougqh/borrowed-annotation
Closed

dougqh wants to merge 1 commit into
dougqh/perf-contract-suppressfrom
dougqh/borrowed-annotation

Conversation

@dougqh

@dougqh dougqh commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Adds @Borrowed to datadog.trace.api.function: a named, reusable "canned exception" for the recurring @NoEscape retention shape where a field's own scope is bounded the same way the retained value's would have been (e.g. a container whose lifetime is tied to a single operation). It's meta-annotated @SuppressPerfContract(value = NoEscape.class, reason = "..."), so annotating a field @Borrowed satisfies @NoEscape's Checker contract the same way a direct @SuppressPerfContract use or a // Retained on purpose: <reason> comment would.

Stacked on #12647 (@PerfContract/@SuppressPerfContract) -- this is the first real usage of the meta-annotation pattern that PR introduces.

Motivation

Gives call sites a one-word way to express the specific, recurring "this retention is fine because the field's scope is itself bounded" justification, instead of writing out the same @SuppressPerfContract/comment explanation every time.

Additional Notes

Documentation-and-tooling only; changes no behavior.

Jira ticket: APMLP-1873

A named, reusable stand-in for
@SuppressPerfContract(value = NoEscape.class, reason = "...") for the
recurring shape where a field's own scope is bounded the same way the
retained value's would have been -- e.g. a container whose lifetime
is tied to a single operation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Sep 25, 2026
@dougqh

dougqh commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing -- decided the generic @SuppressPerfContract mechanism is sufficient here; a named canned exception isn't worth it without a real recurring call site.

@dougqh dougqh closed this Sep 25, 2026
@dougqh
dougqh deleted the dougqh/borrowed-annotation branch September 25, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant