MCPcopy Create free account
hub / github.com/golang/mobile / testJavaRefKeep

Method testJavaRefKeep

bind/java/SeqTest.java:328–356  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

326 }
327
328 public void testJavaRefKeep() {
329 finalizedAnI = false;
330 AnI obj = new AnI_Traced();
331 Testpkg.callF(obj);
332 assertTrue("want F to be called", obj.calledF);
333 Testpkg.callF(obj);
334 obj = null;
335 int attempts = 0;
336 while (true) {
337 runGC();
338 if (finalizedAnI)
339 break;
340 attempts++;
341 try {
342 Thread.sleep(100);
343 } catch (InterruptedException e) {
344 throw new RuntimeException(e);
345 }
346 if (attempts >= 10)
347 fail("want obj not to be kept by Go; tried " + attempts + " garbage collections.");
348 }
349
350 finalizedAnI = false;
351 obj = new AnI_Traced();
352 Testpkg.keep(obj);
353 obj = null;
354 runGC();
355 assertFalse("want obj to be kept live by Go", finalizedAnI);
356 }
357
358 private int countI = 0;
359

Callers

nothing calls this directly

Calls 1

runGCMethod · 0.95

Tested by

no test coverage detected