@@ -228,15 +228,24 @@ public CacheStats snapshot() {
228
228
static final CacheStats EMPTY_STATS = new CacheStats (0 , 0 , 0 , 0 , 0 , 0 );
229
229
230
230
/*
231
- * We avoid using a method reference here for now: Inside Google, CacheBuilder is used from the
232
- * implementation of a custom ClassLoader that is sometimes used as a system classloader. That's a
233
- * problem because method-reference linking tries to look up the system classloader, and it fails
234
- * because there isn't one yet.
231
+ * We avoid using a method reference or lambda here for now:
235
232
*
236
- * I would have guessed that a lambda would produce the same problem, but maybe it's safe because
237
- * the lambda implementation is generated as a method in the _same class_ as the usage?
233
+ * - method reference: Inside Google, CacheBuilder is used from the implementation of a custom
234
+ * ClassLoader that is sometimes used as a system classloader. That's a problem because
235
+ * method-reference linking tries to look up the system classloader, and it fails because there
236
+ * isn't one yet.
237
+ *
238
+ * - lambda: Outside Google, we got a report of a similar problem in
239
+ * https://github.com/google/guava/issues/6565
238
240
*/
239
- static final Supplier <StatsCounter > CACHE_STATS_COUNTER = () -> new SimpleStatsCounter ();
241
+ @ SuppressWarnings ("AnonymousToLambda" )
242
+ static final Supplier <StatsCounter > CACHE_STATS_COUNTER =
243
+ new Supplier <StatsCounter >() {
244
+ @ Override
245
+ public StatsCounter get () {
246
+ return new SimpleStatsCounter ();
247
+ }
248
+ };
240
249
241
250
enum NullListener implements RemovalListener <Object , Object > {
242
251
INSTANCE ;
0 commit comments