< prev index next >

test/java/lang/management/ClassLoadingMXBean/LoadCounts.java

Print this page
rev 11832 : 8078896: Add @modules as needed to the jdk_svc tests
Reviewed-by: alanb, mchung
   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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 /*
  25  * @test
  26  * @bug     4530538
  27  * @summary Basic unit test of ClassLoadingMXBean.getLoadedClassCount()
  28  *                             ClassLoadingMXBean.getTotalLoadedClassCount()
  29  *                             ClassLoadingMXBean.getUnloadedClassCount()
  30  * @author  Alexei Guibadoulline

  31  * @run main/othervm LoadCounts
  32  */
  33 
  34 import java.lang.management.*;
  35 
  36 public class LoadCounts {
  37     private static ClassLoadingMXBean mbean
  38         = ManagementFactory.getClassLoadingMXBean();
  39 
  40     public static void main(String argv[]) throws Exception {
  41         // Get current count
  42         int classesNowPrev = mbean.getLoadedClassCount();
  43         long classesTotalPrev = mbean.getTotalLoadedClassCount();
  44 
  45         System.out.println("Loading 4 classes with the system class loader");
  46 
  47         new SimpleOne();
  48         new SimpleTwo();
  49         new Chain();
  50 


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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 /*
  25  * @test
  26  * @bug     4530538
  27  * @summary Basic unit test of ClassLoadingMXBean.getLoadedClassCount()
  28  *                             ClassLoadingMXBean.getTotalLoadedClassCount()
  29  *                             ClassLoadingMXBean.getUnloadedClassCount()
  30  * @author  Alexei Guibadoulline
  31  * @modules java.management
  32  * @run main/othervm LoadCounts
  33  */
  34 
  35 import java.lang.management.*;
  36 
  37 public class LoadCounts {
  38     private static ClassLoadingMXBean mbean
  39         = ManagementFactory.getClassLoadingMXBean();
  40 
  41     public static void main(String argv[]) throws Exception {
  42         // Get current count
  43         int classesNowPrev = mbean.getLoadedClassCount();
  44         long classesTotalPrev = mbean.getTotalLoadedClassCount();
  45 
  46         System.out.println("Loading 4 classes with the system class loader");
  47 
  48         new SimpleOne();
  49         new SimpleTwo();
  50         new Chain();
  51 


< prev index next >