diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java b/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java index f8a92e25fef..9dd8987717e 100644 --- a/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java @@ -25,9 +25,6 @@ package sun.jvmstat.monitor; -import sun.management.counter.Units; -import sun.management.counter.Variability; - /** * The base class for Instrumentation Monitoring Objects. This base class * provides implementations of the {@link Monitor} methods that are common diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java b/jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java index 071a29b27de..0d5dbadc859 100644 --- a/jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java +++ b/jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java @@ -25,9 +25,6 @@ package sun.jvmstat.monitor; -import sun.management.counter.Units; -import sun.management.counter.Variability; - /** * Interface provided by Instrumentation Monitoring Objects. * diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/Units.java b/jdk/src/share/classes/sun/jvmstat/monitor/Units.java new file mode 100644 index 00000000000..5e632196df3 --- /dev/null +++ b/jdk/src/share/classes/sun/jvmstat/monitor/Units.java @@ -0,0 +1,128 @@ +/* + * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.jvmstat.monitor; + +/** + * Provides a typesafe enumeration for describing units of measurement + * attribute for instrumentation objects. + * + * @author Brian Doherty + */ +public class Units implements java.io.Serializable { + + /* The enumeration values for this typesafe enumeration must be + * kept in synchronization with the Units enum in the perfData.hpp file + * in the HotSpot source base. + */ + + private static final int NUNITS=8; + + private static Units[] map = new Units[NUNITS]; + + private final String name; + private final int value; + + /** + * An Invalid Units value. + */ + public static final Units INVALID = new Units("Invalid", 0); + + /** + * Units attribute representing unit-less quantities. + */ + public static final Units NONE = new Units("None", 1); + + /** + * Units attribute representing Bytes. + */ + public static final Units BYTES = new Units("Bytes", 2); + + /** + * Units attribute representing Ticks. + */ + public static final Units TICKS = new Units("Ticks", 3); + + /** + * Units attribute representing a count of events. + */ + public static final Units EVENTS = new Units("Events", 4); + + /** + * Units attribute representing String data. Although not really + * a unit of measure, this Units value serves to distinguish String + * instrumentation objects from instrumentation objects of other types. + */ + public static final Units STRING = new Units("String", 5); + + /** + * Units attribute representing Hertz (frequency). + */ + public static final Units HERTZ = new Units("Hertz", 6); + + /** + * Returns a string describing this Unit of measurement attribute + * + * @return String - a descriptive string for this enum. + */ + public String toString() { + return name; + } + + /** + * Returns the integer representation of this Units attribute + * + * @return int - an integer representation of this Units attribute. + */ + public int intValue() { + return value; + } + + /** + * Maps an integer value to its corresponding Units attribute. + * If the integer value does not have a corresponding Units enum + * value, then {@link Units#INVALID} is returned. + * + * @param value an integer representation of counter Units + * @return Units - the Units object for the given value + * or {@link Units#INVALID} if out of range. + */ + public static Units toUnits(int value) { + + if (value < 0 || value >= map.length || map[value] == null) { + return INVALID; + } + + return map[value]; + } + + private Units(String name, int value) { + this.name = name; + this.value = value; + map[value] = this; + } + + private static final long serialVersionUID = 6992337162326171013L; +} diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java b/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java new file mode 100644 index 00000000000..1323226d4a5 --- /dev/null +++ b/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java @@ -0,0 +1,111 @@ +/* + * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.jvmstat.monitor; + +/** + * Provides a typesafe enumeration for the Variability attribute for + * instrumentation objects. + * + * @author Brian Doherty + */ +public class Variability implements java.io.Serializable { + + /* The enumeration values for this typesafe enumeration must be + * kept in synchronization with the Variability enum in the perfData.hpp file + * in the HotSpot source base. + */ + + private static final int NATTRIBUTES = 4; + private static Variability[] map = new Variability[NATTRIBUTES]; + + private String name; + private int value; + + /** + * An invalid Variablity value. + */ + public static final Variability INVALID = new Variability("Invalid",0); + + /** + * Variability attribute representing Constant counters. + */ + public static final Variability CONSTANT = new Variability("Constant",1); + + /** + * Variability attribute representing a Monotonically changing counters. + */ + public static final Variability MONOTONIC = new Variability("Monotonic",2); + + /** + * Variability attribute representing Variable counters. + */ + public static final Variability VARIABLE = new Variability("Variable",3); + + /** + * Returns a string describing this Variability attribute. + * + * @return String - a descriptive string for this enum. + */ + public String toString() { + return name; + } + + /** + * Returns the integer representation of this Variability attribute. + * + * @return int - an integer representation of this Variability attribute. + */ + public int intValue() { + return value; + } + + /** + * Maps an integer value its corresponding Variability attribute. + * If the integer value does not have a corresponding Variability enum + * value, the {@link Variability#INVALID} is returned + * + * @param value an integer representation of a Variability attribute + * @return Variability - The Variability object for the given + * value or {@link Variability#INVALID} + * if out of range. + */ + public static Variability toVariability(int value) { + + if (value < 0 || value >= map.length || map[value] == null) { + return INVALID; + } + + return map[value]; + } + + private Variability(String name, int value) { + this.name = name; + this.value = value; + map[value]=this; + } + + private static final long serialVersionUID = 6992337162326171013L; +} diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java index 39b3d35b300..15832778a7d 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java @@ -26,8 +26,6 @@ package sun.jvmstat.perfdata.monitor; import sun.jvmstat.monitor.*; -import sun.management.counter.Units; -import sun.management.counter.Variability; import java.nio.ByteBuffer; /** diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java index 4730c3b5de8..b69d7c6e0e5 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java @@ -26,8 +26,6 @@ package sun.jvmstat.perfdata.monitor; import sun.jvmstat.monitor.*; -import sun.management.counter.Units; -import sun.management.counter.Variability; import java.nio.IntBuffer; /** diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java index c73073755d0..e8948b0b669 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java @@ -26,8 +26,6 @@ package sun.jvmstat.perfdata.monitor; import sun.jvmstat.monitor.*; -import sun.management.counter.Units; -import sun.management.counter.Variability; import java.nio.LongBuffer; /** diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java index e20611230bd..f34376d3912 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java @@ -26,7 +26,6 @@ package sun.jvmstat.perfdata.monitor; import sun.jvmstat.monitor.*; -import sun.management.counter.Variability; import java.nio.ByteBuffer; /** diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java index 2119db9946a..0f1b5c4c2c6 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java @@ -26,8 +26,6 @@ package sun.jvmstat.perfdata.monitor; import sun.jvmstat.monitor.*; -import sun.management.counter.Units; -import sun.management.counter.Variability; import java.nio.ByteBuffer; import java.nio.charset.Charset; diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java index fece6d9a6b6..252a5204b24 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java @@ -26,7 +26,6 @@ package sun.jvmstat.perfdata.monitor; import sun.jvmstat.monitor.*; -import sun.management.counter.Variability; import java.nio.ByteBuffer; /** diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java index a823ca68dbe..fea037d0265 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java @@ -25,8 +25,6 @@ package sun.jvmstat.perfdata.monitor.v1_0; -import sun.management.counter.Units; -import sun.management.counter.Variability; import sun.jvmstat.monitor.*; import sun.jvmstat.perfdata.monitor.*; import java.util.*; diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java index b090bc2203c..77b3c1a088c 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java @@ -27,8 +27,6 @@ package sun.jvmstat.perfdata.monitor.v2_0; import sun.jvmstat.monitor.*; import sun.jvmstat.perfdata.monitor.*; -import sun.management.counter.Units; -import sun.management.counter.Variability; import java.util.*; import java.util.regex.*; import java.nio.*; diff --git a/jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java b/jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java index e5336135075..f6006d64fed 100644 --- a/jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java +++ b/jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java @@ -26,7 +26,6 @@ package sun.tools.jstat; import sun.jvmstat.monitor.*; -import sun.management.counter.Variability; /** * A class implementing the ExpressionEvaluator to resolve unresolved diff --git a/jdk/src/share/classes/sun/tools/jstat/JStatLogger.java b/jdk/src/share/classes/sun/tools/jstat/JStatLogger.java index 077dd90096a..671f1c2893d 100644 --- a/jdk/src/share/classes/sun/tools/jstat/JStatLogger.java +++ b/jdk/src/share/classes/sun/tools/jstat/JStatLogger.java @@ -29,8 +29,6 @@ import java.util.*; import java.io.*; import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.event.*; -import sun.management.counter.Units; -import sun.management.counter.Variability; import java.util.regex.PatternSyntaxException; /** diff --git a/jdk/src/share/classes/sun/tools/jstat/Jstat.java b/jdk/src/share/classes/sun/tools/jstat/Jstat.java index 43cbaa29a53..c778212d04a 100644 --- a/jdk/src/share/classes/sun/tools/jstat/Jstat.java +++ b/jdk/src/share/classes/sun/tools/jstat/Jstat.java @@ -28,8 +28,6 @@ package sun.tools.jstat; import java.util.*; import sun.jvmstat.monitor.*; import sun.jvmstat.monitor.event.*; -import sun.management.counter.Variability; -import sun.management.counter.Units; /** * Application to output jvmstat statistics exported by a target Java