Avoid Reference.isEnqueued in tests

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 16
    • Affects Version/s: 16
    • Component/s: hotspot
    • gc
    • b28

      Reference.isEnqueued is being deprecated (JDK-8052260). There are a couple of tests that use it and should be updated.

      The test vmTestbase/gc/gctests/ReferencesGC/ReferencesGC.java uses Reference.isEnqueued() to detect whether the GC has cleared and notified Reference objects. Because of timing issues, it's probably possible for these to not work as intended, since the references might not make it to their respective queues immediately. Better would be to use the recently added Reference.refersTo with a null argument.

      The test jdk/java/lang/ref/ReferenceEnqueue.java also uses Reference.isEnqueued, again in a way that is subject to timing issues. It could instead use Reference.refersTo and ReferenceQueue.remove with a timeout.

      vmTestBase/gc/gctests/WeakReferenceGC/WeakReferenceGC.java also uses isEnqueued. This can also be dealt with by using ReferenceQueue.remove with a timeout.

            Assignee:
            Kim Barrett
            Reporter:
            Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: