124N/A/*
2362N/A * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
124N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
124N/A *
124N/A * This code is free software; you can redistribute it and/or modify it
124N/A * under the terms of the GNU General Public License version 2 only, as
124N/A * published by the Free Software Foundation.
124N/A *
124N/A * This code is distributed in the hope that it will be useful, but WITHOUT
124N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
124N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
124N/A * version 2 for more details (a copy is included in the LICENSE file that
124N/A * accompanied this code).
124N/A *
124N/A * You should have received a copy of the GNU General Public License version
124N/A * 2 along with this work; if not, write to the Free Software Foundation,
124N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
124N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
124N/A */
124N/A
124N/A/*
124N/A * @test
124N/A * @bug 6658779
124N/A * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticOptions()
124N/A * @author Daniel Fuchs
124N/A *
124N/A * @run main GetDiagnosticOptions
124N/A */
124N/A
124N/Aimport com.sun.management.HotSpotDiagnosticMXBean;
124N/Aimport com.sun.management.VMOption;
124N/Aimport java.lang.management.ManagementFactory;
124N/Aimport java.util.List;
124N/Aimport javax.management.MBeanServer;
124N/A
124N/Apublic class GetDiagnosticOptions {
124N/A private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
124N/A "com.sun.management:type=HotSpotDiagnostic";
124N/A
124N/A public static void main(String[] args) throws Exception {
178N/A List<HotSpotDiagnosticMXBean> list =
178N/A ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
178N/A HotSpotDiagnosticMXBean mbean = list.get(0);
124N/A checkDiagnosticOptions(mbean);
124N/A
124N/A MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
124N/A mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
124N/A HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
124N/A HotSpotDiagnosticMXBean.class);
124N/A checkDiagnosticOptions(mbean);
124N/A }
124N/A
124N/A private static void checkDiagnosticOptions(HotSpotDiagnosticMXBean mbean) {
124N/A List<VMOption> options = mbean.getDiagnosticOptions();
124N/A for (VMOption opt : options) {
124N/A System.out.println("option: "+opt.getName()+"="+opt.getValue());
124N/A }
124N/A }
124N/A}