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

jdk/test/java/lang/ClassLoader/forNameLeak/ClassForNameLeak.java fails with -Xcomp: ClassLoader was never enqueued!

    XMLWordPrintable

Details

    Backports

      Description

        jdk/test/java/lang/ClassLoader/forNameLeak/ClassForNameLeak.java is a regression test created for
        JDK-8151486: Class.forName causes memory leak

        The test uses PhantomReferences to verify that instances of ClassLoader are garbage collected. The test works well, but fails if the -Xcomp VM flag is given:

        ----------System.out:(11/888)----------
        returning phantom ref: java.lang.ref.PhantomReference@2f43ab0d to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@2ff14224 to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@6bebaa4a to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@4006b63a to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@58140e41 to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@745902d6 to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@3597967c to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@ee64986 to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@6ae29f7d to LeakedClassLoader
        returning phantom ref: java.lang.ref.PhantomReference@301bfb23 to LeakedClassLoader
        Enqueued java.lang.ref.PhantomReference@3597967c
        ----------System.err:(13/897)----------
        java.lang.RuntimeException: ClassLoader was never enqueued!
        at ClassForNameLeak.main(ClassForNameLeak.java:114)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-internal/Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-internal/NativeMethodAccessorImpl.java:62)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-internal/DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(java.base@9-internal/Method.java:537)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
        at java.lang.Thread.run(java.base@9-internal/Thread.java:844)

        The problem is well reproducible will any GC.

        Attachments

          Issue Links

            Activity

              People

                mchung Mandy Chung
                dfazunen Dmitry Fazunenko (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: