6951661: Eliminate jvmstat dependency on sun.management.counter
authormchung
Wed, 12 May 2010 14:41:10 -0700
changeset 5599 a9bbe8282b0f
parent 5469 18ea05ea56b9
child 5600 8ca34998a6b3
6951661: Eliminate jvmstat dependency on sun.management.counter Summary: jvmstat keeps its own copy of Units and Variability class Reviewed-by: alanb
jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java
jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java
jdk/src/share/classes/sun/jvmstat/monitor/Units.java
jdk/src/share/classes/sun/jvmstat/monitor/Variability.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java
jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java
jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java
jdk/src/share/classes/sun/tools/jstat/JStatLogger.java
jdk/src/share/classes/sun/tools/jstat/Jstat.java
--- a/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -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
--- a/jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/Monitor.java	Wed May 12 14:41:10 2010 -0700
@@ -25,9 +25,6 @@
 
 package sun.jvmstat.monitor;
 
-import sun.management.counter.Units;
-import sun.management.counter.Variability;
-
 /**
  * Interface provided by Instrumentation Monitoring Objects.
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/Units.java	Wed May 12 14:41:10 2010 -0700
@@ -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 <code>value</code>
+     *                 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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/Variability.java	Wed May 12 14:41:10 2010 -0700
@@ -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
+     *                       <code>value</code> 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;
+}
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -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;
 
 /**
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -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;
 
 /**
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -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;
 
 /**
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -26,7 +26,6 @@
 package sun.jvmstat.perfdata.monitor;
 
 import sun.jvmstat.monitor.*;
-import sun.management.counter.Variability;
 import java.nio.ByteBuffer;
 
 /**
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -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;
 
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java	Wed May 12 14:41:10 2010 -0700
@@ -26,7 +26,6 @@
 package sun.jvmstat.perfdata.monitor;
 
 import sun.jvmstat.monitor.*;
-import sun.management.counter.Variability;
 import java.nio.ByteBuffer;
 
 /**
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java	Wed May 12 14:41:10 2010 -0700
@@ -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.*;
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java	Wed May 12 14:41:10 2010 -0700
@@ -27,8 +27,6 @@
 
 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.*;
--- a/jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/tools/jstat/ExpressionResolver.java	Wed May 12 14:41:10 2010 -0700
@@ -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
--- a/jdk/src/share/classes/sun/tools/jstat/JStatLogger.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/tools/jstat/JStatLogger.java	Wed May 12 14:41:10 2010 -0700
@@ -29,8 +29,6 @@
 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;
 
 /**
--- a/jdk/src/share/classes/sun/tools/jstat/Jstat.java	Sun May 09 16:37:06 2010 -0700
+++ b/jdk/src/share/classes/sun/tools/jstat/Jstat.java	Wed May 12 14:41:10 2010 -0700
@@ -28,8 +28,6 @@
 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