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

ClassForNameLeak fails intermittently as the class loader hasn't been unloaded

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 21
    • None
    • core-libs

    Description

      The ClassForNameLeak test includes a loop[1] that calls System.gc() in order to give some phantom references (to class loaders created earlier in the test) a chance to be enqueued for processing. When running on GraalVM, this loop sometimes does not run long enough to allow all phantom references to be enqueued, resulting in:

      java.lang.RuntimeException: ClassLoader was never enqueued!
              at ClassForNameLeak.main(ClassForNameLeak.java:118)
              at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
              at java.base/java.lang.reflect.Method.invoke(Method.java:578)
              at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
              at java.base/java.lang.Thread.run(Thread.java:1583)

      Bumping the number of loop iterations from 10 to 100 seems to reliably prevent the failure.

      [1] https://github.com/openjdk/jdk/blob/09514745fc87d5a212bdf09399aa2045f02b4612/test/jdk/java/lang/ClassLoader/forNameLeak/ClassForNameLeak.java#L109-L112

      Attachments

        Issue Links

          Activity

            People

              mchung Mandy Chung
              dnsimon Douglas Simon
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: