Add @Strategy marker annotation for static-polymorphism strategies#11984
Draft
dougqh wants to merge 1 commit into
Draft
Add @Strategy marker annotation for static-polymorphism strategies#11984dougqh wants to merge 1 commit into
dougqh wants to merge 1 commit into
Conversation
Contributor
|
🎯 Code Coverage (details) 🔗 Commit SHA: da64961 | Docs | Datadog PR Page | Give us feedback! |
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. |
dougqh
force-pushed
the
dougqh/strategy-annotation
branch
from
July 17, 2026 16:28
4a05183 to
fbb0085
Compare
…orphism strategies Marker-only (no enforcement yet): telegraphs the static-polymorphism strategy pattern and gives a future checker targets. @strategy marks strategy types/parameters; @StrategyConsumer marks the higher-order methods that must inline for them to specialize. Contracts live in the javadoc. Applications land in stacked PRs (FlatHashtable first). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dougqh
force-pushed
the
dougqh/strategy-annotation
branch
from
July 17, 2026 16:36
fbb0085 to
da64961
Compare
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
Adds
@Strategy, a marker annotation for static-polymorphism strategy types and parameters — the stateless, concrete-typed policy objects the JIT can devirtualize and inline so one shared algorithm specializes to straight-line code per caller.Why
First step toward making the
*Hashtable/LightMapcollections family a coherent, learnable set built on a single strategy grammar. Landing the marker first telegraphs the pattern ahead of the larger consistency changes, and gives a future checker (APT / Error Prone) a target to verify against.Marker-only — no enforcement yet. The discipline it names is held by hand for now; the contract lives in the javadoc.
Design notes
@Target({TYPE, PARAMETER})— on a type: "this is a strategy" (hold itstatic final, concrete-typed, so it inlines). On a parameter: "this is a strategy slot" (the arg should be astatic finalconstant or a non-capturing lambda). The parameter target lets us tag a slot even when its type can't be (e.g. ajava.util.function.Functionwe don't own).@Retention(SOURCE)— zero bytecode footprint, no runtime metadata (agent hygiene); a source-level checker reads it fine.@Documented— the contract is human-facing, so it belongs in the generated javadoc.@Inherited— documentary intent (a concrete subclass of a strategy base is a strategy); inert underSOURCEretention, kept as a signal.Applications
None here, by design — the first uses land in the stacked FlatHashtable PR that builds on this one.
🤖 Generated with Claude Code