Conversation
The type form only works when the returned value's concrete type can carry the annotation. It can't for a lambda/anonymous instance of a JDK interface (Iterable, Iterator, ...), which is exactly the shape ConcurrentHashtable's hashIterable/hashIterator return. Add METHOD to @target so the constraint can be documented on the factory method itself, and extend the checker contract (and its perf-review checks.md entry) with the matching field-initialized-from-call trigger shape. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dougqh
marked this pull request as ready for review
September 15, 2026 20:31
There was a problem hiding this comment.
More details
The method target matches the documented checker contract. CLASS retention keeps the change outside runtime behavior.
🤖 Datadog Autotest · Commit 6543b2f · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
This comment has been minimized.
This comment has been minimized.
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
amarziali
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Widens
datadog.trace.api.function.NoEscape(added in #12368) from@Target(TYPE)to@Target({TYPE, METHOD}), and extends its Javadoc "Checker contract" with a matching method-form trigger.Motivation
The type form only works when the returned value's concrete type can itself carry the annotation (e.g.
SubSequence,Maybe). It can't when the return type is a lambda or anonymous instance of a JDK interface —Iterable,Iterator,Runnable, etc — which we can't annotate. That's exactly the shape ofConcurrentHashtable.hashIterable/hashIterator(in a companion branch), which return() -> hashIterator(...)-style lambdas that should never be retained past the scan that consumes them.The two forms compose: annotate the type when you can, fall back to the method when you can't.
Additional Notes
@NoEscapestaysCLASS-retention, no runtime semantics.ConcurrentHashtable.hashIterable/hashIterator.checks.mdentry to describe both trigger shapes.Contributor Checklist
type:andcomp:labels in addition to any other useful labelsclose/fix/linking keywords when referencing an issue🤖 Generated with Claude Code