< prev index next >

test/jdk/java/util/logging/TestLoggerWeakRefLeak.java

Print this page
rev 51638 : [mq]: 8210112


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.BufferedReader;
  25 import java.io.InputStream;
  26 import java.io.InputStreamReader;
  27 
  28 import static jdk.testlibrary.Asserts.assertGreaterThan;
  29 import jdk.testlibrary.ProcessTools;
  30 
  31 import com.sun.tools.attach.AttachNotSupportedException;
  32 import com.sun.tools.attach.VirtualMachine;
  33 
  34 import sun.tools.attach.HotSpotVirtualMachine;
  35 
  36 /*
  37  * @test
  38  * @bug 6942989
  39  * @summary Check for WeakReference leak in Logger and anonymous Logger objects
  40  * @library /lib/testlibrary

  41  * @modules jdk.attach/sun.tools.attach
  42  *          java.logging
  43  * @build jdk.testlibrary.ProcessTools
  44  * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak Logger
  45  * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak AnonymousLogger
  46  */
  47 public class TestLoggerWeakRefLeak {
  48 
  49     private static final String TARGET_CLASS = "java.lang.ref.WeakReference";
  50     private static final int INSTANCE_COUNT = 100;
  51     private static int loggerCount = 0;
  52 
  53     public static void main(String[] args) throws Exception {
  54         if (args[0].equals("AnonymousLogger")) {
  55             System.out.println("Test for WeakReference leak in AnonymousLogger object");
  56             testIfLeaking(TestLoggerWeakRefLeak::callAnonymousLogger);
  57         } else {
  58             System.out.println("Test for WeakReference leak in Logger object");
  59             testIfLeaking(TestLoggerWeakRefLeak::callLogger);
  60         }
  61     }
  62 
  63     /**




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.BufferedReader;
  25 import java.io.InputStream;
  26 import java.io.InputStreamReader;
  27 
  28 import static jdk.testlibrary.Asserts.assertGreaterThan;
  29 import jdk.test.lib.process.ProcessTools;
  30 
  31 import com.sun.tools.attach.AttachNotSupportedException;
  32 import com.sun.tools.attach.VirtualMachine;
  33 
  34 import sun.tools.attach.HotSpotVirtualMachine;
  35 
  36 /*
  37  * @test
  38  * @bug 6942989
  39  * @summary Check for WeakReference leak in Logger and anonymous Logger objects
  40  * @library /lib/testlibrary
  41  * @library /test/lib
  42  * @modules jdk.attach/sun.tools.attach
  43  *          java.logging
  44  * @build jdk.test.lib.process.ProcessTools
  45  * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak Logger
  46  * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak AnonymousLogger
  47  */
  48 public class TestLoggerWeakRefLeak {
  49 
  50     private static final String TARGET_CLASS = "java.lang.ref.WeakReference";
  51     private static final int INSTANCE_COUNT = 100;
  52     private static int loggerCount = 0;
  53 
  54     public static void main(String[] args) throws Exception {
  55         if (args[0].equals("AnonymousLogger")) {
  56             System.out.println("Test for WeakReference leak in AnonymousLogger object");
  57             testIfLeaking(TestLoggerWeakRefLeak::callAnonymousLogger);
  58         } else {
  59             System.out.println("Test for WeakReference leak in Logger object");
  60             testIfLeaking(TestLoggerWeakRefLeak::callLogger);
  61         }
  62     }
  63 
  64     /**


< prev index next >