Skip to content

Add @Strategy marker annotation for static-polymorphism strategies#11984

Draft
dougqh wants to merge 1 commit into
masterfrom
dougqh/strategy-annotation
Draft

Add @Strategy marker annotation for static-polymorphism strategies#11984
dougqh wants to merge 1 commit into
masterfrom
dougqh/strategy-annotation

Conversation

@dougqh

@dougqh dougqh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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 / LightMap collections 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 it static final, concrete-typed, so it inlines). On a parameter: "this is a strategy slot" (the arg should be a static final constant or a non-capturing lambda). The parameter target lets us tag a slot even when its type can't be (e.g. a java.util.function.Function we 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 under SOURCE retention, 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

@dougqh dougqh added tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes comp: core Tracer core type: refactoring labels Jul 17, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 57.27% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: da64961 | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.94 s 13.92 s [-0.6%; +0.8%] (no difference)
startup:insecure-bank:tracing:Agent 12.90 s 13.01 s [-1.6%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 16.95 s 16.67 s [+0.7%; +2.7%] (maybe worse)
startup:petclinic:iast:Agent 16.90 s 16.87 s [-0.4%; +0.8%] (no difference)
startup:petclinic:profiling:Agent 16.83 s 16.87 s [-1.4%; +0.9%] (no difference)
startup:petclinic:sca:Agent 16.94 s 16.61 s [+0.9%; +3.2%] (maybe worse)
startup:petclinic:tracing:Agent 15.66 s 15.97 s [-6.1%; +2.3%] (no difference)

Commit: da649614 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@dougqh
dougqh force-pushed the dougqh/strategy-annotation branch from 4a05183 to fbb0085 Compare July 17, 2026 16:28
…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
dougqh force-pushed the dougqh/strategy-annotation branch from fbb0085 to da64961 Compare July 17, 2026 16:36
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