Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial rollback of cl/441881361 to fix https://github.com/google/guava/issues/6565 #6571

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions android/guava/src/com/google/common/cache/CacheBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,24 @@ public CacheStats snapshot() {
static final CacheStats EMPTY_STATS = new CacheStats(0, 0, 0, 0, 0, 0);

/*
* We avoid using a method reference here for now: Inside Google, CacheBuilder is used from the
* implementation of a custom ClassLoader that is sometimes used as a system classloader. That's a
* problem because method-reference linking tries to look up the system classloader, and it fails
* because there isn't one yet.
* We avoid using a method reference or lambda here for now:
*
* I would have guessed that a lambda would produce the same problem, but maybe it's safe because
* the lambda implementation is generated as a method in the _same class_ as the usage?
* - method reference: Inside Google, CacheBuilder is used from the implementation of a custom
* ClassLoader that is sometimes used as a system classloader. That's a problem because
* method-reference linking tries to look up the system classloader, and it fails because there
* isn't one yet.
*
* - lambda: Outside Google, we got a report of a similar problem in
* https://github.com/google/guava/issues/6565
*/
static final Supplier<StatsCounter> CACHE_STATS_COUNTER = () -> new SimpleStatsCounter();
@SuppressWarnings("AnonymousToLambda")
static final Supplier<StatsCounter> CACHE_STATS_COUNTER =
new Supplier<StatsCounter>() {
@Override
public StatsCounter get() {
return new SimpleStatsCounter();
}
};

enum NullListener implements RemovalListener<Object, Object> {
INSTANCE;
Expand Down
23 changes: 16 additions & 7 deletions guava/src/com/google/common/cache/CacheBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,24 @@ public CacheStats snapshot() {
static final CacheStats EMPTY_STATS = new CacheStats(0, 0, 0, 0, 0, 0);

/*
* We avoid using a method reference here for now: Inside Google, CacheBuilder is used from the
* implementation of a custom ClassLoader that is sometimes used as a system classloader. That's a
* problem because method-reference linking tries to look up the system classloader, and it fails
* because there isn't one yet.
* We avoid using a method reference or lambda here for now:
*
* I would have guessed that a lambda would produce the same problem, but maybe it's safe because
* the lambda implementation is generated as a method in the _same class_ as the usage?
* - method reference: Inside Google, CacheBuilder is used from the implementation of a custom
* ClassLoader that is sometimes used as a system classloader. That's a problem because
* method-reference linking tries to look up the system classloader, and it fails because there
* isn't one yet.
*
* - lambda: Outside Google, we got a report of a similar problem in
* https://github.com/google/guava/issues/6565
*/
static final Supplier<StatsCounter> CACHE_STATS_COUNTER = () -> new SimpleStatsCounter();
@SuppressWarnings("AnonymousToLambda")
static final Supplier<StatsCounter> CACHE_STATS_COUNTER =
new Supplier<StatsCounter>() {
@Override
public StatsCounter get() {
return new SimpleStatsCounter();
}
};

enum NullListener implements RemovalListener<Object, Object> {
INSTANCE;
Expand Down