[jdk16] RFR: 8258007: Add instrumentation to NativeLibraryTest

Mandy Chung mchung at openjdk.java.net
Fri Dec 18 22:45:58 UTC 2020


On Fri, 18 Dec 2020 22:33:11 GMT, Brent Christian <bchristi at openjdk.org> wrote:

> This change adds some extra test output for NativeLibraryTest, primarily via an update to the ForceGC utility class.
> 
> It was observed that there was nothing preventing the Cleaner from cleaning the short-lived Object that ForceGC registers before await()/doit()/System.gc() is even called.
> 
> The new 'o' reference is kept alive until FoceGC.await() has been called.
> 
> We should find out a little more the next time NativeLibraryTest fails (or perhaps it won't fail anymore!)

This looks okay.

test/lib/jdk/test/lib/util/ForceGC.java line 49:

> 47:                 System.gc();
> 48:                 System.out.format("doit %d: gc %d%n", iter, i);
> 49:                 if (cleanerInvoked.await(1L, TimeUnit.SECONDS)) {

If the object that the test waits for garbage collected takes more GC cycles than the object registered in ForceGC's cleaner, this will return immediately.   If you are concerned, maybe if the count down latch already becomes zero, it should call System.sleep before the next System.gc().

-------------

Marked as reviewed by mchung (Reviewer).

PR: https://git.openjdk.java.net/jdk16/pull/53


More information about the core-libs-dev mailing list