3232
3333import com .google .common .annotations .GwtCompatible ;
3434import com .google .common .annotations .GwtIncompatible ;
35+ import com .google .common .annotations .J2ktIncompatible ;
3536import com .google .common .base .Ticker ;
3637import com .google .common .cache .TestingRemovalListeners .CountingRemovalListener ;
3738import com .google .common .cache .TestingRemovalListeners .QueuingRemovalListener ;
@@ -78,6 +79,7 @@ public void testInitialCapacity_setTwice() {
7879 assertThrows (IllegalStateException .class , () -> builder .initialCapacity (16 ));
7980 }
8081
82+ @ J2ktIncompatible
8183 @ GwtIncompatible // CacheTesting
8284 public void testInitialCapacity_small () {
8385 LoadingCache <?, ?> cache = CacheBuilder .newBuilder ().initialCapacity (5 ).build (identityLoader ());
@@ -90,6 +92,7 @@ public void testInitialCapacity_small() {
9092 assertThat (map .segments [3 ].table .length ()).isEqualTo (2 );
9193 }
9294
95+ @ J2ktIncompatible
9396 @ GwtIncompatible // CacheTesting
9497 public void testInitialCapacity_smallest () {
9598 LoadingCache <?, ?> cache = CacheBuilder .newBuilder ().initialCapacity (0 ).build (identityLoader ());
@@ -119,6 +122,7 @@ public void testConcurrencyLevel_setTwice() {
119122 assertThrows (IllegalStateException .class , () -> builder .concurrencyLevel (16 ));
120123 }
121124
125+ @ J2ktIncompatible
122126 @ GwtIncompatible // CacheTesting
123127 public void testConcurrencyLevel_small () {
124128 LoadingCache <?, ?> cache =
@@ -142,12 +146,14 @@ public void testMaximumSize_setTwice() {
142146 assertThrows (IllegalStateException .class , () -> builder .maximumSize (16 ));
143147 }
144148
149+ @ J2ktIncompatible
145150 @ GwtIncompatible // maximumWeight
146151 public void testMaximumSize_andWeight () {
147152 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ().maximumSize (16 );
148153 assertThrows (IllegalStateException .class , () -> builder .maximumWeight (16 ));
149154 }
150155
156+ @ J2ktIncompatible
151157 @ GwtIncompatible // digs into internals of the non-GWT implementation
152158 public void testMaximumSize_largerThanInt () {
153159 CacheBuilder <Object , Object > builder =
@@ -156,31 +162,36 @@ public void testMaximumSize_largerThanInt() {
156162 assertThat (cache .segments .length * cache .segments [0 ].table .length ()).isEqualTo (512 );
157163 }
158164
165+ @ J2ktIncompatible
159166 @ GwtIncompatible // maximumWeight
160167 public void testMaximumWeight_negative () {
161168 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ();
162169 assertThrows (IllegalArgumentException .class , () -> builder .maximumWeight (-1 ));
163170 }
164171
172+ @ J2ktIncompatible
165173 @ GwtIncompatible // maximumWeight
166174 public void testMaximumWeight_setTwice () {
167175 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ().maximumWeight (16 );
168176 assertThrows (IllegalStateException .class , () -> builder .maximumWeight (16 ));
169177 assertThrows (IllegalStateException .class , () -> builder .maximumSize (16 ));
170178 }
171179
180+ @ J2ktIncompatible
172181 @ GwtIncompatible // maximumWeight
173182 public void testMaximumWeight_withoutWeigher () {
174183 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ().maximumWeight (1 );
175184 assertThrows (IllegalStateException .class , () -> builder .build (identityLoader ()));
176185 }
177186
187+ @ J2ktIncompatible
178188 @ GwtIncompatible // weigher
179189 public void testWeigher_withoutMaximumWeight () {
180190 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ().weigher (constantWeigher (42 ));
181191 assertThrows (IllegalStateException .class , () -> builder .build (identityLoader ()));
182192 }
183193
194+ @ J2ktIncompatible
184195 @ GwtIncompatible // weigher
185196 public void testWeigher_withMaximumSize () {
186197 assertThrows (
@@ -191,12 +202,14 @@ public void testWeigher_withMaximumSize() {
191202 () -> CacheBuilder .newBuilder ().maximumSize (1 ).weigher (constantWeigher (42 )));
192203 }
193204
205+ @ J2ktIncompatible
194206 @ GwtIncompatible // weakKeys
195207 public void testKeyStrengthSetTwice () {
196208 CacheBuilder <Object , Object > builder1 = CacheBuilder .newBuilder ().weakKeys ();
197209 assertThrows (IllegalStateException .class , () -> builder1 .weakKeys ());
198210 }
199211
212+ @ J2ktIncompatible
200213 @ GwtIncompatible // weakValues
201214 public void testValueStrengthSetTwice () {
202215 CacheBuilder <Object , Object > builder1 = CacheBuilder .newBuilder ().weakValues ();
@@ -208,6 +221,7 @@ public void testValueStrengthSetTwice() {
208221 assertThrows (IllegalStateException .class , () -> builder2 .weakValues ());
209222 }
210223
224+ @ J2ktIncompatible
211225 @ GwtIncompatible // Duration
212226 @ IgnoreJRERequirement // No more dangerous than wherever the caller got the Duration from
213227 public void testLargeDurationsAreOk () {
@@ -224,6 +238,7 @@ public void testTimeToLive_negative() {
224238 assertThrows (IllegalArgumentException .class , () -> builder .expireAfterWrite (-1 , SECONDS ));
225239 }
226240
241+ @ J2ktIncompatible
227242 @ GwtIncompatible // Duration
228243 public void testTimeToLive_negative_duration () {
229244 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ();
@@ -243,6 +258,7 @@ public void testTimeToLive_setTwice() {
243258 assertThrows (IllegalStateException .class , () -> builder .expireAfterWrite (3600 , SECONDS ));
244259 }
245260
261+ @ J2ktIncompatible
246262 @ GwtIncompatible // Duration
247263 public void testTimeToLive_setTwice_duration () {
248264 CacheBuilder <Object , Object > builder =
@@ -255,6 +271,7 @@ public void testTimeToIdle_negative() {
255271 assertThrows (IllegalArgumentException .class , () -> builder .expireAfterAccess (-1 , SECONDS ));
256272 }
257273
274+ @ J2ktIncompatible
258275 @ GwtIncompatible // Duration
259276 public void testTimeToIdle_negative_duration () {
260277 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ();
@@ -274,6 +291,7 @@ public void testTimeToIdle_setTwice() {
274291 assertThrows (IllegalStateException .class , () -> builder .expireAfterAccess (3600 , SECONDS ));
275292 }
276293
294+ @ J2ktIncompatible
277295 @ GwtIncompatible // Duration
278296 public void testTimeToIdle_setTwice_duration () {
279297 CacheBuilder <Object , Object > builder =
@@ -290,25 +308,29 @@ public void testTimeToIdleAndToLive() {
290308 // well, it didn't blow up.
291309 }
292310
311+ @ J2ktIncompatible
293312 @ GwtIncompatible // refreshAfterWrite
294313 public void testRefresh_zero () {
295314 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ();
296315 assertThrows (IllegalArgumentException .class , () -> builder .refreshAfterWrite (0 , SECONDS ));
297316 }
298317
318+ @ J2ktIncompatible
299319 @ GwtIncompatible // Duration
300320 public void testRefresh_zero_duration () {
301321 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ();
302322 assertThrows (IllegalArgumentException .class , () -> builder .refreshAfterWrite (Duration .ZERO ));
303323 }
304324
325+ @ J2ktIncompatible
305326 @ GwtIncompatible // refreshAfterWrite
306327 public void testRefresh_setTwice () {
307328 CacheBuilder <Object , Object > builder =
308329 CacheBuilder .newBuilder ().refreshAfterWrite (3600 , SECONDS );
309330 assertThrows (IllegalStateException .class , () -> builder .refreshAfterWrite (3600 , SECONDS ));
310331 }
311332
333+ @ J2ktIncompatible
312334 @ GwtIncompatible // Duration
313335 public void testRefresh_setTwice_duration () {
314336 CacheBuilder <Object , Object > builder =
@@ -332,6 +354,7 @@ public void testValuesIsNotASet() {
332354 assertThat (CacheBuilder .newBuilder ().build ().asMap ().values () instanceof Set ).isFalse ();
333355 }
334356
357+ @ J2ktIncompatible
335358 @ GwtIncompatible // CacheTesting
336359 public void testNullCache () {
337360 CountingRemovalListener <Object , Object > listener = countingRemovalListener ();
@@ -345,6 +368,7 @@ public void testNullCache() {
345368 CacheTesting .checkEmpty (nullCache .asMap ());
346369 }
347370
371+ @ J2ktIncompatible
348372 @ GwtIncompatible // QueuingRemovalListener
349373 public void testRemovalNotification_clear () throws InterruptedException {
350374 // If a clear() happens while a computation is pending, we should not get a removal
@@ -415,6 +439,7 @@ public void run() {
415439 * removal listener), or else is not affected by the {@code clear()} (and therefore exists in the
416440 * cache afterward).
417441 */
442+ @ J2ktIncompatible
418443 @ GwtIncompatible // QueuingRemovalListener
419444
420445 @ SuppressWarnings ("ThreadPriorityCheck" ) // TODO: b/175898629 - Consider onSpinWait.
@@ -502,6 +527,7 @@ public void run() {
502527 * Calls get() repeatedly from many different threads, and tests that all of the removed entries
503528 * (removed because of size limits or expiration) trigger appropriate removal notifications.
504529 */
530+ @ J2ktIncompatible
505531 @ GwtIncompatible // QueuingRemovalListener
506532
507533 public void testRemovalNotification_get_basher () throws InterruptedException {
@@ -585,13 +611,15 @@ public void run() {
585611 assertThat (cache .size () + removalListener .size ()).isEqualTo (computeCount .get ());
586612 }
587613
614+ @ J2ktIncompatible
588615 @ GwtIncompatible // NullPointerTester
589616 public void testNullParameters () throws Exception {
590617 NullPointerTester tester = new NullPointerTester ();
591618 CacheBuilder <Object , Object > builder = CacheBuilder .newBuilder ();
592619 tester .testAllPublicInstanceMethods (builder );
593620 }
594621
622+ @ J2ktIncompatible
595623 @ GwtIncompatible // CacheTesting
596624 public void testSizingDefaults () {
597625 LoadingCache <?, ?> cache = CacheBuilder .newBuilder ().build (identityLoader ());
@@ -600,6 +628,7 @@ public void testSizingDefaults() {
600628 assertThat (map .segments [0 ].table .length ()).isEqualTo (4 ); // capacity / conc level
601629 }
602630
631+ @ J2ktIncompatible
603632 @ GwtIncompatible // CountDownLatch
604633 static final class DelayingIdentityLoader <T > extends CacheLoader <T , T > {
605634 private final AtomicBoolean shouldWait ;
0 commit comments