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

Avoid Reference.isEnqueued in tests

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: hotspot
    • Subcomponent:
      gc
    • Resolved In Build:
      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

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

                Dates

                Created:
                Updated:
                Resolved: