Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1189 commits
Select commit Hold shift + click to select a range
1b2fcf4
resolve and remove some of the suppressed warnings
ben-manes Aug 25, 2024
2c3eb58
dependency updates
ben-manes Sep 1, 2024
967f17a
suppress eclipse warnings
ben-manes Sep 2, 2024
c2015da
sync with guava's cache test changes
ben-manes Sep 2, 2024
2e31df3
minor build improvements for eclipse sync
ben-manes Sep 2, 2024
50d70d0
run code generators during Eclipse project synchronization
ben-manes Sep 3, 2024
d6381ca
add unhandledWarningToken to Eclipse's ignore list
ben-manes Sep 4, 2024
2689917
dependency updates
ben-manes Sep 8, 2024
dad696a
add snia enterprise and baleen trace formats to the simulator
ben-manes Sep 14, 2024
0499355
enable all errorprone checks by default and resolve their nit warnings
ben-manes Sep 15, 2024
eafcb4a
run pmd static analyzer agaisnt the test suite
ben-manes Sep 18, 2024
124cf9a
run spotbugs static analyzer agaisnt the test suite
ben-manes Sep 20, 2024
ebd8eff
clarify javadoc (fixes #1780)
ben-manes Sep 22, 2024
e32eccd
use github action to avoid downloadThenRun scorecard warning
ben-manes Sep 22, 2024
b643bfe
simplify the gha jdk selection and enable the build cache for graalvm
ben-manes Sep 28, 2024
af9d01e
enable qodana caching between runs
ben-manes Sep 29, 2024
da2f548
upgrade errorprone static analyzer
ben-manes Sep 30, 2024
9b4cb0f
Bump github/codeql-action in the github-actions group (#1783)
dependabot[bot] Oct 1, 2024
f7e511f
dependency updates
ben-manes Oct 6, 2024
c0a69cc
dependency updates
ben-manes Oct 16, 2024
47a0101
gradle upgrade
ben-manes Oct 19, 2024
aa490e2
allow jmh benchmarks to be cached for faster ci runs
ben-manes Oct 19, 2024
0eaf6f2
dependency updates
ben-manes Oct 26, 2024
3457bf5
Fix incorrect date format pattern in unit test (#1789)
Marcono1234 Oct 26, 2024
ed1f4cd
upgrade errorprone-support static analysis
ben-manes Nov 2, 2024
832ab2c
minor touchups
ben-manes Nov 4, 2024
8b835c9
Use the ToolProvider SPI to run google-java-format (#1795)
cushon Nov 6, 2024
2d4e079
include method parameters in class file for use by static analyzers
ben-manes Nov 7, 2024
323e902
dependency updates
ben-manes Nov 12, 2024
91a36fb
optimize the frequency sketch
ben-manes Nov 16, 2024
2abba88
dependency updates
ben-manes Nov 23, 2024
a31defd
enable jspecify mode in nullaway for stricter null checks
ben-manes Nov 23, 2024
2542ca8
migrate to jspecify annotations (was checker framework)
ben-manes Nov 26, 2024
41d97e6
Avoid giving the result of loads a non-null type.
cpovirk Dec 3, 2024
e9e5013
Make function output types nullable instead of unspecified.
cpovirk Dec 3, 2024
7b93d04
Leave the value type of the `CompletableFuture` in `asMap` unspecified.
cpovirk Dec 3, 2024
1b767fb
Allow async loads to return `null`.
cpovirk Dec 3, 2024
bc74eb6
Undo accidental Javadoc formatting.
cpovirk Dec 3, 2024
d9235d3
Unmark `*LoadingCache` result types.
cpovirk Dec 4, 2024
047021c
Avoid giving the result of loads a non-null type.
cpovirk Dec 5, 2024
68e525e
enable nullaway on jmh benchmarks
ben-manes Dec 1, 2024
e512b50
Allow caches to have nullable type arguments for their value types. (…
cpovirk Dec 10, 2024
d491293
enable nullaway on unit tests
ben-manes Dec 14, 2024
8a680a3
dependency updates
ben-manes Dec 21, 2024
62f401c
remove sun.misc.unsafe leftover in the test and benchmark code
ben-manes Dec 21, 2024
88d58ca
enable nullaway on the simulator
ben-manes Dec 22, 2024
ddd1210
sign maven artifacts with sigstore
ben-manes Dec 23, 2024
d722be8
use sigstore only when publishing via github actions
ben-manes Dec 25, 2024
02349cf
use an exhaustive codeql configuration
ben-manes Dec 26, 2024
d2e530a
testing polish
ben-manes Dec 30, 2024
f381814
add openjdk's collection test suite
ben-manes Jan 3, 2025
a9846ae
restores and tests the write-through behavior on entrySet's toArray
ben-manes Jan 4, 2025
ae21802
add missing asserts to openjdk tests that check only in their custom …
ben-manes Jan 5, 2025
70f5cf8
use jakarta.inject for jcache guice integration test
ben-manes Jan 6, 2025
b09770f
upgrade to apache commons collections' junit5 test suite
ben-manes Jan 6, 2025
bbf54be
minor polish and fixes #1820
ben-manes Jan 9, 2025
3ff2445
migrate to the maintained javapoet project
ben-manes Jan 11, 2025
2d93f2b
fix variable expiration calculation when nearing overflow
ben-manes Jan 11, 2025
25405d6
skip refreshing if the async cache entry is still loading (fixes #1478)
ben-manes Jan 13, 2025
9b65365
Avoid early expiration of an pending future due to delayed pinning (f…
ben-manes Jan 13, 2025
8022a16
expand expire write optimization to more operations (fixes #1320)
ben-manes Jan 16, 2025
93d845e
prepare for next release
ben-manes Jan 17, 2025
439c561
Release 3.2.0
ben-manes Jan 18, 2025
88226ef
improve the handling of negative durations with variable expiration
ben-manes Jan 21, 2025
7500552
add zizmor static analyzer
ben-manes Jan 24, 2025
18c03d2
dependency updates
ben-manes Feb 3, 2025
2befdb1
Add @Nullable annotation in Cache2k (#1831)
msridhar Feb 9, 2025
e768cc7
dependency updates
ben-manes Feb 9, 2025
b3b3206
Update Javadoc to explain how to use nullness in type arguments in Ca…
cpovirk Feb 10, 2025
2fee4bd
enable gradle daemon toolchain auto-provisioning
ben-manes Feb 12, 2025
868924a
modernize the simulator to use jdk21 (unrelated to the core library)
ben-manes Feb 15, 2025
8ea5cad
minor touchups
ben-manes Feb 23, 2025
d884a31
Remove some unneeded suppressions (#1835)
msridhar Feb 26, 2025
1bb8465
dependency updates
ben-manes Mar 1, 2025
d49327c
better handle CaffeineSpec being reflectively constructed (fixes #1839)
ben-manes Mar 7, 2025
1ec7303
various updates and modernizations
ben-manes Mar 23, 2025
6db071c
Update to NullAway 0.12.6 (#1842)
msridhar Mar 27, 2025
063dc39
minor updates
ben-manes Mar 27, 2025
be1f523
run the test suite weekly against the jdk early access build
ben-manes Mar 29, 2025
b52316e
upgrade graalvm
ben-manes Mar 30, 2025
815c893
fix sonarqube
ben-manes Mar 30, 2025
3ae2a86
clean up jdk distribution handling
ben-manes Mar 30, 2025
ebc0cd2
add ecj for static analysis
ben-manes Apr 6, 2025
a1c8c60
minor touchups
ben-manes Apr 7, 2025
87ef8d2
resolve build properties lazily during configuration time
ben-manes Apr 8, 2025
4e03caf
resolve nullaway warnings and upgrade gradle
ben-manes Apr 11, 2025
cb0e5d9
resolve more suppressed warnings
ben-manes Apr 12, 2025
acc40a9
minor touchups
ben-manes Apr 15, 2025
6a99ff8
Spelling (#1851)
jsoref Apr 15, 2025
d04483d
Add check-spelling
jsoref Apr 10, 2025
1b88adc
touchups
ben-manes Apr 16, 2025
c6d6f2a
generalize apache commons' map tests using a junit5 parameterized class
ben-manes Apr 18, 2025
d5e3b7b
generalize eclipse collections' tests using a junit5 parameterized class
ben-manes Apr 19, 2025
137dcf5
restore the intellij workaround (IDEA-337223)
ben-manes Apr 20, 2025
797c15b
dependency updates
ben-manes Apr 24, 2025
701df97
switch to a maintained csv library
ben-manes May 4, 2025
ae33c18
prefer implicit gradle task dependencies by their input dependencies
ben-manes May 10, 2025
ae3e59f
minor build polish
ben-manes May 16, 2025
a86fa81
migrate from the osshr to the central portal
ben-manes May 16, 2025
d08e596
minor clean up
ben-manes May 19, 2025
8ddc0a0
fix sonar lint warnings
ben-manes May 20, 2025
034feeb
add test coverage for retry cases for writes with an incomplete future
ben-manes May 25, 2025
7d0843a
add test coverage for jcache re-read when the entry unexpires
ben-manes May 25, 2025
af2e295
add test case for the interner's retry loop
ben-manes May 25, 2025
08f80f4
increase multi-threaded test coverage
ben-manes May 26, 2025
c6af784
remove workaround for historic fork-join pool bugs fixed in jdk8
ben-manes May 28, 2025
d44264a
fix async cache's synchronous computeIfAbsent to retry if incomplete
ben-manes May 28, 2025
786d1c8
Use stronger memory order to avoid publication races (fixes #1820)
ben-manes May 28, 2025
dade1b1
minor touchups and dependency updates
ben-manes May 29, 2025
29bc5f1
fix intermittent nulls after replacing a weak/soft value on aarch64
ben-manes Jun 7, 2025
e0963ed
remove unreachable code
ben-manes Jun 8, 2025
b0264b9
remove unnecessary @CanIgnoreReturnValue usages for stricter checking
ben-manes Jun 8, 2025
56b69c7
minor touchups
ben-manes Jun 9, 2025
7df5358
Release 3.2.1
ben-manes Jun 9, 2025
a5e031b
increase branch coverage
ben-manes Jun 15, 2025
b20d839
increase branch coverage
ben-manes Jun 17, 2025
e9ecffe
increase branch coverage
ben-manes Jun 24, 2025
9021c74
Return correct characteristics from spliterators (#1884)
pkoenig10 Jul 1, 2025
a794497
additional tests for collection streams
ben-manes Jul 2, 2025
419e861
increase branch coverage
ben-manes Jul 5, 2025
f55fea4
minor touchups
ben-manes Jul 12, 2025
2191d9a
Release 3.2.2
ben-manes Jul 13, 2025
a4fd90d
touch ups
ben-manes Jul 13, 2025
d065a9f
workaround gradle 9-rc incompatibilities
ben-manes Jul 15, 2025
b3b8d78
dependency updates
ben-manes Jul 16, 2025
85f9d1a
dependency updates
ben-manes Jul 27, 2025
38dd616
use javadoc external snippets to compile and test the example code
ben-manes Aug 6, 2025
57f5e2b
build clean ups
ben-manes Aug 10, 2025
5bc786e
use parallel gc for parameterized tests
ben-manes Aug 11, 2025
c7ce489
remove allocation hotspots in large test suites
ben-manes Aug 11, 2025
5f02f36
Support underscore in CaffeineSpec numeric literals (fixes #1890)
ben-manes Aug 15, 2025
6b343e8
resolve coverage gap from underscore support in numeric literals
ben-manes Aug 19, 2025
2ebefd0
dependency updates
ben-manes Aug 21, 2025
db9ede6
lazier build configuration
ben-manes Aug 26, 2025
a6d0e3f
downgrade sonarqube plugin due to retracted version (fixes #1893)
ben-manes Aug 26, 2025
1c15d99
use java object layout to estimate the cache footprint
ben-manes Aug 30, 2025
1ba67ca
use more granular log levels in tests
ben-manes Sep 4, 2025
d5f5d12
update tests to use Guava's compute methods
ben-manes Sep 13, 2025
f7dc7e4
Make contents of some AtomicReference variables @Nullable (#1899)
msridhar Sep 19, 2025
d92ab9b
Remove some unnecessary NullAway suppressions (#1900)
msridhar Sep 20, 2025
7f26c19
dependency updates and document pgp keys (fixes #1901)
ben-manes Oct 4, 2025
3106ab5
disable osgi tests on jdk-25 due to currently being incompatible
ben-manes Oct 5, 2025
632a1ab
strengthen the weak/soft garbage collection in tests for jdk 26-ea
ben-manes Oct 6, 2025
038c9d0
verify reproducible jars before publishing and add build scan tags
ben-manes Oct 6, 2025
1366663
re-enable osgi tests on jdk-25 with workaround for bnd plugin
ben-manes Oct 6, 2025
bc566e3
run reproducibility test in parallel with tests
ben-manes Oct 6, 2025
7eab652
add tests for the Java Platform Module System
ben-manes Oct 11, 2025
e0dd94b
minor build clean up
ben-manes Oct 12, 2025
782ac79
use the key reference with the frequency sketch (fixes #1902)
ben-manes Oct 13, 2025
1971428
use the assemble task for a full build without running the test suites
ben-manes Oct 15, 2025
0e46d22
detect if the user's future is inconsistent with the results
ben-manes Oct 15, 2025
d8e0a92
allow the project.version to be overridden by external builders
ben-manes Oct 21, 2025
c975fc0
upgrade error-prone static analyzer
ben-manes Oct 22, 2025
6250b38
clarify policy javadoc and add corresponding test cases (fixes #1927)
ben-manes Oct 26, 2025
2299add
Allow users to read the maximum size without locking (fixes #1897)
ben-manes Oct 26, 2025
cc3f37d
reorganize into separate gradle test suites
ben-manes Oct 27, 2025
5227a98
minor build touchups
ben-manes Oct 28, 2025
6257608
Release 3.2.3
ben-manes Oct 28, 2025
f5bac04
update readme
ben-manes Oct 28, 2025
3121162
dependency updates
ben-manes Nov 1, 2025
3421a4d
add missing package-info files in test fixtures
ben-manes Nov 3, 2025
85a85b0
oss scorecard branch protection tweaks
ben-manes Nov 3, 2025
b43be40
minor polish
ben-manes Nov 6, 2025
a680a89
discard the null async mapping when in the exceeded bulk results
ben-manes Nov 8, 2025
afb27bc
Fix misplaced `@NonNull` annotation in AsyncCache getIfPresent
ben-manes Nov 9, 2025
897fe70
fix an AsyncCache.synchronous().asMap() spliterator's tryAdvance skip…
ben-manes Nov 9, 2025
5a99d0f
reschedule the pacer if the pending future has already completed
ben-manes Nov 9, 2025
7704962
adjust discarding an in-flight refresh to be more aggressive
ben-manes Nov 10, 2025
5a54a65
retry soft reference tests due to non-deterministic garbage collection
ben-manes Nov 11, 2025
b5fd0e4
avoid duplicated async completion hooks
ben-manes Nov 11, 2025
74a6e21
add more external tests
ben-manes Nov 14, 2025
602b2d5
more aggressively discard in-flight refreshes in an unbounded cache
ben-manes Nov 16, 2025
8e329e1
stricter refresh discarding
ben-manes Nov 17, 2025
a51673c
allow conditional remove/replace by identity resolve values with brok…
ben-manes Nov 21, 2025
c958ecf
workaround graalvm toolchain not being detected properly
ben-manes Nov 22, 2025
cc5425a
action updates
ben-manes Nov 23, 2025
fc36e9a
remove composite build configuration cache (macos github action bug)
ben-manes Nov 24, 2025
3c9f5a9
dependency updates, resolve warnings, and minor touchups
ben-manes Dec 7, 2025
b96af2d
resolve various intellij inspections
ben-manes Dec 26, 2025
29ee70b
more idiomatic gradle build
ben-manes Dec 27, 2025
50b524e
speed up development ci build
ben-manes Dec 29, 2025
a126699
fix sonarqube to analyze with the minimum supported java version
ben-manes Dec 29, 2025
d0357d2
split lincheck into a fast sanity check and a slow scheduled check
ben-manes Dec 29, 2025
ae682eb
avoid clobbering the local build cache
ben-manes Dec 29, 2025
4fe2e0f
resolve numerous warnings by using nullness helpers
ben-manes Dec 30, 2025
d65cf4e
added infer static analyzer
ben-manes Dec 31, 2025
96c26cf
minor touchups
ben-manes Dec 31, 2025
8d3149e
build clean up
ben-manes Jan 2, 2026
8565771
avoid accidentally skipping tests by disallowing them
ben-manes Jan 2, 2026
5fc9f04
fix jmh config mistake
ben-manes Jan 3, 2026
a254984
enable hotspot jit randomizations during testing
ben-manes Jan 3, 2026
009cc8d
minor github action updates
ben-manes Jan 3, 2026
c49dfbd
fix jcstress test failure due to jdk version specific jvm args
ben-manes Jan 6, 2026
10f7c2a
add retry logic to reference caching tests due to non-deterministic GC
ben-manes Jan 6, 2026
1d2fedc
minor updates
ben-manes Jan 9, 2026
c2a5381
resolve intellij and spotbugs warnings
ben-manes Jan 13, 2026
ddf8013
use test sharding to more evenly distribute the work across jobs
ben-manes Jan 19, 2026
857e5b9
modernize the jcache tests and replace the base class with a test fix…
ben-manes Jan 22, 2026
0222e6f
fix fuzz tests causing a segment fault due to parallel jvm forks
ben-manes Jan 25, 2026
5cc0363
fix coverage loss due to test refactoring
ben-manes Jan 25, 2026
8b5cc21
migrate test suite to junit
ben-manes Jan 31, 2026
3c892ee
enable junit parallel test execution
ben-manes Feb 2, 2026
94c9c30
test refinements
ben-manes Feb 3, 2026
242b72e
polish
ben-manes Feb 4, 2026
0ca03e8
fix test lifecycle setup
ben-manes Feb 5, 2026
9257e89
perform test sharding at discovery time
ben-manes Feb 7, 2026
3bc4d38
fix statistics when getAll fails with previously null loads
ben-manes Feb 14, 2026
4d56cbc
fix jcache's replace to publish the new value to the writer
ben-manes Feb 14, 2026
ab91706
documentation fixes
ben-manes Feb 15, 2026
e144986
additional fuzz tests (as recommended and generated by ai)
ben-manes Feb 16, 2026
3c5dfc9
add qlty static analyzer
ben-manes Feb 22, 2026
211dd54
fix putIfAbsent calculating the read expiry from the offered new value
ben-manes Feb 22, 2026
ca49c08
fix minor expiration edge cases
ben-manes Feb 22, 2026
fdb1b24
use stricter calculations to handle overflow if excessively sized
ben-manes Feb 24, 2026
ae0403e
dependency updates
ben-manes Feb 28, 2026
f29c1cf
promptly discard thread local after usage (fixes #1944)
ben-manes Mar 2, 2026
c968f98
minor edge case handling
ben-manes Mar 4, 2026
a3526ab
fix minor edge cases in put and remap
ben-manes Mar 15, 2026
eb67f93
Replace array-based lambda captures with context objects
ben-manes Mar 16, 2026
8e42145
Fix eviction stats weight and refresh linearizability in remap
ben-manes Mar 16, 2026
fded831
Fix int overflow in hill climber sample counter sum
ben-manes Mar 16, 2026
2f88253
Add ObjectInputFilter support to JavaSerializationCopier (JCache)
ben-manes Mar 16, 2026
ac0ca50
Reuse the key reference in doComputeIfAbsent node creation
ben-manes Mar 16, 2026
b57fbbf
Use bucket mask for start index in getExpirationDelay
ben-manes Mar 16, 2026
8d9b427
Add coverage gap tests for expiry exceptions, async completion, and b…
ben-manes Mar 16, 2026
853b46f
Add SARIF reporting for SpotBugs and PMD
ben-manes Mar 16, 2026
1d37b86
Fix build cache relocatability: absolute paths in task inputs (#1947)
ribafish Mar 20, 2026
d49bece
Add Fray concurrency test suite for instruction-level interleavings
ben-manes Mar 21, 2026
4ae89a7
test polish
ben-manes Mar 21, 2026
fbadda6
codify the ad hoc analysis prompts into a structured toolbox
ben-manes Mar 22, 2026
9ee85cb
add adversarial framing and parallel layers to analysis skills
ben-manes Mar 23, 2026
c76be3d
Fix UnboundedLocalCache.replace async notification bypass
ben-manes Mar 28, 2026
b97bd0d
Fix CaffeineSpec sentinel collision for maximumSize, maximumWeight, i…
ben-manes Mar 29, 2026
07156f7
Fix SerializationProxy dropping zero-duration expiration on round-trip
ben-manes Mar 29, 2026
45fdb39
Fix ageOf to mask writeTime tag bit during refresh
ben-manes Mar 30, 2026
7fb852d
Remove redundant CaffeineSpec validation, defer to builder
ben-manes Mar 30, 2026
28573b4
Avoid redundant scheduleDrainBuffers calls in hashCode and toString
ben-manes Mar 30, 2026
f5e87dc
Use expiry parameter consistently in put fast paths
ben-manes Mar 30, 2026
9863bb1
Use lambda parameter instead of captured outer variable
ben-manes Mar 30, 2026
b7e10e3
Fix TimerWheel zero-boundary handling and async expiration delay
ben-manes Mar 30, 2026
75e23bd
Skip collected entries in policy query methods
ben-manes Apr 1, 2026
bd70323
add mutation testing for coverage gap analysis
ben-manes Apr 5, 2026
c4508be
increase pit coverage
ben-manes Apr 6, 2026
556f76d
Pass caller's value to hasExpired to avoid a re-read
ben-manes Apr 11, 2026
651dadf
Defer executor dispatch in notifyOnReplace to notifyRemoval
ben-manes Apr 11, 2026
affc148
additional test coverage
ben-manes Apr 11, 2026
4e4425b
Add serialization proxy for the synchronous cache view
ben-manes Apr 13, 2026
66b8ca8
Restore producer index on OOME during write buffer resize
ben-manes Apr 13, 2026
268d1de
Harden edge cases from full audit sweep
ben-manes Apr 13, 2026
6388422
Integrate async-profiler with JMH and publish flame graphs in CI
ben-manes Apr 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
161 changes: 161 additions & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Caffeine

High-performance, near-optimal caching library for Java 11+.

## Build & Test

```bash
./gradlew :caffeine:build # Full build
./gradlew :caffeine:test --tests 'ClassName' # Single test class
./gradlew :caffeine:test --tests 'ClassName.methodName' # Single method
./gradlew :caffeine:compileTestJava # Compile tests only
```

Run individual tests, not the full suite — it's slow and sharded across 40 CI workers.

### Test Filtering

```bash
./gradlew :caffeine:test -Pimplementation=caffeine # Cache type (caffeine/guava)
./gradlew :caffeine:test -Pkeys=strong # Key reference (strong/weak)
./gradlew :caffeine:test -Pvalues=strong # Value reference (strong/weak/soft)
./gradlew :caffeine:test -Pcompute=sync # Compute mode (sync/async)
./gradlew :caffeine:test -Pstats=enabled # Stats recording (enabled/disabled)
```

### Specialized Test Suites

```bash
./gradlew :caffeine:frayTest # Fray concurrency interleaving
./gradlew :caffeine:lincheckTest # LinCheck linearizability
./gradlew :caffeine:fuzzTest # Fuzzing (Jazzer)
./gradlew :caffeine:jcstress # JCStress concurrency stress tests
./gradlew :caffeine:googleTest # Guava collections tests
./gradlew :caffeine:apacheTest # Apache Commons collections tests
./gradlew :caffeine:eclipseTest # Eclipse Collections' collections tests
./gradlew :caffeine:jctoolsTest # JCTools collections tests
./gradlew :caffeine:jsr166Test # JSR-166 collections tests
./gradlew :caffeine:openjdkTest # OpenJDK collections tests
./gradlew :caffeine:moduleTest # Java module system tests
./gradlew :caffeine:osgiTest # OSGi bundle tests
```

Tests cannot be `@Disabled` or skipped — the build fails on any skipped test.

### Static Analysis

```bash
./gradlew :caffeine:build -Pspotbugs # SpotBugs
./gradlew :caffeine:build -Ppmd # PMD
.github/scripts/analyze.sh # all
```

ErrorProne + NullAway run on every build. Fix warnings, don't suppress them.

### Benchmarks & Analysis

```bash
./gradlew jmh -PincludePattern=GetPutBenchmark # JMH microbenchmarks
./gradlew :caffeine:memoryOverhead # JOL object layout analysis
./gradlew :caffeine:stress --workload read --duration PT30S # Stress testing (read, write, refresh)
```

## Style

Google Java Style. Contributors must sign a CLA.

## Guidelines

- Before suggesting dependency versions, Semgrep rulesets, or tool integrations, verify they exist (check Maven Central, registries, JDK release notes). Never recommend unverified tools. Use latest versions.
- Stay focused on the specific task requested. Don't produce unsolicited broad recommendation plans or premature "ready for engineer follow-up" conclusions.
- Lossy/best-effort semantics (read buffer drops, approximate frequency counts, eventual consistency) are intentional design trade-offs in the cache — not defects. Read `.claude/docs/design-decisions.md` before flagging these.
- When fixing a bug or making a design change, update or create `.claude/` files (docs, rules, skills, agents) to keep them in sync with the change.
- Don't blindly suggest committing after writing code. Actually run the tests and verify the output before proposing to commit.

## Architecture

Core: `caffeine/src/main/java/com/github/benmanes/caffeine/cache/`

| File | Purpose |
|------|---------|
| `BoundedLocalCache.java` | Main cache logic: eviction, expiration, compute |
| `FrequencySketch.java` | TinyLFU admission frequency counters |
| `BoundedBuffer.java` | Striped ring buffer for read recording |
| `MpscGrowableArrayQueue.java` | Write buffer (multi-producer single-consumer) |
| `TimerWheel.java` | Hierarchical timer wheel for variable expiration |
| `Node.java` | Node interface (implementations are code-generated) |

Tests: `caffeine/src/test/java/com/github/benmanes/caffeine/cache/`

## Code Generation

Node classes (PS, PW, PSAWMW, etc.) are **generated by javaPoet**. Never edit files
in `build/generated/`. Edit the generators in `caffeine/src/javaPoet/java/` instead.

```bash
./gradlew :caffeine:generateNodes :caffeine:generateLocalCaches
```

Node naming: P=strong key, F=weak key, S=strong value, W=weak value, D=soft value.
Suffixes: A=access-time, W=write-time, R=refresh, MS=unweighted eviction, MW=weighted eviction.

## Project Structure

```
caffeine/ — Core cache library
guava/ — Guava compatibility adapter
jcache/ — JSR-107 JCache adapter
simulator/ — Cache policy simulator
```

## Reference Docs

For deep dives, read these on demand (not auto-loaded to save context):

- `.claude/docs/design-decisions.md` — why non-obvious choices are intentional, not bugs
- `.claude/docs/synchronization.md` — lock hierarchy, access modes, callback invocation points
- `.claude/docs/testing.md` — CacheSpec parameterization, Truth subjects, test utilities
- `.claude/docs/research-foundations.md` — papers mapped to implementation (TinyLFU, BP-Wrapper, etc.)
- `.claude/docs/finding-taxonomy.md` — standard severity/category schema for audit and review findings

When to read which doc:
- Concurrency or thread-safety work → `synchronization.md`
- Auditing or reviewing code → `design-decisions.md` first (prevents false positives)
- Writing or modifying tests → `testing.md`
- Understanding algorithm choices → `research-foundations.md`
- Interpreting or writing audit findings → `finding-taxonomy.md`

## Claude Code Extensions

- **Rules** (`.claude/rules/`): project conventions, loaded automatically when relevant
- **Skills** (`/review-change`): multi-layer parallel code review with blind + design-aware + regression pattern matching
- **Skills** (`/audit-*`): 19 deep analysis skills for concurrency, correctness, and performance
- **Skills** (`/audit-adversarial`): hostile full-codebase review with NO design context — finds bugs domain familiarity masks
- **Skills** (`/sim-*`): simulator workflow automation — `/sim-compare` for policy comparison charts, `/sim-analyze` for trace characterization
- **Auditor agent** (`.claude/agents/`): multi-pass — analysis → reflection → evaluator challenge → targeted re-audit

### Audit Selection Guide

| If concerned about... | Run |
|---|---|
| Thread-safety of a specific change | `/audit-jmm` |
| API contract ordering under concurrency | `/audit-linearizability` |
| Feature interactions (eviction+expiry+refresh) | `/audit-feature-interaction` |
| Exception paths leaving inconsistent state | `/audit-exception-safety` |
| Memory leaks after removal/eviction | `/audit-memory-retention` |
| Arithmetic edge cases (overflow, off-by-one) | `/audit-arithmetic` |
| Shutdown/close/GC races | `/audit-lifecycle` |
| Fresh-eyes adversarial sweep (no domain context) | `/audit-adversarial` |
| Full correctness proof of public methods | `/audit-correctness-proof` |
| Map/ConcurrentMap contract compliance | `/audit-map-contract` |
| Re-entrancy from user callbacks | `/audit-reentrancy` |
| Concurrent iteration and view consistency | `/audit-iteration` |
| Performance inefficiencies on hot paths | `/audit-performance` |
| Serialization proxy completeness and safety | `/audit-serialization` |
| Behavior under extreme/adversarial API inputs | `/audit-adversarial-input` |
| Progress and termination guarantees | `/audit-liveness` |
| Test coverage gaps and missing edge cases | `/audit-coverage-gaps` |
| Per-subsystem concurrency correctness | `/audit-subsystem-safety` |
| Build/CI configuration correctness | `/audit-build-ci` |

**Review vs Audit**: `/review-change` is for pre-commit code review — reads design docs and filters known-intentional patterns. `/audit-*` skills are for correctness doubts — independent, no design context filtering. Use review for routine changes, audit when you need fresh-eyes analysis.
Loading