Skip to content

What code should I look at to see the implementation created by Caffeine newBuilder? #1762

Answered by ben-manes
jojaeng2 asked this question in Q&A
Discussion options

You must be logged in to vote

The implementations are private to the package. The unit tests unwrap to inspect internals, such as

static <K, V> BoundedLocalCache<K, V> asBoundedLocalCache(Cache<K, V> cache) {
return (BoundedLocalCache<K, V>) cache.asMap();
}

The build uses a code generator for the concrete classes, which the method handle loads. This is to avoid memory waste to minimize field allocations, as only a few types might be used in a given application. The generated code is part of the sources jar (so your IDE should find it) or can be created by running grad…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jojaeng2
Comment options

Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants