CompilationImpl.java revision 381
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt/*
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt *
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * This code is free software; you can redistribute it and/or modify it
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * under the terms of the GNU General Public License version 2 only, as
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * published by the Free Software Foundation. Sun designates this
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * particular file as subject to the "Classpath" exception as provided
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * by Sun in the LICENSE file that accompanied this code.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt *
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * This code is distributed in the hope that it will be useful, but WITHOUT
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * version 2 for more details (a copy is included in the LICENSE file that
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * accompanied this code).
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt *
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * You should have received a copy of the GNU General Public License version
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * 2 along with this work; if not, write to the Free Software Foundation,
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt *
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * CA 95054 USA or visit www.sun.com if you need additional information or
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * have any questions.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt */
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Huntpackage sun.management;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Huntimport java.lang.management.CompilationMXBean;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Huntimport java.lang.management.ManagementFactory;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Huntimport javax.management.ObjectName;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt/**
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * Implementation class for the compilation subsystem.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * Standard and committed hotspot-specific metrics if any.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt *
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * ManagementFactory.getCompilationMXBean() returns an instance
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * of this class.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt */
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Huntclass CompilationImpl implements CompilationMXBean {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt private final VMManagement jvm;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt private final String name;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt /**
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt * Constructor of CompilationImpl class.
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt */
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt CompilationImpl(VMManagement vm) {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt this.jvm = vm;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt this.name = jvm.getCompilerName();
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt if (name == null) {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt throw new AssertionError("Null compiler name");
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt public java.lang.String getName() {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt return name;
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt public boolean isCompilationTimeMonitoringSupported() {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt return jvm.isCompilationTimeMonitoringSupported();
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt public long getTotalCompilationTime() {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt if (!isCompilationTimeMonitoringSupported()) {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt throw new UnsupportedOperationException(
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt "Compilation time monitoring is not supported.");
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt return jvm.getTotalCompileTime();
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt public ObjectName getObjectName() {
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt return Util.newObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt }
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt}
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Hunt