Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8257876

Avoid Reference.isEnqueued in tests

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 16
    • 16
    • hotspot
    • gc
    • b28

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: