RFR: 8257876: Avoid Reference.isEnqueued in tests

Thomas Schatzl tschatzl at openjdk.java.net
Wed Dec 9 14:01:35 UTC 2020


On Wed, 9 Dec 2020 13:23:47 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Please review this change that eliminates the use of Reference.isEnqueued by
>> tests.  There were three tests using it:
>> 
>> vmTestbase/gc/gctests/ReferencesGC/ReferencesGC.java
>> vmTestbase/gc/gctests/WeakReferenceGC/WeakReferenceGC.java
>> jdk/java/lang/ref/ReferenceEnqueue.java
>> 
>> In each of them, some combination of using Reference.refersTo and
>> ReferenceQueue.remove with a timeout were used to eliminate the use of
>> Reference.isEnqueued.
>> 
>> I also cleaned up ReferencesGC.java in various respects.  It contained
>> several bits of dead code, and the failure checks were made stronger.
>> 
>> Testing:
>> mach5 tier1
>> Locally (linux-x64) ran all three tests with each GC (including Shenandoah).
>
> test/jdk/java/lang/ref/ReferenceEnqueue.java line 58:
> 
>> 56:             for (int i = 0; i < iterations; i++) {
>> 57:                 System.gc();
>> 58:                 enqueued = (queue.remove(100) == ref);
> 
> The code does not catch `InterruptedException` like it does in the other files.

I understand that the test code previously just forwarded the `InterruptedException` if it happened in the `Thread.sleep()` call too. So this may only be an exiting issue and please ignore this comment.
Not catching `InterruptedException` here only seems to be a cause for unnecessary failure. Then again, it probably does not happen a lot.

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

PR: https://git.openjdk.java.net/jdk/pull/1691


More information about the core-libs-dev mailing list