Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/lang/management/MemoryMXBean/GetMBeanInfo.java
38821 views
/*1* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 493039726* @summary Make sure MemoryMXBean has two notification types.27* @author Mandy Chung28*29* @run main GetMBeanInfo30*/3132import java.lang.management.*;33import javax.management.*;3435public class GetMBeanInfo {36private final static int EXPECTED_NOTIF_TYPES = 2;37private static int count = 0;3839public static void main(String argv[]) throws Exception {40final ObjectName objName;41objName = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);4243MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();4445MBeanInfo minfo = mbs.getMBeanInfo(objName);46MBeanNotificationInfo[] notifs = minfo.getNotifications();47for (int i = 0; i < notifs.length; i++) {48printNotifType(notifs[i]);49}5051if (count != EXPECTED_NOTIF_TYPES) {52throw new RuntimeException("Unexpected number of notification types"53+ " count = " + count +54" expected = " + EXPECTED_NOTIF_TYPES);55}56}5758private static void printNotifType(MBeanNotificationInfo notif) {59String[] types = notif.getNotifTypes();60for (int i = 0; i < types.length; i++) {61System.out.println(types[i]);62count++;63}64}65}666768