< prev index next >

test/java/lang/management/MemoryMXBean/Pending.java

Print this page
rev 16783 : 8176176: fix @modules in jdk_svc tests
Reviewed-by: duke


   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  * @modules java.base/jdk.internal.misc
  28  *          java.management
  29  * @summary Basic unit test of
  30  *          RuntimeMXBean.getObjectPendingFinalizationCount()
  31  *          1. GC and runFinalization() to get the current pending number
  32  *          2. Create some number of objects with reference and without ref.
  33  *          3. Clear all the references
  34  *          4. GC and runFinalization() and the finalizable objects should
  35  *             be garbage collected.
  36  * @author  Alexei Guibadoulline and Mandy Chung



  37  */
  38 
  39 import java.lang.management.*;
  40 
  41 public class Pending {
  42     static final int NO_REF_COUNT = 600;
  43     static final int REF_COUNT = 500;
  44     static final int TOTAL_FINALIZABLE = (NO_REF_COUNT + REF_COUNT);
  45     private static int finalized = 0;
  46     private static MemoryMXBean mbean
  47         = ManagementFactory.getMemoryMXBean();
  48 
  49     private static final String INDENT = "      ";
  50     private static void printFinalizerInstanceCount() {
  51         if (!trace) return;
  52 
  53         int count = jdk.internal.misc.VM.getFinalRefCount();
  54         System.out.println(INDENT + "Finalizable object Count = " + count);
  55 
  56         count = jdk.internal.misc.VM.getPeakFinalRefCount();




   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
  28  *          RuntimeMXBean.getObjectPendingFinalizationCount()
  29  *          1. GC and runFinalization() to get the current pending number
  30  *          2. Create some number of objects with reference and without ref.
  31  *          3. Clear all the references
  32  *          4. GC and runFinalization() and the finalizable objects should
  33  *             be garbage collected.
  34  * @author  Alexei Guibadoulline and Mandy Chung
  35  *
  36  * @modules java.base/jdk.internal.misc
  37  *          java.management
  38  */
  39 
  40 import java.lang.management.*;
  41 
  42 public class Pending {
  43     static final int NO_REF_COUNT = 600;
  44     static final int REF_COUNT = 500;
  45     static final int TOTAL_FINALIZABLE = (NO_REF_COUNT + REF_COUNT);
  46     private static int finalized = 0;
  47     private static MemoryMXBean mbean
  48         = ManagementFactory.getMemoryMXBean();
  49 
  50     private static final String INDENT = "      ";
  51     private static void printFinalizerInstanceCount() {
  52         if (!trace) return;
  53 
  54         int count = jdk.internal.misc.VM.getFinalRefCount();
  55         System.out.println(INDENT + "Finalizable object Count = " + count);
  56 
  57         count = jdk.internal.misc.VM.getPeakFinalRefCount();


< prev index next >