diff --git a/android/guava/src/com/google/common/cache/CacheBuilder.java b/android/guava/src/com/google/common/cache/CacheBuilder.java index f52243e4d4ff..69b095d7e307 100644 --- a/android/guava/src/com/google/common/cache/CacheBuilder.java +++ b/android/guava/src/com/google/common/cache/CacheBuilder.java @@ -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 CACHE_STATS_COUNTER = () -> new SimpleStatsCounter(); + @SuppressWarnings("AnonymousToLambda") + static final Supplier CACHE_STATS_COUNTER = + new Supplier() { + @Override + public StatsCounter get() { + return new SimpleStatsCounter(); + } + }; enum NullListener implements RemovalListener { INSTANCE; diff --git a/guava/src/com/google/common/cache/CacheBuilder.java b/guava/src/com/google/common/cache/CacheBuilder.java index 35e9196e12ac..6e6458651397 100644 --- a/guava/src/com/google/common/cache/CacheBuilder.java +++ b/guava/src/com/google/common/cache/CacheBuilder.java @@ -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 CACHE_STATS_COUNTER = () -> new SimpleStatsCounter(); + @SuppressWarnings("AnonymousToLambda") + static final Supplier CACHE_STATS_COUNTER = + new Supplier() { + @Override + public StatsCounter get() { + return new SimpleStatsCounter(); + } + }; enum NullListener implements RemovalListener { INSTANCE;