--- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. 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
@@ -458,7 +458,7 @@
loader.initRemotePackageMap(cf, parents);
Layer layer = new Layer(cf, parents, mn -> loader);
return new Controller(layer);
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
throw new LayerInstantiationException(e.getMessage());
}
}
@@ -526,7 +526,7 @@
try {
Layer layer = new Layer(cf, parents, pool::loaderFor);
return new Controller(layer);
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException | IllegalStateException e) {
throw new LayerInstantiationException(e.getMessage());
}
}
@@ -610,9 +610,8 @@
try {
Layer layer = new Layer(cf, parents, clf);
return new Controller(layer);
- } catch (IllegalArgumentException iae) {
- // IAE is thrown by VM when defining the module fails
- throw new LayerInstantiationException(iae.getMessage());
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ throw new LayerInstantiationException(e.getMessage());
}
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Module.java Tue Jan 31 20:54:44 2017 +0100
@@ -128,14 +128,8 @@
Version version = descriptor.version().orElse(null);
String vs = Objects.toString(version, null);
String loc = Objects.toString(uri, null);
- Set<String> packages = descriptor.packages();
- int n = packages.size();
- String[] array = new String[n];
- int i = 0;
- for (String pn : packages) {
- array[i++] = pn.replace('.', '/');
- }
- defineModule0(this, isOpen, vs, loc, array);
+ String[] packages = descriptor.packages().toArray(new String[0]);
+ defineModule0(this, isOpen, vs, loc, packages);
}
@@ -789,13 +783,12 @@
// update VM first, just in case it fails
if (syncVM) {
- String pkgInternalForm = pn.replace('.', '/');
if (other == EVERYONE_MODULE) {
- addExportsToAll0(this, pkgInternalForm);
+ addExportsToAll0(this, pn);
} else if (other == ALL_UNNAMED_MODULE) {
- addExportsToAllUnnamed0(this, pkgInternalForm);
+ addExportsToAllUnnamed0(this, pn);
} else {
- addExports0(this, pkgInternalForm, other);
+ addExports0(this, pn, other);
}
}
@@ -1021,7 +1014,7 @@
// update VM first, just in case it fails
if (syncVM)
- addPackage0(this, pn.replace('.', '/'));
+ addPackage0(this, pn);
// replace with new set
this.extraPackages = extraPackages; // volatile write
@@ -1180,8 +1173,7 @@
if (descriptor.isOpen()) {
assert descriptor.opens().isEmpty();
for (String source : descriptor.packages()) {
- String sourceInternalForm = source.replace('.', '/');
- addExportsToAll0(m, sourceInternalForm);
+ addExportsToAll0(m, source);
}
return;
}
@@ -1192,7 +1184,6 @@
// process the open packages first
for (Opens opens : descriptor.opens()) {
String source = opens.source();
- String sourceInternalForm = source.replace('.', '/');
if (opens.isQualified()) {
// qualified opens
@@ -1201,7 +1192,7 @@
// only open to modules that are in this configuration
Module m2 = nameToModule.get(target);
if (m2 != null) {
- addExports0(m, sourceInternalForm, m2);
+ addExports0(m, source, m2);
targets.add(m2);
}
}
@@ -1210,7 +1201,7 @@
}
} else {
// unqualified opens
- addExportsToAll0(m, sourceInternalForm);
+ addExportsToAll0(m, source);
openPackages.put(source, EVERYONE_SET);
}
}
@@ -1218,7 +1209,6 @@
// next the exports, skipping exports when the package is open
for (Exports exports : descriptor.exports()) {
String source = exports.source();
- String sourceInternalForm = source.replace('.', '/');
// skip export if package is already open to everyone
Set<Module> openToTargets = openPackages.get(source);
@@ -1234,7 +1224,7 @@
if (m2 != null) {
// skip qualified export if already open to m2
if (openToTargets == null || !openToTargets.contains(m2)) {
- addExports0(m, sourceInternalForm, m2);
+ addExports0(m, source, m2);
targets.add(m2);
}
}
@@ -1245,7 +1235,7 @@
} else {
// unqualified exports
- addExportsToAll0(m, sourceInternalForm);
+ addExportsToAll0(m, source);
exportedPackages.put(source, EVERYONE_SET);
}
}
--- a/jdk/src/java.base/share/classes/module-info.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.base/share/classes/module-info.java Tue Jan 31 20:54:44 2017 +0100
@@ -177,7 +177,7 @@
exports jdk.internal.perf to
java.desktop,
java.management,
- jdk.jvmstat;
+ jdk.internal.jvmstat;
exports jdk.internal.ref to
java.desktop,
jdk.unsupported;
@@ -197,7 +197,7 @@
jdk.jlink;
exports jdk.internal.vm to
java.management,
- jdk.jvmstat;
+ jdk.internal.jvmstat;
exports sun.net to
jdk.incubator.httpclient;
exports sun.net.ext to
--- a/jdk/src/java.base/share/native/include/jvm.h Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.base/share/native/include/jvm.h Tue Jan 31 20:54:44 2017 +0100
@@ -401,30 +401,67 @@
* Module support funcions
*/
+/*
+ * Define a module with the specified packages and bind the module to the
+ * given class loader.
+ * module: module to define
+ * is_open: specifies if module is open (currently ignored)
+ * version: the module version
+ * location: the module location
+ * packages: list of packages in the module
+ * num_packages: number of packages in the module
+ */
JNIEXPORT void JNICALL
JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
- jstring location, jobjectArray packages);
+ jstring location, const char* const* packages, jsize num_packages);
+/*
+ * Set the boot loader's unnamed module.
+ * module: boot loader's unnamed module
+ */
JNIEXPORT void JNICALL
JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
-JNIEXPORT void JNICALL
-JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject to_module);
-
+/*
+ * Do a qualified export of a package.
+ * from_module: module containing the package to export
+ * package: name of the package to export
+ * to_module: module to export the package to
+ */
JNIEXPORT void JNICALL
-JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
+JVM_AddModuleExports(JNIEnv *env, jobject from_module, const char* package, jobject to_module);
+/*
+ * Do an export of a package to all unnamed modules.
+ * from_module: module containing the package to export
+ * package: name of the package to export to all unnamed modules
+ */
JNIEXPORT void JNICALL
-JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, jstring package);
+JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, const char* package);
-JNIEXPORT void JNICALL
-JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, jstring package);
-
+/*
+ * Do an unqualified export of a package.
+ * from_module: module containing the package to export
+ * package: name of the package to export
+ */
JNIEXPORT void JNICALL
-JVM_AddModulePackage(JNIEnv* env, jobject module, jstring package);
+JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package);
-JNIEXPORT jobject JNICALL
-JVM_GetModuleByPackageName(JNIEnv *env, jobject cl, jstring pkg);
+/*
+ * Add a module to the list of modules that a given module can read.
+ * from_module: module requesting read access
+ * source_module: module that from_module wants to read
+ */
+JNIEXPORT void JNICALL
+JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
+
+/*
+ * Add a package to a module.
+ * module: module that will contain the package
+ * package: package to add to the module
+ */
+JNIEXPORT void JNICALL
+JVM_AddModulePackage(JNIEnv* env, jobject module, const char* package);
/*
* Reflection support functions
--- a/jdk/src/java.base/share/native/libjava/Module.c Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.base/share/native/libjava/Module.c Tue Jan 31 20:54:44 2017 +0100
@@ -22,18 +22,88 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+#include <stdlib.h>
+#include <string.h>
#include "jni.h"
+#include "jni_util.h"
#include "jvm.h"
#include "java_lang_reflect_Module.h"
+/*
+ * Gets the UTF-8 chars for the string and translates '.' to '/'. Does no
+ * further validation, assumption being that both calling code in
+ * java.lang.reflect.Module and VM will do deeper validation.
+ */
+static char*
+GetInternalPackageName(JNIEnv *env, jstring pkg, char* buf, jsize buf_size)
+{
+ jsize len;
+ jsize unicode_len;
+ char* p;
+ char* utf_str;
+
+ len = (*env)->GetStringUTFLength(env, pkg);
+ unicode_len = (*env)->GetStringLength(env, pkg);
+ if (len >= buf_size) {
+ utf_str = malloc(len + 1);
+ if (utf_str == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return NULL;
+ }
+ } else {
+ utf_str = buf;
+ }
+ (*env)->GetStringUTFRegion(env, pkg, 0, unicode_len, utf_str);
+
+ p = utf_str;
+ while (*p != '\0') {
+ if (*p == '.') {
+ *p = '/';
+ }
+ p++;
+ }
+ return utf_str;
+}
+
JNIEXPORT void JNICALL
Java_java_lang_reflect_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
jboolean is_open, jstring version,
jstring location, jobjectArray packages)
{
- JVM_DefineModule(env, module, is_open, version, location, packages);
+ char** pkgs = NULL;
+ jsize idx;
+ jsize num_packages = (*env)->GetArrayLength(env, packages);
+
+ if (num_packages != 0 && (pkgs = calloc(num_packages, sizeof(char*))) == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return;
+ } else {
+ int valid = 1;
+ for (idx = 0; idx < num_packages; idx++) {
+ jstring pkg = (*env)->GetObjectArrayElement(env, packages, idx);
+ pkgs[idx] = GetInternalPackageName(env, pkg, NULL, 0);
+ if (pkgs[idx] == NULL) {
+ valid = 0;
+ break;
+ }
+ }
+
+ if (valid != 0) {
+ JVM_DefineModule(env, module, is_open, version, location,
+ (const char* const*)pkgs, num_packages);
+ }
+ }
+
+ if (num_packages > 0) {
+ for (idx = 0; idx < num_packages; idx++) {
+ if (pkgs[idx] != NULL) {
+ free(pkgs[idx]);
+ }
+ }
+ free(pkgs);
+ }
}
JNIEXPORT void JNICALL
@@ -46,25 +116,81 @@
Java_java_lang_reflect_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
jstring pkg, jobject to)
{
- JVM_AddModuleExports(env, from, pkg, to);
+ char buf[128];
+ char* pkg_name;
+
+ if (pkg == NULL) {
+ JNU_ThrowNullPointerException(env, "package is null");
+ return;
+ }
+
+ pkg_name = GetInternalPackageName(env, pkg, buf, (jsize)sizeof(buf));
+ if (pkg_name != NULL) {
+ JVM_AddModuleExports(env, from, pkg_name, to);
+ if (pkg_name != buf) {
+ free(pkg_name);
+ }
+ }
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
jstring pkg)
{
- JVM_AddModuleExportsToAll(env, from, pkg);
+ char buf[128];
+ char* pkg_name;
+
+ if (pkg == NULL) {
+ JNU_ThrowNullPointerException(env, "package is null");
+ return;
+ }
+
+ pkg_name = GetInternalPackageName(env, pkg, buf, (jsize)sizeof(buf));
+ if (pkg_name != NULL) {
+ JVM_AddModuleExportsToAll(env, from, pkg_name);
+ if (pkg_name != buf) {
+ free(pkg_name);
+ }
+ }
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
jobject from, jstring pkg)
{
- JVM_AddModuleExportsToAllUnnamed(env, from, pkg);
+ char buf[128];
+ char* pkg_name;
+
+ if (pkg == NULL) {
+ JNU_ThrowNullPointerException(env, "package is null");
+ return;
+ }
+
+ pkg_name = GetInternalPackageName(env, pkg, buf, (jsize)sizeof(buf));
+ if (pkg_name != NULL) {
+ JVM_AddModuleExportsToAllUnnamed(env, from, pkg_name);
+ if (pkg_name != buf) {
+ free(pkg_name);
+ }
+ }
}
JNIEXPORT void JNICALL
Java_java_lang_reflect_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
{
- JVM_AddModulePackage(env, m, pkg);
+ char buf[128];
+ char* pkg_name;
+
+ if (pkg == NULL) {
+ JNU_ThrowNullPointerException(env, "package is null");
+ return;
+ }
+
+ pkg_name = GetInternalPackageName(env, pkg, buf, (jsize)sizeof(buf));
+ if (pkg_name != NULL) {
+ JVM_AddModulePackage(env, m, pkg_name);
+ if (pkg_name != buf) {
+ free(pkg_name);
+ }
+ }
}
--- a/jdk/src/java.management/share/classes/sun/management/Agent.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.management/share/classes/sun/management/Agent.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. 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
@@ -502,19 +502,9 @@
}
}
- // Rebuilding service URL to broadcast it
- String jmxremotePort = props.getProperty(JMXREMOTE_PORT);
- String rmiPort = props.getProperty(RMI_PORT);
-
- JMXServiceURL url = jmxServer.getAddress();
- String hostname = url.getHost();
-
- String jmxUrlStr = (rmiPort != null)
- ? String.format(
- "service:jmx:rmi://%s:%s/jndi/rmi://%s:%s/jmxrmi",
- hostname, rmiPort, hostname, jmxremotePort)
- : String.format(
- "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi", hostname, jmxremotePort);
+ // Get service URL to broadcast it
+ Map<String,String> remoteProps = ConnectorAddressLink.importRemoteFrom(0);
+ String jmxUrlStr = remoteProps.get("sun.management.JMXConnectorServer.0.remoteAddress");
String instanceName = props.getProperty("com.sun.management.jdp.name");
--- a/jdk/src/java.naming/share/classes/javax/naming/CompoundName.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/java.naming/share/classes/javax/naming/CompoundName.java Tue Jan 31 20:54:44 2017 +0100
@@ -149,11 +149,10 @@
public class CompoundName implements Name {
/**
- * Implementation of this compound name.
- * This field is initialized by the constructors and cannot be null.
- * It should be treated as a read-only variable by subclasses.
- */
- protected transient NameImpl impl;
+ * Implementation of this compound name. This field is initialized by the
+ * constructors and cannot be null.
+ */
+ private transient NameImpl impl;
/**
* Syntax properties for this compound name.
* This field is initialized by the constructors and cannot be null.
--- a/jdk/src/jdk.attach/share/classes/module-info.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/jdk.attach/share/classes/module-info.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. 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
@@ -27,7 +27,7 @@
* Defines the attach API.
*/
module jdk.attach {
- requires jdk.jvmstat;
+ requires jdk.internal.jvmstat;
exports com.sun.tools.attach;
exports com.sun.tools.attach.spi;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/module-info.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module jdk.internal.jvmstat {
+ exports sun.jvmstat.monitor to
+ jdk.attach,
+ jdk.jcmd,
+ jdk.jconsole,
+ jdk.jstatd;
+ exports sun.jvmstat.monitor.event to
+ jdk.jcmd,
+ jdk.jstatd;
+ exports sun.jvmstat.perfdata.monitor to
+ jdk.jstatd;
+
+ uses sun.jvmstat.monitor.MonitoredHostService;
+ provides sun.jvmstat.monitor.MonitoredHostService with
+ sun.jvmstat.perfdata.monitor.protocol.file.MonitoredHostFileService,
+ sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostLocalService;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/AbstractMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * The base class for Instrumentation Monitoring Objects. This base class
+ * provides implementations of the {@link Monitor} methods that are common
+ * to all classes implementing the Monitor interface..
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public abstract class AbstractMonitor implements Monitor {
+ protected String name;
+ protected Units units;
+ protected Variability variability;
+ protected int vectorLength;
+ protected boolean supported;
+
+ /**
+ * Create a vector instrumentation monitoring object with the given
+ * name and attributes.
+ *
+ * @param name the name to assign to this instrumentation object.
+ * @param units the units of measure attribute
+ * @param variability the variability attribute
+ * @param supported support level indicator
+ * @param vectorLength the length of the vector, or 0 if not a vector type.
+ */
+ protected AbstractMonitor(String name, Units units, Variability variability,
+ boolean supported, int vectorLength) {
+ this.name = name;
+ this.units = units;
+ this.variability = variability;
+ this.vectorLength = vectorLength;
+ this.supported = supported;
+ }
+
+ /**
+ * Create a scalar instrumentation monitoring object with the given
+ * name and attributes.
+ *
+ * @param name the name to assign to this instrumentation object.
+ * @param units the units of measure attribute
+ * @param variability the variability attribute
+ * @param supported support level indicator
+ */
+ protected AbstractMonitor(String name, Units units, Variability variability,
+ boolean supported) {
+ this(name, units, variability, supported, 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBaseName() {
+ int baseIndex = name.lastIndexOf('.') + 1;
+ return name.substring(baseIndex);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Units getUnits() {
+ return units;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Variability getVariability() {
+ return variability;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isVector() {
+ return vectorLength > 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getVectorLength() {
+ return vectorLength;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSupported() {
+ return supported;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract Object getValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/BufferedMonitoredVm.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+import sun.jvmstat.monitor.*;
+
+/**
+ * Interface to support asynchronous polling of the exported
+ * instrumentation of a target Java Virtual Machine.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public interface BufferedMonitoredVm extends MonitoredVm {
+
+ /**
+ * Interface to get the bytes associated with the instrumentation
+ * for the target Java Virtual Machine.
+ *
+ * @return byte[] - a byte array containing the current bytes
+ * for the instrumentation exported by the
+ * target Java Virtual Machine.
+ */
+ byte[] getBytes();
+
+ /**
+ * Interface to get the size of the instrumentation buffer
+ * for the target Java Virtual Machine.
+ *
+ * @return int - the size of the instrumentation buffer for the
+ * target Java Virtual Machine.
+ */
+ int getCapacity();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/ByteArrayMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Interface for Monitoring ByteArrayInstrument objects.
+ *
+ * This interface is provided to support the StringMonitor interface. No
+ * instrumentation objects of this direct type can currently be created
+ * or monitored.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see sun.jvmstat.instrument.ByteArrayInstrument
+ */
+public interface ByteArrayMonitor extends Monitor {
+
+ /**
+ * Get a copy of the current values of the elements of the
+ * ByteArrayInstrument object.
+ *
+ * @return byte[] - a copy of the bytes in the associated
+ * instrumenattion object.
+ */
+ public byte[] byteArrayValue();
+
+ /**
+ * Get the current value of an element of the ByteArrayInstrument object.
+ *
+ * @return byte - the byte value at the specified index in the
+ * associated instrumentation object.
+ */
+ public byte byteAt(int index);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/HostIdentifier.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,568 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+import java.net.*;
+
+/**
+ * An abstraction that identifies a target host and communications
+ * protocol. The HostIdentifier, or hostid, provides a convenient string
+ * representation of the information needed to locate and communicate with
+ * a target host. The string, based on a {@link URI}, may specify the
+ * the communications protocol, host name, and protocol specific information
+ * for a target host. The format for a HostIdentifier string is:
+ * <pre>
+ * [<I>protocol</I>:][[<I>//</I>]<I>hostname</I>][<I>:port</I>][<I>/servername</I>]
+ * </pre>
+ * There are actually no required components of this string, as a null string
+ * is interpreted to mean a local connection to the local host and is equivalent
+ * to the string <em>local://localhost</em>. The components of the
+ * HostIdentifier are:
+ * <ul>
+ * <li><p>{@code protocol} - The communications protocol. If omitted,
+ * and a hostname is not specified, then default local protocol,
+ * <em>local:</em>, is assumed. If the protocol is omitted and a
+ * hostname is specified then the default remote protocol,
+ * <em>rmi:</em> is assumed.
+ * </p></li>
+ * <li><p>{@code hostname} - The hostname. If omitted, then
+ * <em>localhost</em> is assumed. If the protocol is also omitted,
+ * then default local protocol <em>local:</em> is also assumed.
+ * If the hostname is not omitted but the protocol is omitted,
+ * then the default remote protocol, <em>rmi:</em> is assumed.
+ * </p></li>
+ * <li><p>{@code port} - The port for the communications protocol.
+ * Treatment of the {@code port} parameter is implementation
+ * (protocol) specific. It is unused by the default local protocol,
+ * <em>local:</em>. For the default remote protocol, <em>rmi:</em>,
+ * {@code port} indicates the port number of the <em>rmiregistry</em>
+ * on the target host and defaults to port 1099.
+ * </p></li>
+ * <li><p>{@code servername} - The treatment of the Path, Query, and
+ * Fragment components of the HostIdentifier are implementation
+ * (protocol) dependent. These components are ignored by the
+ * default local protocol, <em>local:</em>. For the default remote
+ * protocol, <em>rmi</em>, the Path component is interpreted as
+ * the name of the RMI remote object. The Query component may
+ * contain an access mode specifier <em>?mode=</em> specifying
+ * <em>"r"</em> or <em>"rw"</em> access (write access currently
+ * ignored). The Fragment part is ignored.
+ * </p></li>
+ * </ul>
+ * <p>
+ * All HostIdentifier objects are represented as absolute, hierarchical URIs.
+ * The constructors accept relative URIs, but these will generally be
+ * transformed into an absolute URI specifying a default protocol. A
+ * HostIdentifier differs from a URI in that certain contractions and
+ * illicit syntactical constructions are allowed. The following are all
+ * valid HostIdentifier strings:
+ *
+ * <ul>
+ * <li>{@code <null>} - transformed into "//localhost"</li>
+ * <li>localhost - transformed into "//localhost"</li>
+ * <li>hostname - transformed into "//hostname"</li>
+ * <li>hostname:port - transformed into "//hostname:port"</li>
+ * <li>proto:hostname - transformed into "proto://hostname"</li>
+ * <li>proto:hostname:port - transformed into
+ * "proto://hostname:port"</li>
+ * <li>proto://hostname:port</li>
+ * </ul>
+ *
+ * @see URI
+ * @see VmIdentifier
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class HostIdentifier {
+ private URI uri;
+
+ /**
+ * creates a canonical representation of the uriString. This method
+ * performs certain translations depending on the type of URI generated
+ * by the string.
+ */
+ private URI canonicalize(String uriString) throws URISyntaxException {
+ if ((uriString == null) || (uriString.compareTo("localhost") == 0)) {
+ uriString = "//localhost";
+ return new URI(uriString);
+ }
+
+ URI u = new URI(uriString);
+
+ if (u.isAbsolute()) {
+ if (u.isOpaque()) {
+ /*
+ * this code is here to deal with a special case. For ease of
+ * use, we'd like to be able to handle the case where the user
+ * specifies hostname:port, not requiring the scheme part.
+ * This introduces some subtleties.
+ * hostname:port - scheme = hostname
+ * - schemespecificpart = port
+ * - hostname = null
+ * - userinfo=null
+ * however, someone could also enter scheme:hostname:port and
+ * get into this code. the strategy is to consider this
+ * syntax illegal and provide some code to defend against it.
+ * Basically, we test that the string contains only one ":"
+ * and that the ssp is numeric. If we get two colons, we will
+ * attempt to insert the "//" after the first colon and then
+ * try to create a URI from the resulting string.
+ */
+ String scheme = u.getScheme();
+ String ssp = u.getSchemeSpecificPart();
+ String frag = u.getFragment();
+ URI u2 = null;
+
+ int c1index = uriString.indexOf(':');
+ int c2index = uriString.lastIndexOf(':');
+ if (c2index != c1index) {
+ /*
+ * this is the scheme:hostname:port case. Attempt to
+ * transform this to scheme://hostname:port. If a path
+ * part is part of the original strings, it will be
+ * included in the SchemeSpecificPart. however, the
+ * fragment part must be handled separately.
+ */
+ if (frag == null) {
+ u2 = new URI(scheme + "://" + ssp);
+ } else {
+ u2 = new URI(scheme + "://" + ssp + "#" + frag);
+ }
+ return u2;
+ }
+ /*
+ * here we have the <string>:<string> case, possibly with
+ * optional path and fragment components. we assume that
+ * the part following the colon is a number. we don't check
+ * this condition here as it will get detected later anyway.
+ */
+ u2 = new URI("//" + uriString);
+ return u2;
+ } else {
+ return u;
+ }
+ } else {
+ /*
+ * This is the case where we were given a hostname followed
+ * by a path part, fragment part, or both a path and fragment
+ * part. The key here is that no scheme part was specified.
+ * For this case, if the scheme specific part does not begin
+ * with "//", then we prefix the "//" to the given string and
+ * attempt to create a URI from the resulting string.
+ */
+ String ssp = u.getSchemeSpecificPart();
+ if (ssp.startsWith("//")) {
+ return u;
+ } else {
+ return new URI("//" + uriString);
+ }
+ }
+ }
+
+ /**
+ * Create a HostIdentifier instance from a string value.
+ *
+ * @param uriString a string representing a target host. The syntax of
+ * the string must conform to the rules specified in the
+ * class documentation.
+ *
+ * @throws URISyntaxException Thrown when the uriString or its canonical
+ * form is poorly formed. This exception may
+ * get encapsulated into a MonitorException in
+ * a future version.
+ *
+ */
+ public HostIdentifier(String uriString) throws URISyntaxException {
+ uri = canonicalize(uriString);
+ }
+
+ /**
+ * Create a HostIdentifier instance from component parts of a URI.
+ *
+ * @param scheme the {@link URI#getScheme} component of a URI.
+ * @param authority the {@link URI#getAuthority} component of a URI.
+ * @param path the {@link URI#getPath} component of a URI.
+ * @param query the {@link URI#getQuery} component of a URI.
+ * @param fragment the {@link URI#getFragment} component of a URI.
+ *
+ * @throws URISyntaxException Thrown when the uriString or its canonical
+ * form is poorly formed. This exception may
+ * get encapsulated into a MonitorException in
+ * a future version.
+ * @see URI
+ */
+ public HostIdentifier(String scheme, String authority, String path,
+ String query, String fragment)
+ throws URISyntaxException {
+ uri = new URI(scheme, authority, path, query, fragment);
+ }
+
+ /**
+ * Create a HostIdentifier instance from a VmIdentifier.
+ *
+ * The necessary components of the VmIdentifier are extracted and
+ * reassembled into a HostIdentifier. If a "file:" scheme (protocol)
+ * is specified, the returned HostIdentifier will always be
+ * equivalent to HostIdentifier("file://localhost").
+ *
+ * @param vmid the VmIdentifier use to construct the HostIdentifier.
+ */
+ public HostIdentifier(VmIdentifier vmid) {
+ /*
+ * Extract all components of the VmIdentifier URI except the
+ * user-info part of the authority (the lvmid).
+ */
+ StringBuilder sb = new StringBuilder();
+ String scheme = vmid.getScheme();
+ String host = vmid.getHost();
+ String authority = vmid.getAuthority();
+
+ // check for 'file:' VmIdentifiers and handled as a special case.
+ if ((scheme != null) && (scheme.compareTo("file") == 0)) {
+ try {
+ uri = new URI("file://localhost");
+ } catch (URISyntaxException e) { };
+ return;
+ }
+
+ if ((host != null) && (host.compareTo(authority) == 0)) {
+ /*
+ * this condition occurs when the VmIdentifier specifies only
+ * the authority (i.e. the lvmid ), and not a host name.
+ */
+ host = null;
+ }
+
+ if (scheme == null) {
+ if (host == null) {
+ scheme = "local"; // default local scheme
+ } else {
+ /*
+ * rmi is the default remote scheme. if the VmIdentifier
+ * specifies some other protocol, this default is overridden.
+ */
+ scheme = "rmi";
+ }
+ }
+
+ sb.append(scheme).append("://");
+
+ if (host == null) {
+ sb.append("localhost"); // default host name
+ } else {
+ sb.append(host);
+ }
+
+ int port = vmid.getPort();
+ if (port != -1) {
+ sb.append(":").append(port);
+ }
+
+ String path = vmid.getPath();
+ if ((path != null) && (path.length() != 0)) {
+ sb.append(path);
+ }
+
+ String query = vmid.getQuery();
+ if (query != null) {
+ sb.append("?").append(query);
+ }
+
+ String frag = vmid.getFragment();
+ if (frag != null) {
+ sb.append("#").append(frag);
+ }
+
+ try {
+ uri = new URI(sb.toString());
+ } catch (URISyntaxException e) {
+ // shouldn't happen, as we were passed a valid VmIdentifier
+ throw new RuntimeException("Internal Error", e);
+ }
+ }
+
+ /**
+ * Resolve a VmIdentifier with this HostIdentifier. A VmIdentifier, such
+ * as <em>1234</em> or <em>1234@hostname</em> or any other string that
+ * omits certain components of the URI string may be valid, but is certainly
+ * incomplete. They are missing critical information for identifying the
+ * the communications protocol, target host, or other parameters. A
+ * VmIdentifier of this form is considered <em>unresolved</em>. This method
+ * uses components of the HostIdentifier to resolve the missing components
+ * of the VmIdentifier.
+ * <p>
+ * Specified components of the unresolved VmIdentifier take precedence
+ * over their HostIdentifier counterparts. For example, if the VmIdentifier
+ * indicates <em>1234@hostname:2099</em> and the HostIdentifier indicates
+ * <em>rmi://hostname:1099/</em>, then the resolved VmIdentifier will
+ * be <em>rmi://1234@hostname:2099</em>. Any component not explicitly
+ * specified or assumed by the HostIdentifier, will remain unresolved in
+ * resolved VmIdentifier.
+ * <p>
+ * A VmIdentifier specifying a <em>file:</em> scheme (protocol), is
+ * not changed in any way by this method.
+ *
+ * @param vmid the unresolved VmIdentifier.
+ * @return VmIdentifier - the resolved VmIdentifier. If vmid was resolved
+ * on entry to this method, then the returned
+ * VmIdentifier will be equal, but not identical, to
+ * vmid.
+ */
+ public VmIdentifier resolve(VmIdentifier vmid)
+ throws URISyntaxException, MonitorException {
+ String scheme = vmid.getScheme();
+ String host = vmid.getHost();
+ String authority = vmid.getAuthority();
+
+ if ((scheme != null) && (scheme.compareTo("file") == 0)) {
+ // don't attempt to resolve a file based VmIdentifier.
+ return vmid;
+ }
+
+ if ((host != null) && (host.compareTo(authority) == 0)) {
+ /*
+ * this condition occurs when the VmIdentifier specifies only
+ * the authority (i.e. an lvmid), and not a host name.
+ */
+ host = null;
+ }
+
+ if (scheme == null) {
+ scheme = getScheme();
+ }
+
+ URI nuri = null;
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(scheme).append("://");
+
+ String userInfo = vmid.getUserInfo();
+ if (userInfo != null) {
+ sb.append(userInfo);
+ } else {
+ sb.append(vmid.getAuthority());
+ }
+
+ if (host == null) {
+ host = getHost();
+ }
+ sb.append("@").append(host);
+
+ int port = vmid.getPort();
+ if (port == -1) {
+ port = getPort();
+ }
+
+ if (port != -1) {
+ sb.append(":").append(port);
+ }
+
+ String path = vmid.getPath();
+ if ((path == null) || (path.length() == 0)) {
+ path = getPath();
+ }
+
+ if ((path != null) && (path.length() > 0)) {
+ sb.append(path);
+ }
+
+ String query = vmid.getQuery();
+ if (query == null) {
+ query = getQuery();
+ }
+ if (query != null) {
+ sb.append("?").append(query);
+ }
+
+ String fragment = vmid.getFragment();
+ if (fragment == null) {
+ fragment = getFragment();
+ }
+ if (fragment != null) {
+ sb.append("#").append(fragment);
+ }
+
+ String s = sb.toString();
+ return new VmIdentifier(s);
+ }
+
+ /**
+ * Return the Scheme, or protocol, portion of this HostIdentifier.
+ *
+ * @return String - the scheme for this HostIdentifier.
+ * @see URI#getScheme()
+ */
+ public String getScheme() {
+ return uri.isAbsolute() ? uri.getScheme() : null;
+ }
+
+ /**
+ * Return the Scheme Specific Part of this HostIdentifier.
+ *
+ * @return String - the scheme specific part for this HostIdentifier.
+ * @see URI#getSchemeSpecificPart()
+ */
+ public String getSchemeSpecificPart() {
+ return uri.getSchemeSpecificPart();
+ }
+
+ /**
+ * Return the User Info part of this HostIdentifier.
+ *
+ * @return String - the user info part for this HostIdentifier.
+ * @see URI#getUserInfo()
+ */
+ public String getUserInfo() {
+ return uri.getUserInfo();
+ }
+
+ /**
+ * Return the Host part of this HostIdentifier.
+ *
+ * @return String - the host part for this HostIdentifier, or
+ * "localhost" if the URI.getHost() returns null.
+ * @see URI#getUserInfo()
+ */
+ public String getHost() {
+ return (uri.getHost() == null) ? "localhost" : uri.getHost();
+ }
+
+ /**
+ * Return the Port for of this HostIdentifier.
+ *
+ * @return String - the port for this HostIdentifier
+ * @see URI#getPort()
+ */
+ public int getPort() {
+ return uri.getPort();
+ }
+
+ /**
+ * Return the Path part of this HostIdentifier.
+ *
+ * @return String - the path part for this HostIdentifier.
+ * @see URI#getPath()
+ */
+ public String getPath() {
+ return uri.getPath();
+ }
+
+ /**
+ * Return the Query part of this HostIdentifier.
+ *
+ * @return String - the query part for this HostIdentifier.
+ * @see URI#getQuery()
+ */
+ public String getQuery() {
+ return uri.getQuery();
+ }
+
+ /**
+ * Return the Fragment part of this HostIdentifier.
+ *
+ * @return String - the fragment part for this HostIdentifier.
+ * @see URI#getFragment()
+ */
+ public String getFragment() {
+ return uri.getFragment();
+ }
+
+ /**
+ * Return the mode indicated in this HostIdentifier.
+ *
+ * @return String - the mode string. If no mode is specified, then "r"
+ * is returned. otherwise, the specified mode is returned.
+ */
+ public String getMode() {
+ String query = getQuery();
+ if (query != null) {
+ String[] queryArgs = query.split("\\+");
+ for (int i = 0; i < queryArgs.length; i++) {
+ if (queryArgs[i].startsWith("mode=")) {
+ int index = queryArgs[i].indexOf('=');
+ return queryArgs[i].substring(index+1);
+ }
+ }
+ }
+ return "r";
+ }
+
+ /**
+ * Return the URI associated with the HostIdentifier.
+ *
+ * @return URI - the URI.
+ * @see URI
+ */
+ public URI getURI() {
+ return uri;
+ }
+
+ /**
+ * Return the hash code for this HostIdentifier. The hash code is
+ * identical to the hash code for the contained URI.
+ *
+ * @return int - the hashcode.
+ * @see URI#hashCode()
+ */
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ /**
+ * Test for quality with other objects.
+ *
+ * @param object the object to be test for equality.
+ * @return boolean - returns true if the given object is of type
+ * HostIdentifier and its URI field is equal to this
+ * object's URI field. Otherwise, returns false.
+ *
+ * @see URI#equals(Object)
+ */
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ if (!(object instanceof HostIdentifier)) {
+ return false;
+ }
+ return uri.equals(((HostIdentifier)object).uri);
+ }
+
+
+ /**
+ * Convert to a string representation. Conversion is identical to
+ * calling getURI().toString(). This may change in a future release.
+ *
+ * @return String - a String representation of the HostIdentifier.
+ *
+ * @see URI#toString()
+ */
+ public String toString() {
+ return uri.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/IntegerMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Interface for Monitoring Integer Instrument Objects.
+ *
+ * The IntegerMonitor interface does not currently have a IntInstrument
+ * counterpart. It is used in limited situations to expose certain
+ * implementation specifics as performance counters. Typically,
+ * a LongInstrument serves as a reasonable replacement for the
+ * an IntInstrument class.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public interface IntegerMonitor extends Monitor {
+
+ /**
+ * Get the value of this Integer Instrumentation Object
+ *
+ * return int - the current value of this instrumentation object
+ */
+ public int intValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/LongMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Interface for Monitoring LongInstrument objects.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see sun.jvmstat.instrument.LongInstrument
+ */
+public interface LongMonitor extends Monitor {
+
+ /**
+ * Get the current value of this LongInstrument object.
+ *
+ * @return long - the current value of the associated LongInstrument object.
+ */
+ public long longValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/Monitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Interface provided by Instrumentation Monitoring Objects.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public interface Monitor {
+
+ /**
+ * Returns the name of this instrumentation object.
+ *
+ * @return String - the name assigned to this instrumentation monitoring
+ * object
+ */
+ String getName();
+
+ /**
+ * Returns the base name of this instrumentation object.
+ * The base name is the component of the name following the last
+ * "." character in the name.
+ *
+ * @return String - the base name of the name assigned to this
+ * instrumentation monitoring object.
+ */
+ String getBaseName();
+
+ /**
+ * Returns the Units for this instrumentation monitoring object.
+ *
+ * @return Units - the units of measure attribute
+ */
+ Units getUnits();
+
+ /**
+ * Returns the Variability for this instrumentation object.
+ *
+ *@return Variability - the variability attribute
+ */
+ Variability getVariability();
+
+ /**
+ * Test if the instrumentation object is a vector type.
+ *
+ * @return boolean - true if this instrumentation object is a vector type,
+ * false otherwise.
+ */
+ boolean isVector();
+
+ /**
+ * Return the length of the vector.
+ * @return int - the length of the vector or zero if this instrumentation
+ * object is a scalar type.
+ */
+ int getVectorLength();
+
+ /**
+ * Test if the instrumentation object is supported.
+ */
+ boolean isSupported();
+
+ /**
+ * Return an Object that encapsulates this instrumentation object's
+ * current data value.
+ */
+ Object getValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/MonitorException.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Base class for exceptions that occur while interfacing with the
+ * Monitoring interfaces.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class MonitorException extends Exception {
+
+ /**
+ * Create a MonitorException
+ */
+ public MonitorException() {
+ super();
+ }
+
+ /**
+ * Create a MonitorException with the given message.
+ *
+ * @param message the message to associate with the exception.
+ */
+ public MonitorException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create a MonitorException with the given message and cause.
+ *
+ * @param message the message to associate with the exception.
+ * @param cause the exception causing this exception.
+ */
+ public MonitorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create an InstrumentationException with the given cause.
+ *
+ * @param cause the exception causing this exception.
+ */
+ public MonitorException(Throwable cause) {
+ super(cause);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredHost.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.Set;
+
+import sun.jvmstat.monitor.event.HostListener;
+
+/**
+ * An abstraction for a host that contains instrumented Java Virtual
+ * Machines. The class provides abstract factory methods for creating
+ * concrete instances of this class and factory methods for creating
+ * {@link MonitoredVm} instances. Concrete implementations of this class
+ * provide methods for managing the communications protocols and provide
+ * for event notification.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ *
+ * @see HostIdentifier
+ * @see VmIdentifier
+ * @see MonitoredVm
+ * @see HostListener
+ */
+public abstract class MonitoredHost {
+ private static Map<HostIdentifier, MonitoredHost> monitoredHosts =
+ new HashMap<HostIdentifier, MonitoredHost>();
+
+ /*
+ * The default optimized local protocol override mechanism. The value
+ * of this property is used to construct the default package name
+ * for the default optimized local protocol as follows:
+ * <IMPL_PACKAGE>.monitor.<LOCAL_PROTOCOL>
+ * This property is not expected to be set under normal circumstances.
+ */
+ private static final String LOCAL_PROTOCOL_PROP_NAME =
+ "sun.jvmstat.monitor.local";
+ private static final String LOCAL_PROTOCOL =
+ System.getProperty(LOCAL_PROTOCOL_PROP_NAME, "local");
+
+ /*
+ * The default remote protocol override mechanism. The value of
+ * this property is used to construct the default package name
+ * for the default remote protocol protocol as follows:
+ * <IMPL_PACKAGE>.monitor.protocol.<REMOTE_PROTOCOL>
+ * This property is not expected to be set under normal circumstances.
+ */
+ private static final String REMOTE_PROTOCOL_PROP_NAME =
+ "sun.jvmstat.monitor.remote";
+ private static final String REMOTE_PROTOCOL =
+ System.getProperty(REMOTE_PROTOCOL_PROP_NAME, "rmi");
+
+ /**
+ * The HostIdentifier for this MonitoredHost instance.
+ */
+ protected HostIdentifier hostId;
+
+ /**
+ * The polling interval, in milliseconds, for this MonitoredHost instance.
+ */
+ protected int interval;
+
+ /**
+ * The last Exception encountered while polling this MonitoredHost.
+ */
+ protected Exception lastException;
+
+ /**
+ * Factory method to construct MonitoredHost instances to manage
+ * connections to the host indicated by {@code hostIdString}
+ *
+ * @param hostIdString a String representation of a {@link HostIdentifier}
+ * @return MonitoredHost - the MonitoredHost instance for communicating
+ * with the indicated host using the protocol
+ * specified in hostIdString.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ * @throws URISyntaxException Thrown when the hostIdString is poorly
+ * formed. This exception may get encapsulated
+ * into MonitorException in a future revision.
+ */
+ public static MonitoredHost getMonitoredHost(String hostIdString)
+ throws MonitorException, URISyntaxException {
+ HostIdentifier hostId = new HostIdentifier(hostIdString);
+ return getMonitoredHost(hostId);
+ }
+
+ /**
+ * Factory method to construct a MonitoredHost instance to manage the
+ * connection to the Java Virtual Machine indicated by {@code vmid}.
+ *
+ * This method provide a convenient short cut for attaching to a specific
+ * instrumented Java Virtual Machine. The information in the VmIdentifier
+ * is used to construct a corresponding HostIdentifier, which in turn is
+ * used to create the MonitoredHost instance.
+ *
+ * @param vmid The identifier for the target Java Virtual Machine.
+ * @return MonitoredHost - The MonitoredHost object needed to attach to
+ * the target Java Virtual Machine.
+ *
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public static MonitoredHost getMonitoredHost(VmIdentifier vmid)
+ throws MonitorException {
+ // use the VmIdentifier to construct the corresponding HostIdentifier
+ HostIdentifier hostId = new HostIdentifier(vmid);
+ return getMonitoredHost(hostId);
+ }
+
+
+ /*
+ * Load the MonitoredHostServices
+ */
+ private static ServiceLoader<MonitoredHostService> monitoredHostServiceLoader =
+ ServiceLoader.load(MonitoredHostService.class, MonitoredHostService.class.getClassLoader());
+
+ /**
+ * Factory method to construct a MonitoredHost instance to manage the
+ * connection to the host indicated by {@code hostId}.
+ *
+ * @param hostId the identifier for the target host.
+ * @return MonitoredHost - The MonitoredHost object needed to attach to
+ * the target host.
+ *
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public static MonitoredHost getMonitoredHost(HostIdentifier hostId)
+ throws MonitorException {
+ MonitoredHost mh = null;
+
+ synchronized(monitoredHosts) {
+ mh = monitoredHosts.get(hostId);
+ if (mh != null) {
+ if (mh.isErrored()) {
+ monitoredHosts.remove(hostId);
+ } else {
+ return mh;
+ }
+ }
+ }
+
+ hostId = resolveHostId(hostId);
+
+ for (MonitoredHostService mhs : monitoredHostServiceLoader) {
+ if (mhs.getScheme().equals(hostId.getScheme())) {
+ mh = mhs.getMonitoredHost(hostId);
+ }
+ }
+
+ if (mh == null) {
+ throw new IllegalArgumentException("Could not find MonitoredHost for scheme: " + hostId.getScheme());
+ }
+
+ synchronized(monitoredHosts) {
+ monitoredHosts.put(mh.hostId, mh);
+ }
+
+ return mh;
+ }
+
+ /**
+ * Method to resolve unspecified components of the given HostIdentifier
+ * by constructing a new HostIdentifier that replaces the unspecified
+ * components with the default values.
+ *
+ * @param hostId the unresolved HostIdentifier.
+ * @return HostIdentifier - a resolved HostIdentifier.
+ *
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ protected static HostIdentifier resolveHostId(HostIdentifier hostId)
+ throws MonitorException {
+ String hostname = hostId.getHost();
+ String scheme = hostId.getScheme();
+ StringBuilder sb = new StringBuilder();
+
+ assert hostname != null;
+
+ if (scheme == null) {
+ if (hostname.compareTo("localhost") == 0) {
+ scheme = LOCAL_PROTOCOL;
+ } else {
+ scheme = REMOTE_PROTOCOL;
+ }
+ }
+
+ sb.append(scheme).append(":").append(hostId.getSchemeSpecificPart());
+
+ String frag = hostId.getFragment();
+ if (frag != null) {
+ sb.append("#").append(frag);
+ }
+
+ try {
+ return new HostIdentifier(sb.toString());
+ } catch (URISyntaxException e) {
+ // programming error - HostIdentifier was valid.
+ assert false;
+ throw new IllegalArgumentException("Malformed URI created: "
+ + sb.toString());
+ }
+ }
+
+ /**
+ * Return the resolved HostIdentifier for this MonitoredHost.
+ *
+ * @return HostIdentifier - the resolved HostIdentifier.
+ */
+ public HostIdentifier getHostIdentifier() {
+ return hostId;
+ }
+
+ /* ---- Methods to support polled MonitoredHost Implementations ----- */
+
+ /**
+ * Set the polling interval for this MonitoredHost.
+ *
+ * @param interval the polling interval, in milliseconds
+ */
+ public void setInterval(int interval) {
+ this.interval = interval;
+ }
+
+ /**
+ * Get the polling interval.
+ *
+ * @return int - the polling interval in milliseconds for this MonitoredHost
+ */
+ public int getInterval() {
+ return interval;
+ }
+
+ /**
+ * Set the last exception encountered while polling this MonitoredHost.
+ *
+ * @param lastException the last exception encountered;
+ */
+ public void setLastException(Exception lastException) {
+ this.lastException = lastException;
+ }
+
+ /**
+ * Get the last exception encountered while polling this MonitoredHost.
+ *
+ * @return Exception - the last exception occurred while polling this
+ * MonitoredHost, or {@code null} if no exception
+ * has occurred or the exception has been cleared,
+ */
+ public Exception getLastException() {
+ return lastException;
+ }
+
+ /**
+ * Clear the last exception.
+ */
+ public void clearLastException() {
+ lastException = null;
+ }
+
+ /**
+ * Test if this MonitoredHost is in the errored state. If this method
+ * returns true, then the Exception returned by getLastException()
+ * indicates the Exception that caused the error condition.
+ *
+ * @return boolean - true if the MonitoredHost instance has experienced
+ * an error, or false if it hasn't or if any past
+ * error has been cleared.
+ */
+ public boolean isErrored() {
+ return lastException != null;
+ }
+
+ /**
+ * Get the MonitoredVm for the given Java Virtual Machine. The default
+ * sampling interval is used for the MonitoredVm instance.
+ *
+ * @param id the VmIdentifier specifying the target Java Virtual Machine.
+ * @return MonitoredVm - the MonitoredVm instance for the target Java
+ * Virtual Machine.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public abstract MonitoredVm getMonitoredVm(VmIdentifier id)
+ throws MonitorException;
+
+ /**
+ * Get the MonitoredVm for the given Java Virtual Machine. The sampling
+ * interval is set to the given interval.
+ *
+ * @param id the VmIdentifier specifying the target Java Virtual Machine.
+ * @param interval the sampling interval for the target Java Virtual Machine.
+ * @return MonitoredVm - the MonitoredVm instance for the target Java
+ * Virtual Machine.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public abstract MonitoredVm getMonitoredVm(VmIdentifier id, int interval)
+ throws MonitorException;
+
+ /**
+ * Detach from the indicated MonitoredVm.
+ *
+ * @param vm the monitored Java Virtual Machine.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public abstract void detach(MonitoredVm vm) throws MonitorException;
+
+ /**
+ * Add a HostListener. The given listener is added to the list
+ * of HostListener objects to be notified of MonitoredHost related events.
+ *
+ * @param listener the HostListener to add.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public abstract void addHostListener(HostListener listener)
+ throws MonitorException;
+
+ /**
+ * Remove a HostListener. The given listener is removed from the list
+ * of HostListener objects to be notified of MonitoredHost related events.
+ *
+ * @param listener the HostListener to add.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public abstract void removeHostListener(HostListener listener)
+ throws MonitorException;
+
+ /**
+ * Return the current set of active Java Virtual Machines for this
+ * MonitoredHost. The returned Set contains {@link Integer} instances
+ * holding the local virtual machine identifier, or <em>lvmid</em>
+ * for each instrumented Java Virtual Machine currently available.
+ *
+ * @return Set - the current set of active Java Virtual Machines associated
+ * with this MonitoredHost, or the empty set of none.
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public abstract Set<Integer> activeVms() throws MonitorException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredHostService.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+public interface MonitoredHostService {
+
+ /**
+ * Construct a MonitoredHost instance to manage the
+ * connection to the host indicated by {@code hostId}.
+ *
+ * @param hostId the identifier for the target host.
+ * @return MonitoredHost - The MonitoredHost object needed to attach to
+ * the target host.
+ *
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId) throws MonitorException;
+
+ /**
+ * Get the scheme that this service supports.
+ *
+ * @return scheme name
+ */
+ public String getScheme();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVm.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+import java.util.List;
+
+import sun.jvmstat.monitor.event.VmListener;
+
+/**
+ * Interface for interacting with a monitorable Java Virtual Machine.
+ * The MonitoredVm interface provides methods for discovery of exported
+ * instrumentation, for attaching event listeners, and for overall
+ * maintenance of the connection to the target.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public interface MonitoredVm {
+
+ /**
+ * Get the VmIdentifier associated with this MonitoredVm
+ *
+ * @return VmIdentifier - the fully resolved Vm identifier associated
+ * with this MonitoredVm.
+ */
+ VmIdentifier getVmIdentifier();
+
+ /**
+ * Find a named Instrumentation object.
+ *
+ * This method will look for the named instrumentation object in the
+ * instrumentation exported by this Java Virtual Machine. If an
+ * instrumentation object with the given name exists, a Monitor interface
+ * to that object will be return. Otherwise, the method returns
+ * {@code null}.
+ *
+ * @param name the name of the Instrumentation object to find.
+ * @return Monitor - the {@link Monitor} object that can be used to
+ * monitor the named instrumentation object, or
+ * {@code null} if the named object doesn't exist.
+ * @throws MonitorException Thrown if an error occurs while communicating
+ * with the target Java Virtual Machine.
+ */
+ Monitor findByName(String name) throws MonitorException;
+
+ /**
+ * Find all Instrumentation objects with names matching the given pattern.
+ *
+ * This method returns a {@link List} of Monitor objects such that
+ * the name of each object matches the given pattern.
+ *
+ * @param patternString a string containing a pattern as described in
+ * {@link java.util.regex.Pattern}.
+ * @return {@code List<Monitor>} - a List of {@link Monitor}
+ * objects that can be used to
+ * monitor the instrumentation objects whose names match
+ * the given pattern. If no instrumentation objects have
+ * names matching the given pattern, then an empty List
+ * is returned.
+ * @throws MonitorException Thrown if an error occurs while communicating
+ * with the target Java Virtual Machine.
+ * @see java.util.regex.Pattern
+ */
+ List<Monitor> findByPattern(String patternString) throws MonitorException;
+
+ /**
+ * Detach from target Java Virtual Machine.
+ *
+ * After calling this method, updates of the instrumentation data values
+ * may be halted. All event notifications are halted. Further interactions
+ * with this object should be avoided.
+ */
+ void detach();
+
+
+ /* ---- Methods to support polled MonitoredVm Implementations ---- */
+
+ /**
+ * Set the polling interval to {@code interval} milliseconds.
+ *
+ * Polling based monitoring implementations need to refresh the
+ * instrumentation data on a periodic basis. This interface allows
+ * the interval to override the implementation specific default
+ * interval.
+ *
+ * @param interval the polling interval in milliseconds
+ */
+ void setInterval(int interval);
+
+ /**
+ * Get the polling interval.
+ *
+ * @return int - the current polling interval in milliseconds.
+ * @see #setInterval
+ */
+ int getInterval();
+
+ /**
+ * Set the last exception encountered while polling this MonitoredVm.
+ *
+ * Polling implementations may choose to poll asynchronously. This
+ * method allows an asynchronous task to communicate any polling related
+ * exceptions with the application. When an a non-null exception is reported
+ * through this interface, the MonitoredVm instance is considered to
+ * be in the <em>errored</em> state.
+ *
+ * @param cause the exception to record.
+ * @see #isErrored
+ */
+ void setLastException(Exception cause);
+
+ /**
+ * Get the last exception encountered while polling this MonitoredVm.
+ *
+ * Returns the last exception observed by the implementation dependent
+ * polling task or {@code null} if no such error has occurred.
+ *
+ * @return Exception - the last exception that occurred during polling
+ * or {@code null} if no error condition exists.
+ * @see #isErrored
+ * @see #setLastException
+ */
+ Exception getLastException();
+
+ /**
+ * Clear the last exception.
+ *
+ * Calling this method will clear the <em>errored</em> state of this
+ * MonitoredVm. However, there is no guarantee that clearing the
+ * the errored state return the asynchronous polling task to an
+ * operational state.
+ *
+ */
+ void clearLastException();
+
+ /**
+ * Test if this MonitoredVm is in the errored state.
+ * The errored state exists only if an error was reported with
+ * call to {@link #setLastException} and only if the parameter to
+ * that call was non-null and no subsequent calls are made to
+ * {@link #clearLastException}.
+ *
+ * @return boolean - true if the instance has a non-null error condition
+ * set, false otherwise.
+ *
+ * @see #setLastException
+ * @see #getLastException
+ */
+ boolean isErrored();
+
+ /**
+ * Add a VmListener. The given listener is added to the list of
+ * VmListener objects to be notified of MonitoredVm related events.
+ *
+ * @param listener the VmListener to add.
+ * @throws MonitorException Thrown if any problems occur while attempting
+ * to add this listener.
+ */
+ void addVmListener(VmListener listener) throws MonitorException;
+
+ /**
+ * Remove a VmListener. The given listener is removed from the list of
+ * VmListener objects to be notified of MonitoredVm related events.
+ *
+ * @param listener the VmListener to be removed.
+ * @throws MonitorException Thrown if any problems occur while attempting
+ * to remove this listener.
+ */
+ void removeVmListener(VmListener listener) throws MonitorException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVmUtil.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Utility class proving concenience methods for extracting various
+ * information from an MonitoredVm object.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class MonitoredVmUtil {
+
+ /**
+ * Private constructor - prevent instantiation.
+ */
+ private MonitoredVmUtil() { }
+
+ /**
+ * Return the Java Virtual Machine Version.
+ *
+ * @param vm the target MonitoredVm
+ * @return String - contains the version of the target JVM or the
+ * the string "Unknown" if the version cannot be
+ * determined.
+ */
+ public static String vmVersion(MonitoredVm vm) throws MonitorException {
+ StringMonitor ver =
+ (StringMonitor)vm.findByName("java.property.java.vm.version");
+ return (ver == null) ? "Unknown" : ver.stringValue();
+ }
+
+ /**
+ * Return the command line for the target Java application.
+ *
+ * @param vm the target MonitoredVm
+ * @return String - contains the command line of the target Java
+ * application or the string "Unknown" if the
+ * command line cannot be determined.
+ */
+ public static String commandLine(MonitoredVm vm) throws MonitorException {
+ StringMonitor cmd = (StringMonitor)vm.findByName("sun.rt.javaCommand");
+ return (cmd == null) ? "Unknown" : cmd.stringValue();
+ }
+
+ /**
+ * Return the arguments to the main class for the target Java application.
+ * Returns the arguments to the main class. If the arguments can't be
+ * found, the string "Unknown" is returned.
+ *
+ * @param vm the target MonitoredVm
+ * @return String - contains the arguments to the main class for the
+ * target Java application or the string "Unknown"
+ * if the command line cannot be determined.
+ */
+ public static String mainArgs(MonitoredVm vm) throws MonitorException {
+ String commandLine = commandLine(vm);
+
+ int firstSpace = commandLine.indexOf(' ');
+ if (firstSpace > 0) {
+ return commandLine.substring(firstSpace + 1);
+ } else if (commandLine.compareTo("Unknown") == 0) {
+ return commandLine;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Return the main class for the target Java application.
+ * Returns the main class or the name of the jar file if the application
+ * was started with the <em>-jar</em> option.
+ *
+ * @param vm the target MonitoredVm
+ * @param fullPath include the full path to Jar file, where applicable
+ * @return String - contains the main class of the target Java
+ * application or the string "Unknown" if the
+ * command line cannot be determined.
+ */
+ public static String mainClass(MonitoredVm vm, boolean fullPath)
+ throws MonitorException {
+ String cmdLine = commandLine(vm);
+ int firstSpace = cmdLine.indexOf(' ');
+ if (firstSpace > 0) {
+ cmdLine = cmdLine.substring(0, firstSpace);
+ }
+ if (fullPath) {
+ return cmdLine;
+ }
+ /*
+ * Can't use File.separator() here because the separator for the target
+ * jvm may be different than the separator for the monitoring jvm.
+ * And we also strip embedded module e.g. "module/MainClass"
+ */
+ int lastSlash = cmdLine.lastIndexOf("/");
+ int lastBackslash = cmdLine.lastIndexOf("\\");
+ int lastSeparator = lastSlash > lastBackslash ? lastSlash : lastBackslash;
+ if (lastSeparator > 0) {
+ cmdLine = cmdLine.substring(lastSeparator + 1);
+ }
+
+ int lastPackageSeparator = cmdLine.lastIndexOf('.');
+ if (lastPackageSeparator > 0) {
+ String lastPart = cmdLine.substring(lastPackageSeparator + 1);
+ /*
+ * We could have a relative path "my.module" or
+ * a module called "my.module" and a jar file called "my.jar" or
+ * class named "jar" in package "my", e.g. "my.jar".
+ * We can never be sure here, but we assume *.jar is a jar file
+ */
+ if (lastPart.equals("jar")) {
+ return cmdLine; /* presumably a file name without path */
+ }
+ return lastPart; /* presumably a class name without package */
+ }
+
+ return cmdLine;
+ }
+
+ /**
+ * Return the JVM arguments for the target Java application.
+ *
+ * @param vm the target MonitoredVm
+ * @return String - contains the arguments passed to the JVM for the
+ * target Java application or the string "Unknown"
+ * if the command line cannot be determined.
+ */
+ public static String jvmArgs(MonitoredVm vm) throws MonitorException {
+ StringMonitor jvmArgs = (StringMonitor)vm.findByName("java.rt.vmArgs");
+ return (jvmArgs == null) ? "Unknown" : jvmArgs.stringValue();
+ }
+
+ /**
+ * Return the JVM flags for the target Java application.
+ *
+ * @param vm the target MonitoredVm
+ * @return String - contains the flags passed to the JVM for the
+ * target Java application or the string "Unknown"
+ * if the command line cannot be determined.
+ */
+ public static String jvmFlags(MonitoredVm vm) throws MonitorException {
+ StringMonitor jvmFlags =
+ (StringMonitor)vm.findByName("java.rt.vmFlags");
+ return (jvmFlags == null) ? "Unknown" : jvmFlags.stringValue();
+ }
+
+ // Index of the sun.rt.jvmCapabilities counter
+ private static int IS_ATTACHABLE = 0;
+ private static int IS_KERNEL_VM = 1;
+
+ /**
+ * Returns true if the VM supports attach-on-demand.
+ *
+ * @param vm the target MonitoredVm
+ */
+ public static boolean isAttachable(MonitoredVm vm) throws MonitorException {
+ StringMonitor jvmCapabilities =
+ (StringMonitor)vm.findByName("sun.rt.jvmCapabilities");
+ if (jvmCapabilities == null) {
+ return false;
+ } else {
+ return jvmCapabilities.stringValue().charAt(IS_ATTACHABLE) == '1';
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/StringMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+/**
+ * Interface for Monitoring StringInstrument objects.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see sun.jvmstat.instrument.StringInstrument
+ */
+public interface StringMonitor extends Monitor {
+
+ /**
+ * Get a copy of the current value of the StringInstrument object.
+ *
+ * @return String - a String object containing a copy of the value of
+ * the associated StringInstrument.
+ */
+ public String stringValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/Units.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.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/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/Variability.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.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;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/VmIdentifier.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor;
+
+import java.net.*;
+
+/**
+ * An abstraction that identifies a target Java Virtual Machine.
+ * The VmIdentifier, or vmid, provides a convenient string representation
+ * of the information needed to locate and communicate with a target
+ * Java Virtual Machine. The string, based on a {@link URI}, may specify
+ * the communications protocol, host name, local vm identifier, and protocol
+ * specific information for a target Java Virtual Machine. The format for
+ * a VmIdentifier string is:
+ * <pre>
+ * [<I>protocol</I>:][<I>//</I>]<I><B>lvmid</B></I>[<I>@hostname</I>][<I>:port</I>][<I>/servername</I>]
+ * </pre>
+ * The only required component of this string is the Local Virtual Machine
+ * Identifier, or {@code lvmid}, which uniquely identifies the target
+ * Java Virtual Machine on a host. The optional components of the VmIdentifier
+ * include:
+ * <ul>
+ * <li>{@code protocol} - The communications protocol. A VmIdentifier
+ * omitting the protocol must be resolved against a HostIdentifier
+ * using {@link HostIdentifier#resolve}.
+ * </li>
+ * <li>{@code hostname} - A hostname or IP address indicating the target
+ * host. A VmIdentifier omitting the protocol must be resolved
+ * against a HostIdentifier using {@link HostIdentifier#resolve}.
+ * </li>
+ * <li>{@code port} - The port for the communications protocol.
+ * Treatment of the {@code port} parameter is implementation
+ * (protocol) specific. A VmIdentifier omitting the protocol should
+ * be resolved against a HostIdentifier using
+ * {@link HostIdentifier#resolve}.
+ * </li>
+ * <li>{@code servername} - The treatment of the Path, Query, and
+ * Fragment components of the VmIdentifier are implementation
+ * (protocol) dependent. A VmIdentifier omitting the protocol should
+ * be resolved against a HostIdentifier using
+ * {@link HostIdentifier#resolve}.
+ * </li>
+ * </ul>
+ * <p>
+ * All VmIdentifier instances are constructed as absolute, hierarchical URIs.
+ * The constructors will accept relative (and even some malformed,
+ * though convenient) URI strings. Such strings are transformed into
+ * legitimate, absolute URI strings.
+ * <p>
+ * With the exception of <em>file:</em> based VmIdentifier strings, all
+ * VmIdentifier strings must include a {@code lvmid}. Attempting to construct
+ * a non-file based VmIdentifier that doesn't include a {@code lvmid}
+ * component will result in a {@code MonitorException}.
+ * <p>
+ * Here are some examples of VmIdentifier strings.
+ * <ul>
+ * <li>Relative URIs
+ * <ul>
+ * <li><em>1234</em> - Specifies the Java Virtual Machine
+ * identified by lvmid <em>1234</em> on an unnamed host.
+ * This string is transformed into the absolute form
+ * <em>//1234</em>, which must be resolved against a
+ * HostIdentifier.
+ * </li>
+ * <li><em>1234@hostname</em> - Specifies the Java Virtual
+ * Machine identified by lvmid <em>1234</em> on host
+ * <em>hostname</em> with an unnamed protocol.
+ * This string is transformed into the absolute form
+ * <em>//1234@hostname</em>, which must be resolved against
+ * a HostIdentifier.
+ * </li>
+ * <li><em>1234@hostname:2099</em> - Specifies the Java Virtual
+ * Machine identified by lvmid <em>1234</em> on host
+ * <em>hostname</em> with an unnamed protocol, but with
+ * port <em>2099</em>. This string is transformed into
+ * the absolute form <em>//1234@hostname:2099</em>, which
+ * must be resolved against a HostIdentifier.
+ * </li>
+ * </ul>
+ * </li>
+ * <li>Absolute URIs
+ * <ul>
+ * <li><em>rmi://1234@hostname:2099/remoteobjectname</em> -
+ * Specifies the Java Virtual Machine identified by lvmid
+ * <em>1234</em> on host <em>hostname</em> accessed
+ * using the <em>rmi:</em> protocol through the rmi remote
+ * object named <em>remoteobjectname</em> as registered with
+ * the <em>rmiserver</em> on port <em>2099</em> on host
+ * <em>hostname</em>.
+ * </li>
+ * <li><em>file:/path/file</em> - Identifies a Java Virtual Machine
+ * through accessing a special file based protocol to use as
+ * the communications mechanism.
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @see URI
+ * @see HostIdentifier
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class VmIdentifier {
+ private URI uri;
+
+ /**
+ * creates a canonical representation of the uriString. This method
+ * performs certain translations depending on the type of URI generated
+ * by the string.
+ */
+ private URI canonicalize(String uriString) throws URISyntaxException {
+ if (uriString == null) {
+ uriString = "local://0@localhost";
+ return new URI(uriString);
+ }
+
+ URI u = new URI(uriString);
+
+ if (u.isAbsolute()) {
+ if (u.isOpaque()) {
+ /*
+ * rmi:1234@hostname/path#fragment converted to
+ * rmi://1234@hostname/path#fragment
+ */
+ u = new URI(u.getScheme(), "//" + u.getSchemeSpecificPart(),
+ u.getFragment());
+ }
+ } else {
+ /*
+ * make the uri absolute, if possible. A relative URI doesn't
+ * specify the scheme part, so it's safe to prepend a "//" and
+ * try again.
+ */
+ if (!uriString.startsWith("//")) {
+ if (u.getFragment() == null) {
+ u = new URI("//" + u.getSchemeSpecificPart());
+ } else {
+ u = new URI("//" + u.getSchemeSpecificPart() + "#"
+ + u.getFragment());
+ }
+ }
+ }
+ return u;
+ }
+
+ /**
+ * check that the VmIdentifier includes a unique numerical identifier
+ * for the target JVM.
+ */
+ private void validate() throws URISyntaxException {
+ // file:// uri, which is a special case where the lvmid is not required.
+ String s = getScheme();
+ if ((s != null) && (s.compareTo("file") == 0)) {
+ return;
+ }
+ if (getLocalVmId() == -1) {
+ throw new URISyntaxException(uri.toString(), "Local vmid required");
+ }
+ }
+
+ /**
+ * Create a VmIdentifier instance from a string value.
+ *
+ * @param uriString a string representing a target Java Virtual Machine.
+ * The syntax of the string must conforms to the rules
+ * specified in the class documentation.
+ * @throws URISyntaxException Thrown when the uriString or its canonical
+ * form is poorly formed.
+ */
+ public VmIdentifier(String uriString) throws URISyntaxException {
+ URI u;
+ try {
+ u = canonicalize(uriString);
+ } catch (URISyntaxException e) {
+ /*
+ * a vmid of the form 1234@hostname:1098 causes an exception,
+ * so try again with a leading "//"
+ */
+ if (uriString.startsWith("//")) {
+ throw e;
+ }
+ u = canonicalize("//"+uriString);
+ }
+
+ uri = u;
+
+ // verify that we have a valid lvmid
+ validate();
+ }
+
+ /**
+ * Create a VmIdentifier instance from a URI object.
+ *
+ * @param uri a well formed, absolute URI indicating the
+ * target Java Virtual Machine.
+ * @throws URISyntaxException Thrown if the URI is missing some
+ * required component.
+ */
+ public VmIdentifier(URI uri) throws URISyntaxException {
+ this.uri = uri;
+ validate();
+ }
+
+ /**
+ * Return the corresponding HostIdentifier for this VmIdentifier.
+ * <p>
+ * This method constructs a HostIdentifier object from the VmIdentifier.
+ * If the VmIdentifier is not specific about the protocol or other
+ * components of the URI, then the resulting HostIdentifier will
+ * be constructed based on this missing information. Typically, the
+ * missing components will have result in the HostIdentifier assigning
+ * assumed defaults that allow the VmIdentifier to be resolved according
+ * to those defaults.
+ * <p>
+ * For example, a VmIdentifier that specifies only a {@code lvmid}
+ * will result in a HostIdentifier for <em>localhost</em> utilizing
+ * the default local protocol, <em>local:</em>. A VmIdentifier that
+ * specifies both a {@code vmid} and a {@code hostname} will result
+ * in a HostIdentifier for the specified host with the default remote
+ * protocol, <em>rmi:</em>, using the protocol defaults for the
+ * {@code port} and {@code servername} components.
+ *
+ * @return HostIdentifier - the host identifier for the host containing
+ * the Java Virtual Machine represented by this
+ * VmIdentifier.
+ * @throws URISyntaxException Thrown if a bad host URI is constructed.
+ * This exception may get encapsulated into
+ * a MonitorException in a future version.
+ */
+ public HostIdentifier getHostIdentifier() throws URISyntaxException {
+ StringBuilder sb = new StringBuilder();
+ if (getScheme() != null) {
+ sb.append(getScheme()).append(":");
+ }
+ sb.append("//").append(getHost());
+ if (getPort() != -1) {
+ sb.append(":").append(getPort());
+ }
+ if (getPath() != null) {
+ sb.append(getPath());
+ }
+ return new HostIdentifier(sb.toString());
+ }
+
+ /**
+ * Return the Scheme, or protocol, portion of this VmIdentifier.
+ *
+ * @return String - the scheme for this VmIdentifier.
+ * @see URI#getScheme()
+ */
+ public String getScheme() {
+ return uri.getScheme();
+ }
+
+ /**
+ * Return the Scheme Specific Part of this VmIdentifier.
+ *
+ * @return String - the Scheme Specific Part for this VmIdentifier.
+ * @see URI#getSchemeSpecificPart()
+ */
+ public String getSchemeSpecificPart() {
+ return uri.getSchemeSpecificPart();
+ }
+
+ /**
+ * Return the UserInfo part of this VmIdentifier.
+ *
+ * @return String - the UserInfo part for this VmIdentifier.
+ * @see URI#getUserInfo()
+ */
+ public String getUserInfo() {
+ return uri.getUserInfo();
+ }
+
+ /**
+ * Return the Host part of this VmIdentifier.
+ *
+ * @return String - the Host part for this VmIdentifier.
+ * @see URI#getHost()
+ */
+ public String getHost() {
+ return uri.getHost();
+ }
+
+ /**
+ * Return the Port part of this VmIdentifier.
+ *
+ * @return int - the Port part for this VmIdentifier.
+ * @see URI#getPort()
+ */
+ public int getPort() {
+ return uri.getPort();
+ }
+
+ /**
+ * Return the Authority part of this VmIdentifier.
+ *
+ * @return String - the Authority part for this VmIdentifier.
+ * @see URI#getAuthority()
+ */
+ public String getAuthority() {
+ return uri.getAuthority();
+ }
+
+ /**
+ * Return the Path part of this VmIdentifier.
+ *
+ * @return String - the Path part for this VmIdentifier.
+ * @see URI#getPath()
+ */
+ public String getPath() {
+ return uri.getPath();
+ }
+
+ /**
+ * Return the Query part of this VmIdentifier.
+ *
+ * @return String - the Query part for this VmIdentifier.
+ * @see URI#getQuery()
+ */
+ public String getQuery() {
+ return uri.getQuery();
+ }
+
+ /**
+ * Return the Fragment part of this VmIdentifier.
+ *
+ * @return String - the Fragment part for this VmIdentifier.
+ * @see URI#getFragment()
+ */
+ public String getFragment() {
+ return uri.getFragment();
+ }
+
+ /**
+ * Return the Local Virtual Machine Identifier for this VmIdentifier.
+ * The Local Virtual Machine Identifier is also known as the
+ * <em>lvmid</em>.
+ *
+ * @return int - the lvmid for this VmIdentifier.
+ */
+ public int getLocalVmId() {
+ int result = -1;
+ try {
+ if (uri.getUserInfo() == null) {
+ result = Integer.parseInt(uri.getAuthority());
+ } else {
+ result = Integer.parseInt(uri.getUserInfo());
+ }
+ } catch (NumberFormatException e) { }
+ return result;
+ }
+
+ /**
+ * Return the mode indicated in this VmIdentifier.
+ *
+ * @return String - the mode string. If no mode is specified, then "r"
+ * is returned. otherwise, the specified mode is returned.
+ */
+ public String getMode() {
+ String query = getQuery();
+ if (query != null) {
+ String[] queryArgs = query.split("\\+");
+ for (int i = 0; i < queryArgs.length; i++) {
+ if (queryArgs[i].startsWith("mode=")) {
+ int index = queryArgs[i].indexOf('=');
+ return queryArgs[i].substring(index+1);
+ }
+ }
+ }
+ return "r";
+ }
+
+ /**
+ * Return the URI associated with the VmIdentifier.
+ *
+ * @return URI - the URI.
+ * @see URI
+ */
+ public URI getURI() {
+ return uri;
+ }
+
+ /**
+ * Return the hash code for this VmIdentifier. The hash code is
+ * identical to the hash code for the contained URI.
+ *
+ * @return int - the hashcode.
+ * @see URI#hashCode()
+ */
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ /**
+ * Test for quality with other objects.
+ *
+ * @param object the object to be test for equality.
+ * @return boolean - returns true if the given object is of type
+ * VmIdentifier and its URI field is equal to
+ * this object's URI field. Otherwise, return false.
+ *
+ * @see URI#equals(Object)
+ */
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ if (!(object instanceof VmIdentifier)) {
+ return false;
+ }
+ return uri.equals(((VmIdentifier)object).uri);
+ }
+
+ /**
+ * Convert to a string representation. Conversion is identical to
+ * calling getURI().toString(). This may change in a future release.
+ *
+ * @return String - a String representation of the VmIdentifier.
+ *
+ * @see URI#toString()
+ */
+ public String toString() {
+ return uri.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/HostEvent.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor.event;
+
+import java.util.EventObject;
+import sun.jvmstat.monitor.MonitoredHost;
+
+/**
+ * Base class for events emitted by a {@link MonitoredHost}.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class HostEvent extends EventObject {
+
+ /**
+ * Construct a new HostEvent instance.
+ *
+ * @param host the MonitoredHost source of the event.
+ */
+ public HostEvent(MonitoredHost host) {
+ super(host);
+ }
+
+ /**
+ * Return the MonitoredHost source of this event.
+ *
+ * @return MonitoredHost - the source of this event.
+ */
+ public MonitoredHost getMonitoredHost() {
+ return (MonitoredHost)source;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/HostListener.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor.event;
+
+import java.util.EventListener;
+
+/**
+ * Interface for listeners of MonitoredHost events.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see sun.jvmstat.monitor.MonitoredHost
+ */
+public interface HostListener extends EventListener {
+
+ /**
+ * Invoked when the status of Java Virtual Machine changes.
+ *
+ * @param event the object describing the event.
+ */
+ void vmStatusChanged(VmStatusChangeEvent event);
+
+ /**
+ * Invoked when the connection to the MonitoredHost has disconnected
+ * due to communication errors.
+ *
+ * @param event the object describing the event.
+ */
+ void disconnected(HostEvent event);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/MonitorStatusChangeEvent.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor.event;
+
+import java.util.List;
+import sun.jvmstat.monitor.MonitoredVm;
+import sun.jvmstat.monitor.Monitor;
+
+/**
+ * Provides a description of a change in status of the instrumentation
+ * exported by the MonitoredVm.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class MonitorStatusChangeEvent extends VmEvent {
+
+ /**
+ * List of instrumentation objects inserted since the last event.
+ * Elements of this list will always be of type Monitor.
+ */
+ protected List<Monitor> inserted;
+
+ /**
+ * List of instrumentation objects removed since the last event.
+ * Elements of this list will always be of type Monitor.
+ */
+ protected List<Monitor> removed;
+
+ /**
+ * Construct a new MonitorStatusChangeEvent.
+ *
+ * @param vm the MonitoredVm source of the event.
+ * @param inserted the list of instrumentation objects inserted since
+ * the last event.
+ * @param removed the list of instrumentation objects removed since
+ * the last event.
+ */
+ public MonitorStatusChangeEvent(MonitoredVm vm, List<Monitor> inserted,
+ List<Monitor> removed) {
+ super(vm);
+ this.inserted = inserted;
+ this.removed = removed;
+ }
+
+ /**
+ * Return the list of instrumentation objects that were inserted
+ * since the last event notification.
+ *
+ * @return List - a List of Monitor objects that were inserted into the
+ * instrumentation exported by the MonitoredHost. If no
+ * new instrumentation was inserted, an emply List is
+ * returned.
+ */
+ public List<Monitor> getInserted() {
+ return inserted;
+ }
+
+ /**
+ * Return the set of instrumentation objects that were removed
+ * since the last event notification.
+ *
+ * @return List - a List of Monitor objects that were removed from the
+ * instrumentation exported by the MonitoredHost. If no
+ * instrumentation was removed, an emply List is returned.
+ */
+ public List<Monitor> getRemoved() {
+ return removed;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/VmEvent.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor.event;
+
+import java.util.EventObject;
+import sun.jvmstat.monitor.MonitoredVm;
+
+/**
+ * Base class for events emitted by a {@link MonitoredVm}.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class VmEvent extends EventObject {
+
+ /**
+ * Construct a new VmEvent instance.
+ *
+ * @param vm the MonitoredVm source of the event.
+ */
+ public VmEvent(MonitoredVm vm) {
+ super(vm);
+ }
+
+ /**
+ * Return the MonitoredVm source of this event.
+ *
+ * @return MonitoredVm - the source of this event.
+ */
+ public MonitoredVm getMonitoredVm() {
+ return (MonitoredVm)source;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/VmListener.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor.event;
+
+import java.util.EventListener;
+
+/**
+ * Interface for listeners of MonitoredVm events.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see sun.jvmstat.monitor.MonitoredVm
+ */
+public interface VmListener extends EventListener {
+
+ /**
+ * Invoked when instrumentation objects are inserted into or removed
+ * from the MonitoredVm.
+ *
+ * @param event the object describing the event.
+ */
+ void monitorStatusChanged(MonitorStatusChangeEvent event);
+
+ /**
+ * Invoked when instrumentation objects are updated. This event is
+ * generated at a fixed interval as determined by the polling rate
+ * of the MonitoredVm that the VmListener is registered with.
+ *
+ * @param event the object describing the event.
+ */
+ void monitorsUpdated(VmEvent event);
+
+ /**
+ * Invoked when the connection to the MonitoredVm has disconnected
+ * due to communication errors.
+ *
+ * @param event the object describing the event.
+ */
+ void disconnected(VmEvent event);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/VmStatusChangeEvent.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.monitor.event;
+
+import java.util.Set;
+import sun.jvmstat.monitor.MonitoredHost;
+
+/**
+ * Provides a description of a change in status of the Java Virtual Machines
+ * associated with a MonitoredHost.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class VmStatusChangeEvent extends HostEvent {
+
+ /**
+ * The set of currently active Java Virtual Machines for the MonitoredHost.
+ * The set contains an Integer object holding the <em>lvmid</em> for each
+ * active Java Virtual Machine on the MonitoredHost. This Set will only
+ * contain Integer objects.
+ */
+ protected Set<Integer> active;
+
+ /**
+ * The set of Java Virtual Machines started on MonitoredHost since the
+ * previous event. The set contains an Integer object holding the
+ * <em>lvmid</em> for each Java Virtual Machine started on the
+ * MonitoredHost. This Set will only contain Integer objects.
+ */
+ protected Set<Integer> started;
+
+ /**
+ * The set of Java Virtual Machines terminated on MonitoredHost since the
+ * previous event. The set contains an Integer object holding the
+ * <em>lvmid</em> for each Java Virtual Machine started on the
+ * MonitoredHost. This Set will only contain Integer objects.
+ */
+ protected Set<Integer> terminated;
+
+ /**
+ * Construct a new VmStatusChangeEvent instance.
+ *
+ * @param host the MonitoredHost that is the source of the event.
+ * @param active the set of currently active Java Virtual Machines
+ * @param started the set of Java Virtual Machines started since the
+ * last event.
+ * @param terminated the set of Java Virtual Machines terminated since
+ * the last event.
+ */
+ public VmStatusChangeEvent(MonitoredHost host, Set<Integer> active,
+ Set<Integer> started, Set<Integer> terminated) {
+ super(host);
+ this.active = active;
+ this.started = started;
+ this.terminated = terminated;
+ }
+
+ /**
+ * Return the set of currently active Java Virtual Machines.
+ * The set contains an Integer object holding the <em>lvmid</em> for each
+ * active Java Virtual Machine on the MonitoredHost.
+ *
+ * @return Set - a set of Integer objects containing the <em>lvmid</em>
+ * of each active Java Virtual Machine on the host. If
+ * there are no active Java Virtual Machines on the host,
+ * an empty Set is returned.
+ */
+ public Set<Integer> getActive() {
+ return active;
+ }
+
+ /**
+ * Return the set of Java Virtual Machines started since the last
+ * event notification. The set contains an Integer object holding
+ * the <em>lvmid</em> for each Java Virtual Machine started on the
+ * MonitoredHost since the last event notification.
+ *
+ * @return Set - a set of Integer objects containing the <em>lvmid</em>
+ * of each Java Virtual Machine started on the host. If
+ * no Java Virtual Machines were recently started on the
+ * host, an empty Set is returned.
+ */
+ public Set<Integer> getStarted() {
+ return started;
+ }
+
+ /**
+ * Return the set of Java Virtual Machines terminated since the last
+ * event notification. The set contains an Integer object holding
+ * the <em>lvmid</em> for each Java Virtual Machine terminated on the
+ * MonitoredHost since the last event notification.
+ *
+ * @return Set - a set of Integer objects containing the <em>lvmid</em>
+ * of each Java Virtual Machine terminated on the host. If
+ * no Java Virtual Machines were recently terminated on the
+ * host, an empty Set is returned.
+ */
+ public Set<Integer> getTerminated() {
+ return terminated;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/event/package.html Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,39 @@
+<!doctype html public "-//IETF//DTD HTML/EN">
+<html>
+<head>
+<!--
+
+
+ Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ particular file as subject to the "Classpath" exception as provided
+ by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+
+
+-->
+</head>
+<body bgcolor="white">
+<p>
+Provides classes for event types and event listeners for MonitoredHost
+and MonitoredVm events..
+</p>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/monitor/package.html Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,64 @@
+<!doctype html public "-//IETF//DTD HTML/EN">
+<html>
+<head>
+<!--
+
+
+ Copyright (c) 2004, 2007, Oracle and/or its affiliates. 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. Oracle designates this
+ particular file as subject to the "Classpath" exception as provided
+ by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+
+
+-->
+</head>
+<body bgcolor="white">
+<p>
+Provides classes for monitoring instrumented HotSpot Java Virtual Machines.
+</p>
+<p>
+The classes in this package provide abstractions for:
+</p>
+<p>
+<ul>
+ <li><p>Identifying monitorable hosts and Java Virtual Machines.</p></li>
+ <li><p>Monitoring the creation and destruction of instrumented
+ Java Virtual Machines on local and remote hosts.</p></li>
+ <li><p>Discovering and Monitoring instrumentation exported by an
+ instrumented Java Virtual Machine.</p></li>
+</ul>
+</p>
+<p>
+The {@link sun.jvmstat.monitor.MonitoredHost} class provides the
+interface to acquire concrete implementations for discovering instrumented
+Java Virtual Machines on a specific host. It serves a factory for creating
+MonitoredHost instances for specific hosts and for creating
+{@link sun.jvmstat.monitor.MonitoredVm} instances for specific
+instrumented Java Virtual Machines on those hosts.
+</p>
+<p>
+The {@link sun.jvmstat.monitor.MonitoredVm} instances provide an
+interface for discovery of instrumentation objects and the
+{@link sun.jvmstat.monitor.Monitor} interfaces provide a mechanism
+for monitoring the instrumentation exported by a JVM.
+</p>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractMonitoredVm.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import java.util.List;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.monitor.event.VmListener;
+
+/**
+ * Base class for all MonitoredVm implementations that utilize the
+ * HotSpot PerfData instrumentation buffer as the communications
+ * mechanism to the target Java Virtual Machine.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public abstract class AbstractMonitoredVm implements BufferedMonitoredVm {
+
+ /**
+ * The VmIdentifier for the target.
+ */
+ protected VmIdentifier vmid;
+
+ /**
+ * The shared memory instrumentation buffer for the target.
+ */
+ protected AbstractPerfDataBuffer pdb;
+
+ /**
+ * The sampling interval, if the instrumentation buffer is acquired
+ * by sampling instead of shared memory mechanisms.
+ */
+ protected int interval;
+
+ /**
+ * Create an AbstractMonitoredVm instance.
+ *
+ * @param vmid the VmIdentifier for the target
+ * @param interval the initial sampling interval
+ */
+ public AbstractMonitoredVm(VmIdentifier vmid, int interval)
+ throws MonitorException {
+ this.vmid = vmid;
+ this.interval = interval;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public VmIdentifier getVmIdentifier() {
+ return vmid;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Monitor findByName(String name) throws MonitorException {
+ return pdb.findByName(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Monitor> findByPattern(String patternString) throws MonitorException {
+ return pdb.findByPattern(patternString);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void detach() {
+ /*
+ * no default action required because the detach operation for the
+ * native byte buffer is managed by the Perf class.
+ */
+ }
+
+
+ /* ---- Methods to support polled MonitoredVm Implementations ----- */
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setInterval(int interval) {
+ this.interval = interval;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getInterval() {
+ return interval;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLastException(Exception e) {
+ // XXX: implement
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Exception getLastException() {
+ // XXX: implement
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearLastException() {
+ // XXX: implement
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isErrored() {
+ // XXX: implement
+ return false;
+ }
+
+ /**
+ * Get a list of the inserted and removed monitors since last called.
+ *
+ * @return MonitorStatus - the status of available Monitors for the
+ * target Java Virtual Machine.
+ * @throws MonitorException Thrown if communications errors occur
+ * while communicating with the target.
+ */
+ public MonitorStatus getMonitorStatus() throws MonitorException {
+ return pdb.getMonitorStatus();
+ }
+
+
+ /* --------------- Methods to support VmListeners ----------------- */
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract void addVmListener(VmListener l);
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract void removeVmListener(VmListener l);
+
+
+ /* ---- Methods to support BufferedMonitoredVm Implementations ---- */
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getBytes() {
+ return pdb.getBytes();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCapacity() {
+ return pdb.getCapacity();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.util.*;
+import java.io.*;
+import java.lang.reflect.*;
+import java.nio.ByteBuffer;
+
+/**
+ * Abstraction for the HotSpot PerfData instrumentation buffer. This class
+ * is responsible for acquiring access to the instrumentation buffer for
+ * a target HotSpot Java Virtual Machine and providing method level access
+ * to its contents.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public abstract class AbstractPerfDataBuffer {
+
+ /**
+ * Reference to the concrete instance created by the
+ * {@link #createPerfDataBuffer} method.
+ */
+ protected PerfDataBufferImpl impl;
+
+ /**
+ * Get the Local Java Virtual Machine Identifier, or <em>lvmid</em>
+ * for the target JVM associated with this instrumentation buffer.
+ *
+ * @return int - the lvmid
+ */
+ public int getLocalVmId() {
+ return impl.getLocalVmId();
+ }
+
+ /**
+ * Get a copy of the raw instrumentation data.
+ * This method is used to get a copy of the current bytes in the
+ * instrumentation buffer. It is generally used for transporting
+ * those bytes over the network.
+ *
+ * @return byte[] - a copy of the bytes in the instrumentation buffer.
+ */
+ public byte[] getBytes() {
+ return impl.getBytes();
+ }
+
+ /**
+ * Get the capacity of the instrumentation buffer.
+ *
+ * @return int - the capacity, or size, of the instrumentation buffer.
+ */
+ public int getCapacity() {
+ return impl.getCapacity();
+ }
+
+ /**
+ * Find a named Instrumentation object.
+ *
+ * This method will look for the named instrumentation object in the
+ * instrumentation exported by this Java Virtual Machine. If an
+ * instrumentation object with the given name exists, a Monitor interface
+ * to that object will be return. Otherwise, the method returns
+ * {@code null}.
+ *
+ * @param name the name of the Instrumentation object to find.
+ * @return Monitor - the {@link Monitor} object that can be used to
+ * monitor the named instrumentation object, or
+ * {@code null} if the named object doesn't exist.
+ * @throws MonitorException Thrown if an error occurs while communicating
+ * with the target Java Virtual Machine.
+ */
+ public Monitor findByName(String name) throws MonitorException {
+ return impl.findByName(name);
+ }
+
+ /**
+ * Find all Instrumentation objects with names matching the given pattern.
+ *
+ * This method returns a {@link List} of Monitor objects such that
+ * the name of each object matches the given pattern.
+ *
+ * @param patternString a string containing a pattern as described in
+ * {@link java.util.regex.Pattern}.
+ * @return {@code List<Monitor>} - a List of {@link Monitor}
+ * objects that can be used to
+ * monitor the instrumentation objects whose names match
+ * the given pattern. If no instrumentation objects have`
+ * names matching the given pattern, then an empty List
+ * is returned.
+ * @throws MonitorException Thrown if an error occurs while communicating
+ * with the target Java Virtual Machine.
+ * @see java.util.regex.Pattern
+ */
+ public List<Monitor> findByPattern(String patternString) throws MonitorException {
+ return impl.findByPattern(patternString);
+ }
+
+ /**
+ * Get a list of the inserted and removed monitors since last called.
+ *
+ * @return MonitorStatus - the status of available Monitors for the
+ * target Java Virtual Machine.
+ * @throws MonitorException Thrown if communications errors occur
+ * while communicating with the target.
+ */
+ public MonitorStatus getMonitorStatus() throws MonitorException {
+ return impl.getMonitorStatus();
+ }
+
+ /**
+ * Get the ByteBuffer containing the instrumentation data.
+ *
+ * @return ByteBuffer - a ByteBuffer object that refers to the
+ * instrumentation data.
+ */
+ public ByteBuffer getByteBuffer() {
+ return impl.getByteBuffer();
+ }
+
+ /**
+ * Create the perfdata instrumentation buffer for the given lvmid
+ * using the given ByteBuffer object as the source of the instrumentation
+ * data. This method parses the instrumentation buffer header to determine
+ * key characteristics of the instrumentation buffer and then dynamically
+ * loads the appropriate class to handle the particular instrumentation
+ * version.
+ *
+ * @param bb the ByteBuffer that references the instrumentation data.
+ * @param lvmid the Local Java Virtual Machine identifier for this
+ * instrumentation buffer.
+ *
+ * @throws MonitorException
+ */
+ protected void createPerfDataBuffer(ByteBuffer bb, int lvmid)
+ throws MonitorException {
+ int majorVersion = AbstractPerfDataBufferPrologue.getMajorVersion(bb);
+ int minorVersion = AbstractPerfDataBufferPrologue.getMinorVersion(bb);
+
+ // instantiate the version specific class
+ String classname = "sun.jvmstat.perfdata.monitor.v"
+ + majorVersion + "_" + minorVersion
+ + ".PerfDataBuffer";
+
+ try {
+ Class<?> implClass = Class.forName(classname);
+ Constructor<?> cons = implClass.getConstructor(new Class<?>[] {
+ Class.forName("java.nio.ByteBuffer"),
+ Integer.TYPE
+ });
+
+ impl = (PerfDataBufferImpl)cons.newInstance(new Object[] {
+ bb, lvmid
+ });
+
+ } catch (ClassNotFoundException e) {
+ // from Class.forName();
+ throw new IllegalArgumentException(
+ "Could not find " + classname + ": " + e.getMessage(), e);
+
+ } catch (NoSuchMethodException e) {
+ // from Class.getConstructor();
+ throw new IllegalArgumentException(
+ "Expected constructor missing in " + classname + ": "
+ + e.getMessage(), e);
+
+ } catch (IllegalAccessException e) {
+ // from Constructor.newInstance()
+ throw new IllegalArgumentException(
+ "Unexpected constructor access in " + classname + ": "
+ + e.getMessage(), e);
+
+ } catch (InstantiationException e) {
+ throw new IllegalArgumentException(
+ classname + "is abstract: " + e.getMessage(), e);
+
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof MonitorException) {
+ throw (MonitorException)cause;
+ }
+ throw new RuntimeException("Unexpected exception: "
+ + e.getMessage() , e);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBufferPrologue.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.ByteOrder;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+
+/**
+ * Abstraction representing the HotSpot PerfData instrumentation buffer
+ * header. This class represents only the fixed portion of the header.
+ * Version specific classes represent the portion of the header that
+ * may change from release to release.
+ * <p>
+ * The PerfDataBufferProlog class supports parsing of the following
+ * C structure:
+ * <pre>
+ * typedef struct {
+ * jint magic; // magic number - 0xcafec0c0
+ * jbyte byte_order; // byte order of the buffer
+ * jbyte major_version; // major and minor version numbers
+ * jbyte minor_version;
+ * jbyte reserved_byte1; // reserved - see concrete implementations for
+ * // possible definition.
+ * ... // remainder is handled by the subclasses.
+ * } PerfDataPrologue
+ * </pre>
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public abstract class AbstractPerfDataBufferPrologue {
+
+ protected ByteBuffer byteBuffer;
+
+ /*
+ * the following constants must match the field offsets and sizes
+ * in the PerfDataPrologue structure in perfMemory.hpp
+ */
+ final static int PERFDATA_PROLOG_OFFSET=0;
+ final static int PERFDATA_PROLOG_MAGIC_OFFSET=0;
+ final static int PERFDATA_PROLOG_BYTEORDER_OFFSET=4;
+ final static int PERFDATA_PROLOG_BYTEORDER_SIZE=1; // sizeof(byte)
+ final static int PERFDATA_PROLOG_MAJOR_OFFSET=5;
+ final static int PERFDATA_PROLOG_MAJOR_SIZE=1; // sizeof(byte)
+ final static int PERFDATA_PROLOG_MINOR_OFFSET=6;
+ final static int PERFDATA_PROLOG_MINOR_SIZE=1; // sizeof(byte)
+ final static int PERFDATA_PROLOG_RESERVEDB1_OFFSET=7;
+ final static int PERFDATA_PROLOG_RESERVEDB1_SIZE=1; // sizeof(byte)
+
+ final static int PERFDATA_PROLOG_SIZE=8; // sizeof(struct PerfDataProlog)
+
+ // these constants should match their #define counterparts in perfMemory.hpp
+ final static byte PERFDATA_BIG_ENDIAN=0;
+ final static byte PERFDATA_LITTLE_ENDIAN=1;
+ final static int PERFDATA_MAGIC = 0xcafec0c0;
+
+ // names for counters that expose the prolog fields
+ public final static String PERFDATA_MAJOR_NAME =
+ "sun.perfdata.majorVersion";
+ public final static String PERFDATA_MINOR_NAME =
+ "sun.perfdata.minorVersion";
+
+ /**
+ * Construct a PerfDataBufferPrologue instance.
+ *
+ * @param byteBuffer buffer containing the instrumentation data
+ */
+ public AbstractPerfDataBufferPrologue(ByteBuffer byteBuffer)
+ throws MonitorException {
+ this.byteBuffer = byteBuffer.duplicate();
+
+ // the magic number is always stored in big-endian format
+ if (getMagic() != PERFDATA_MAGIC) {
+ throw new MonitorVersionException(
+ "Bad Magic: " + Integer.toHexString(getMagic()));
+ }
+
+ // set the byte order
+ this.byteBuffer.order(getByteOrder());
+ }
+
+ /**
+ * Get the magic number.
+ *
+ * @return int - the magic number
+ */
+ public int getMagic() {
+ // the magic number is always stored in big-endian format
+ ByteOrder order = byteBuffer.order();
+ byteBuffer.order(ByteOrder.BIG_ENDIAN);
+
+ // get the magic number
+ byteBuffer.position(PERFDATA_PROLOG_MAGIC_OFFSET);
+ int magic = byteBuffer.getInt();
+
+ // restore the byte order
+ byteBuffer.order(order);
+ return magic;
+ }
+
+ /**
+ * Get the byte order.
+ *
+ * @return int - the byte order of the instrumentation buffer
+ */
+ public ByteOrder getByteOrder() {
+ // byte order field is byte order independent
+ byteBuffer.position(PERFDATA_PROLOG_BYTEORDER_OFFSET);
+
+ byte byte_order = byteBuffer.get();
+
+ if (byte_order == PERFDATA_BIG_ENDIAN) {
+ return ByteOrder.BIG_ENDIAN;
+ } else {
+ return ByteOrder.LITTLE_ENDIAN;
+ }
+ }
+
+ /**
+ * Get the major version.
+ *
+ * @return int - the major version
+ */
+ public int getMajorVersion() {
+ // major version field is byte order independent
+ byteBuffer.position(PERFDATA_PROLOG_MAJOR_OFFSET);
+ return (int)byteBuffer.get();
+ }
+
+ /**
+ * Get the minor version.
+ *
+ * @return int - the minor version
+ */
+ public int getMinorVersion() {
+ // minor version field is byte order independent
+ byteBuffer.position(PERFDATA_PROLOG_MINOR_OFFSET);
+ return (int)byteBuffer.get();
+ }
+
+ /**
+ * Get the accessible flag. If supported, it indicates that the shared
+ * memory region is sufficiently initialized for client acccess.
+ *
+ * @return boolean - the initialized status
+ * @see #supportsAccessible()
+ */
+ public abstract boolean isAccessible();
+
+ /**
+ * Test if the accessible flag is supported by this version of
+ * the PerfDataBufferPrologue. Although not an abstract method, this
+ * method should be overridden by version specific subclasses.
+ *
+ * @return boolean - the initialized flag support status.
+ * @see #isAccessible()
+ */
+ public abstract boolean supportsAccessible();
+
+ /**
+ * Get the size of the header portion of the instrumentation buffer.
+ *
+ * @return int - the size of the header
+ */
+ public int getSize() {
+ return PERFDATA_PROLOG_SIZE; // sizeof(struct PerfDataProlog)
+ }
+
+ /**
+ * Return an IntBuffer that accesses the major version number.
+ * This is used to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the major version number
+ * in the instrumentation buffer header.
+ */
+ public IntBuffer majorVersionBuffer() {
+ int[] holder = new int[1];
+ holder[0] = getMajorVersion();
+ IntBuffer ib = IntBuffer.wrap(holder);
+ ib.limit(1);
+ return ib;
+ }
+
+ /**
+ * Return an IntBuffer that accesses the minor version number.
+ * This is used to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the minor version number
+ * in the instrumentation buffer header.
+ */
+ public IntBuffer minorVersionBuffer() {
+ int[] holder = new int[1];
+ holder[0] = getMinorVersion();
+ IntBuffer ib = IntBuffer.wrap(holder);
+ ib.limit(1);
+ return ib;
+ }
+
+ /**
+ * Get the magic number from the given byteBuffer.
+ *
+ * @return int - the magic number
+ */
+ public static int getMagic(ByteBuffer bb) {
+ // save buffer state
+ int position = bb.position();
+ ByteOrder order = bb.order();
+
+ // the magic number is always stored in big-endian format
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.position(PERFDATA_PROLOG_MAGIC_OFFSET);
+ int magic = bb.getInt();
+
+ // restore buffer state.
+ bb.order(order);
+ bb.position(position);
+
+ return magic;
+ }
+
+ /**
+ * Get the major version number from the given ByteBuffer.
+ *
+ * @return int - the major version
+ */
+ public static int getMajorVersion(ByteBuffer bb) {
+ // save buffer state
+ int position = bb.position();
+
+ bb.position(PERFDATA_PROLOG_MAJOR_OFFSET);
+ int major = (int) bb.get();
+
+ // restore buffer state.
+ bb.position(position);
+
+ return major;
+ }
+
+ /**
+ * Get the minor version number from the given ByteBuffer.
+ *
+ * @return int - the minor version
+ */
+ public static int getMinorVersion(ByteBuffer bb) {
+ // save buffer state
+ int position = bb.position();
+
+ bb.position(PERFDATA_PROLOG_MINOR_OFFSET);
+ int minor = (int)bb.get();
+
+ // restore buffer state.
+ bb.position(position);
+
+ return minor;
+ }
+
+ /**
+ * Get the byte order for the given ByteBuffer.
+ *
+ * @return int - the byte order of the instrumentation buffer
+ */
+ public static ByteOrder getByteOrder(ByteBuffer bb) {
+ // save buffer state
+ int position = bb.position();
+
+ bb.position(PERFDATA_PROLOG_BYTEORDER_OFFSET);
+ ByteOrder order = (bb.get() == PERFDATA_BIG_ENDIAN)
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN;
+
+ // restore buffer state.
+ bb.position(position);
+ return order;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+/**
+ * Class for parsing alias files. File format is expected to follow
+ * the following syntax:
+ *
+ * alias name [alias]*
+ *
+ * Java style comments can occur anywhere within the file.
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class AliasFileParser {
+ private static final String ALIAS = "alias";
+ // 8028357 removed old, inefficient debug logging
+
+ // other variables
+ private URL inputfile;
+ private StreamTokenizer st;
+ private Token currentToken;
+
+ AliasFileParser(URL inputfile) {
+ this.inputfile = inputfile;
+ }
+
+ // value class to hold StreamTokenizer token values
+ private class Token {
+ public String sval;
+ public int ttype;
+
+ public Token(int ttype, String sval) {
+ this.ttype = ttype;
+ this.sval = sval;
+ }
+ }
+
+ /**
+ * method to get the next token as a Token type
+ */
+ private void nextToken() throws IOException {
+ st.nextToken();
+ currentToken = new Token(st.ttype, st.sval);
+ }
+
+ /**
+ * method to match the current Token to a specified token type and
+ * value Throws a SyntaxException if token doesn't match.
+ */
+ private void match(int ttype, String token)
+ throws IOException, SyntaxException {
+
+ if ((currentToken.ttype == ttype)
+ && (currentToken.sval.compareTo(token) == 0)) {
+ nextToken();
+ } else {
+ throw new SyntaxException(st.lineno());
+ }
+ }
+
+
+ /*
+ * method to match the current Token to a specified token type.
+ * Throws a SyntaxException if token doesn't match.
+ */
+ private void match(int ttype) throws IOException, SyntaxException {
+ if (currentToken.ttype == ttype) {
+ nextToken();
+ } else {
+ throw new SyntaxException(st.lineno());
+ }
+ }
+
+ private void match(String token) throws IOException, SyntaxException {
+ match(StreamTokenizer.TT_WORD, token);
+ }
+
+ /**
+ * method to parse the given input file.
+ */
+ public void parse(Map<String, ArrayList<String>> map) throws SyntaxException, IOException {
+
+ if (inputfile == null) {
+ return;
+ }
+
+ BufferedReader r = new BufferedReader(
+ new InputStreamReader(inputfile.openStream()));
+ st = new StreamTokenizer(r);
+
+ // allow both forms of commenting styles
+ st.slashSlashComments(true);
+ st.slashStarComments(true);
+ st.wordChars('_','_');
+
+ nextToken();
+
+ while (currentToken.ttype != StreamTokenizer.TT_EOF) {
+ // look for the start symbol
+ if ((currentToken.ttype != StreamTokenizer.TT_WORD)
+ || (currentToken.sval.compareTo(ALIAS) != 0)) {
+ nextToken();
+ continue;
+ }
+
+ match(ALIAS);
+ String name = currentToken.sval;
+ match(StreamTokenizer.TT_WORD);
+
+ ArrayList<String> aliases = new ArrayList<String>();
+
+ do {
+ aliases.add(currentToken.sval);
+ match(StreamTokenizer.TT_WORD);
+
+ } while ((currentToken.ttype != StreamTokenizer.TT_EOF)
+ && (currentToken.sval.compareTo(ALIAS) != 0));
+
+ map.put(name, aliases);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTask.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import java.util.*;
+
+/**
+ * A TimerTask subclass that keeps a count of the number of executions
+ * of the task.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class CountedTimerTask extends TimerTask {
+
+ volatile long executionCount;
+
+ public long executionCount() {
+ return executionCount;
+ }
+
+ public void run() {
+ executionCount++;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import java.util.*;
+
+/**
+ * Utility methods for use with {@link CountedTimerTask} instances.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class CountedTimerTaskUtils {
+
+ // 8028357 removed old, inefficient debug logging
+
+ /**
+ * Reschedule a CountedTimeTask at a different interval. Probably not
+ * named correctly. This method cancels the old task and computes the
+ * delay for starting the new task based on the new interval and the
+ * time at which the old task was last executed.
+ *
+ * @param timer the Timer for the task
+ * @param oldTask the old Task
+ * @param newTask the new Task
+ * @param oldInterval the old interval; use for debugging output
+ * purposes only.
+ * @param newInterval scheduling interval in milliseconds
+ */
+ public static void reschedule(Timer timer, CountedTimerTask oldTask,
+ CountedTimerTask newTask, int oldInterval,
+ int newInterval) {
+
+ long now = System.currentTimeMillis();
+ long lastRun = oldTask.scheduledExecutionTime();
+ long expired = now - lastRun;
+
+ /*
+ * check if original task ever ran - if not, then lastRun is
+ * undefined and we simply set the delay to 0.
+ */
+ long delay = 0;
+ if (oldTask.executionCount() > 0) {
+ long remainder = newInterval - expired;
+ delay = remainder >= 0 ? remainder : 0;
+ }
+
+ timer.schedule(newTask, delay, newInterval);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorDataException.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.MonitorException;
+
+/**
+ * Exception indicating that improperly formatted data was encountered
+ * while parsing a HotSpot PerfData buffer.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class MonitorDataException extends MonitorException {
+
+ /**
+ * Constructs a <code>MonitorDataException</code> with <code>
+ * null</code> as its error detail message.
+ */
+ public MonitorDataException() {
+ super();
+ }
+
+ /**
+ * Constructs an <code>MonitorDataException</code> with the specified
+ * detail message. The error message string <code>s</code> can later be
+ * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
+ * method of class <code>java.lang.Throwable</code>.
+ *
+ * @param s the detail message.
+ */
+ public MonitorDataException(String s) {
+ super(s);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorStatus.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import java.util.List;
+import sun.jvmstat.monitor.Monitor;
+
+/**
+ * Immutable class containing the list of inserted and deleted
+ * monitors over an arbitrary time period.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class MonitorStatus {
+
+ /**
+ * The list of Monitors inserted since the last query.
+ */
+ protected List<Monitor> inserted;
+
+ /**
+ * The list of Monitors removed since the last query.
+ */
+ protected List<Monitor> removed;
+
+ /**
+ * Create a MonitorStatus instance.
+ *
+ * @param inserted the list of Monitors inserted
+ * @param removed the list of Monitors removed
+ */
+ public MonitorStatus(List<Monitor> inserted, List<Monitor> removed) {
+ this.inserted = inserted;
+ this.removed = removed;
+ }
+
+ /**
+ * Get the list of Monitors inserted since the last query.
+ *
+ * @return List - the List of Monitor objects inserted or an empty List.
+ */
+ public List<Monitor> getInserted() {
+ return inserted;
+ }
+
+ /**
+ * Get the list of Monitors removed since the last query.
+ *
+ * @return List - the List of Monitor objects removed or an empty List.
+ */
+ public List<Monitor> getRemoved() {
+ return removed;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorStructureException.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.MonitorException;
+
+/**
+ * Exception indicating that improperly formatted data was encountered
+ * while parsing a HotSpot PerfData buffer.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class MonitorStructureException extends MonitorException {
+
+ /**
+ * Constructs a <code>MonitorStructureException</code> with <code>
+ * null</code> as its error detail message.
+ */
+ public MonitorStructureException() {
+ super();
+ }
+
+ /**
+ * Constructs an <code>MonitorStructureException</code> with the specified
+ * detail message. The error message string <code>s</code> can later be
+ * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
+ * method of class <code>java.lang.Throwable</code>.
+ *
+ * @param s the detail message.
+ */
+ public MonitorStructureException(String s) {
+ super(s);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorTypeException.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.MonitorException;
+
+/**
+ * Exception indicating that an unexpected type was encountered for
+ * the type field of a PerfData entry in a HotSpot PerfData buffer.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class MonitorTypeException extends MonitorException {
+
+ /**
+ * Constructs a <code>MonitorTypeException</code> with <code>
+ * null </code> as its error detail message.
+ */
+ public MonitorTypeException() {
+ super();
+ }
+
+ /**
+ * Constructs an <code>MonitorTypeException</code> with the specified
+ * detail message. The error message string <code>s</code> can later be
+ * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
+ * method of class <code>java.lang.Throwable</code>.
+ *
+ * @param s the detail message.
+ */
+ public MonitorTypeException(String s) {
+ super(s);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorVersionException.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.MonitorException;
+
+/**
+ * Exception thrown when version of the implementation does not
+ * match the version of the instrumentation exported by a target
+ * Java Virtual Machine.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class MonitorVersionException extends MonitorException {
+
+ /**
+ * Create a MonitorVersionException
+ */
+ public MonitorVersionException() {
+ super();
+ }
+
+ /**
+ * Create a MonitorVersionException with the given message.
+ *
+ * @param message the message to associate with the exception.
+ */
+ public MonitorVersionException(String message) {
+ super(message);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.ByteBuffer;
+
+/**
+ * Class for monitoring a PerfData Byte Array instrumentation object.
+ *
+ * This class is provided to support the PerfStringMonitor classes.
+ * Instrumentation objects of this direct type currently cannot be
+ * created or monitored.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see sun.jvmstat.instrument.ByteArrayInstrument
+ */
+public class PerfByteArrayMonitor extends AbstractMonitor
+ implements ByteArrayMonitor {
+
+ /**
+ * The buffer containing the data for the byte array instrument.
+ */
+ ByteBuffer bb;
+
+ /**
+ * Constructor to create a ByteArrayMonitor for the byte array instrument
+ * represented by the data in the given buffer.
+ *
+ * @param name the name of the instrumentation object
+ * @param u the units of measure attribute
+ * @param v the variability attribute
+ * @param supported support level indicator
+ * @param bb the buffer containing the byte array instrument data
+ * @param vectorLength the length of the vector.
+ */
+ public PerfByteArrayMonitor(String name, Units u, Variability v,
+ boolean supported, ByteBuffer bb,
+ int vectorLength) {
+ super(name, u, v, supported, vectorLength);
+ this.bb = bb;
+ }
+
+ /**
+ * {@inheritDoc}
+ * The object returned contains a byte[] with a copy of the current
+ * elements of the ByteArrayInstrument.
+ *
+ * @return Object - a copy of the current value of the elements of the
+ * byte array instrument. The return type is guaranteed
+ * to be of type byte[].
+ */
+ public Object getValue() {
+ return byteArrayValue();
+ }
+
+ /**
+ * Get a copy of the elements of the byte array instrument.
+ *
+ * @return byte[] - a copy of the current value of the elements of the
+ * byte array instrument.
+ */
+ public byte[] byteArrayValue() {
+ bb.position(0);
+ byte[] b = new byte[bb.limit()];
+
+ // copy the bytes
+ bb.get(b);
+
+ return b;
+ }
+
+ /**
+ * Get the current value of an element of the byte array instrument.
+ *
+ * @return byte - a copy of the current value of the element at index
+ * {@code index} of the byte array instrument.
+ */
+ public byte byteAt(int index) {
+ bb.position(index);
+ return bb.get();
+ }
+
+ /**
+ * Get the maximum length of the byte array for this byte array instrument.
+ *
+ * @return int - the maximum length of the byte array.
+ */
+ public int getMaximumLength() {
+ return bb.limit();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,358 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.util.*;
+import java.nio.*;
+import java.io.*;
+import java.net.*;
+import java.util.regex.*;
+
+/**
+ * The base classes for the concrete implementations of the HotSpot
+ * PerfData instrumentation buffer.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see AbstractPerfDataBuffer
+ */
+public abstract class PerfDataBufferImpl {
+
+ /**
+ * The buffer containing the instrumentation data.
+ */
+ protected ByteBuffer buffer;
+
+ /**
+ * A Map of monitor objects found in the instrumentation buffer.
+ */
+ protected Map<String, Monitor> monitors;
+
+ /**
+ * The Local Java Virtual Machine Identifier for this buffer.
+ */
+ protected int lvmid;
+
+ /**
+ * A Map of monitor object names to aliases as read in from the alias map
+ * file.
+ */
+ protected Map<String, ArrayList<String>> aliasMap;
+
+ /**
+ * A cache of resolved monitor aliases.
+ */
+ protected Map<String, Monitor> aliasCache;
+
+
+ /**
+ * Constructor.
+ *
+ * @param buffer the ByteBuffer containing the instrumentation data.
+ * @param lvmid the Local Java Virtual Machine Identifier for this
+ * instrumentation buffer.
+ */
+ protected PerfDataBufferImpl(ByteBuffer buffer, int lvmid) {
+ this.buffer = buffer;
+ this.lvmid = lvmid;
+ this.monitors = new TreeMap<>();
+ this.aliasMap = new HashMap<>();
+ this.aliasCache = new HashMap<>();
+ }
+
+ /**
+ * Get the Local Java Virtual Machine Identifier, or <em>lvmid</em>
+ * for the target JVM associated with this instrumentation buffer.
+ *
+ * @return int - the lvmid
+ */
+ public int getLocalVmId() {
+ return lvmid;
+ }
+
+ /**
+ * Get a copy of the raw instrumentation data.
+ * This method is used to get a copy of the current bytes in the
+ * instrumentation buffer. It is generally used for transporting
+ * those bytes over the network.
+ *
+ * @return byte[] - a copy of the bytes in the instrumentation buffer.
+ */
+ public byte[] getBytes() {
+ ByteBuffer bb = null;
+ synchronized (this) {
+ /*
+ * this operation is potentially time consuming, and the result
+ * is unused when the getBytes() interface is used. However, the
+ * call is necessary in order to synchronize this monitoring
+ * client with the target jvm, which assures that the receiver
+ * of the byte[] gets an image that is initialized to a usable
+ * state. Otherwise, they might only get a snapshot of an
+ * empty instrumentation buffer immediately after it was created.
+ */
+ try {
+ if (monitors.isEmpty()) {
+ buildMonitorMap(monitors);
+ }
+ } catch (MonitorException e) {
+ /*
+ * just ignore this here and let the receiver of the
+ * byte[] detect and handle the problem.
+ */
+ }
+ bb = buffer.duplicate();
+ }
+ bb.rewind();
+ byte[] bytes = new byte[bb.limit()];
+ bb.get(bytes);
+ return bytes;
+ }
+
+ /**
+ * Get the capacity of the instrumentation buffer.
+ *
+ * @return int - the capacity, or size, of the instrumentation buffer.
+ */
+ public int getCapacity() {
+ return buffer.capacity();
+ }
+
+ /**
+ * Get the ByteBuffer containing the instrumentation data.
+ *
+ * @return ByteBuffer - a ByteBuffer object that refers to the
+ * instrumentation data.
+ */
+ ByteBuffer getByteBuffer() {
+ // receiver is responsible for assuring that the buffer's state
+ // is that of an initialized target.
+ return buffer;
+ }
+
+ /**
+ * Build the alias mapping. Uses the default alias map file unless
+ * the sun.jvmstat.perfdata.aliasmap file indicates some other
+ * file as the source.
+ */
+ @SuppressWarnings("deprecation")
+ private void buildAliasMap() {
+ assert Thread.holdsLock(this);
+
+ URL aliasURL = null;
+ String filename = System.getProperty("sun.jvmstat.perfdata.aliasmap");
+
+ if (filename != null) {
+ File f = new File(filename);
+ try {
+ aliasURL = f.toURL();
+
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ aliasURL = getClass().getResource(
+ "/sun/jvmstat/perfdata/resources/aliasmap");
+ }
+
+ assert aliasURL != null;
+
+ AliasFileParser aliasParser = new AliasFileParser(aliasURL);
+
+ try {
+ aliasParser.parse(aliasMap);
+
+ } catch (IOException e) {
+ System.err.println("Error processing " + filename + ": "
+ + e.getMessage());
+ } catch (SyntaxException e) {
+ System.err.println("Syntax error parsing " + filename + ": "
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * Find the Monitor object for the named counter by using one of its
+ * aliases.
+ */
+ protected Monitor findByAlias(String name) {
+ assert Thread.holdsLock(this);
+
+ Monitor m = aliasCache.get(name);
+ if (m == null) {
+ ArrayList<String> al = aliasMap.get(name);
+ if (al != null) {
+ for (Iterator<String> i = al.iterator(); i.hasNext() && m == null; ) {
+ String alias = i.next();
+ m = monitors.get(alias);
+ }
+ }
+ }
+ return m;
+ }
+
+
+ /**
+ * Find a named Instrumentation object.
+ *
+ * This method will look for the named instrumentation object in the
+ * instrumentation exported by this Java Virtual Machine. If an
+ * instrumentation object with the given name exists, a Monitor interface
+ * to that object will be return. Otherwise, the method returns
+ * {@code null}. The method will map requests for instrumention objects
+ * using old names to their current names, if applicable.
+ *
+ *
+ *
+ * @param name the name of the Instrumentation object to find.
+ * @return Monitor - the {@link Monitor} object that can be used to
+ * monitor the named instrumentation object, or
+ * {@code null} if the named object doesn't exist.
+ * @throws MonitorException Thrown if an error occurs while communicating
+ * with the target Java Virtual Machine.
+ */
+ public Monitor findByName(String name) throws MonitorException {
+ Monitor m = null;
+
+ synchronized (this) {
+ if (monitors.isEmpty()) {
+ buildMonitorMap(monitors);
+ buildAliasMap();
+ }
+
+ // look for the requested monitor
+ m = monitors.get(name);
+ if (m == null) {
+ // not found - load any new monitors, and try again.
+ getNewMonitors(monitors);
+ m = monitors.get(name);
+ }
+ if (m == null) {
+ // still not found, look for aliases
+ m = findByAlias(name);
+ }
+ }
+ return m;
+ }
+
+ /**
+ * Find all Instrumentation objects with names matching the given pattern.
+ *
+ * This method returns a {@link List} of Monitor objects such that
+ * the name of each object matches the given pattern.
+ *
+ * @param patternString a string containing a pattern as described in
+ * {@link java.util.regex.Pattern}.
+ * @return {@code List<Monitor>} - a List of {@link Monitor}
+ * objects that can be used to
+ * monitor the instrumentation objects whose names match
+ * the given pattern. If no instrumentation objects have`
+ * names matching the given pattern, then an empty List
+ * is returned.
+ * @throws MonitorException Thrown if an error occurs while communicating
+ * with the target Java Virtual Machine.
+ * @see java.util.regex.Pattern
+ */
+ public List<Monitor> findByPattern(String patternString)
+ throws MonitorException, PatternSyntaxException {
+
+ synchronized(this) {
+ if (monitors.isEmpty()) {
+ buildMonitorMap(monitors);
+ } else {
+ getNewMonitors(monitors);
+ }
+ }
+
+ Pattern pattern = Pattern.compile(patternString);
+ Matcher matcher = pattern.matcher("");
+ List<Monitor> matches = new ArrayList<>();
+
+ Set<Map.Entry<String,Monitor>> monitorSet = monitors.entrySet();
+
+ for (Iterator<Map.Entry<String, Monitor>> i = monitorSet.iterator(); i.hasNext(); /* empty */) {
+ Map.Entry<String, Monitor> me = i.next();
+ String name = me.getKey();
+ Monitor m = me.getValue();
+
+ // apply pattern to monitor item name
+ matcher.reset(name);
+
+ // if the pattern matches, then add monitor to list
+ if (matcher.lookingAt()) {
+ matches.add(me.getValue());
+ }
+ }
+ return matches;
+ }
+
+ /**
+ * Get a list of the inserted and removed monitors since last called.
+ *
+ * @return MonitorStatus - the status of available Monitors for the
+ * target Java Virtual Machine.
+ * @throws MonitorException Thrown if communications errors occur
+ * while communicating with the target.
+ */
+ public MonitorStatus getMonitorStatus() throws MonitorException {
+ synchronized(this) {
+ if (monitors.isEmpty()) {
+ buildMonitorMap(monitors);
+ }
+ return getMonitorStatus(monitors);
+ }
+ }
+
+ // PerfDataBuffer implementation specific classes
+
+ /**
+ * get the list of inserted and removed monitors since last called.
+ *
+ * @param m the map of Monitors.
+ * @throws MonitorException Thrown if communications errors occur
+ * while communicating with the target.
+ */
+ protected abstract MonitorStatus getMonitorStatus(Map<String, Monitor> m)
+ throws MonitorException;
+
+ /**
+ * build the map of Monitor objects.
+ *
+ * @param m the map of Monitors.
+ * @throws MonitorException Thrown if communications errors occur
+ * while communicating with the target.
+ */
+ protected abstract void buildMonitorMap(Map<String, Monitor> m) throws MonitorException;
+
+ /**
+ * get the new Monitor objects from the Map of Monitor objects.
+ *
+ * @param m the map of Monitors.
+ * @throws MonitorException Thrown if communications errors occur
+ * while communicating with the target.
+ */
+ protected abstract void getNewMonitors(Map<String, Monitor> m) throws MonitorException;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.IntBuffer;
+
+/**
+ * Class for monitoring a PerfData Integer instrument.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfIntegerMonitor extends AbstractMonitor
+ implements IntegerMonitor {
+
+ /**
+ * The buffer containing the data for the integer instrument.
+ */
+ IntBuffer ib;
+
+ /**
+ * Constructor to create an IntegerMonitor object for the integer
+ * instrument represented by the data in the given buffer.
+ *
+ * @param name the name of the integer instrument
+ * @param u the units of measure attribute
+ * @param v the variability attribute
+ * @param supported support level indicator
+ * @param ib the buffer containing the integer instrument data.
+ */
+ public PerfIntegerMonitor(String name, Units u, Variability v,
+ boolean supported, IntBuffer ib) {
+ super(name, u, v, supported);
+ this.ib = ib;
+ }
+
+ /**
+ * {@inheritDoc}
+ * The object returned contains an Integer object containing the
+ * current value of the IntegerInstrument.
+ *
+ * @return Object - the current value of the IntegerInstrument. The
+ * return type is guaranteed to be of type Integer.
+ */
+ public Object getValue() {
+ return ib.get(0);
+ }
+
+ /**
+ * Return the current value of the IntegerInstrument as an int.
+ *
+ * @return int - a the current value of the IntegerInstrument.
+ */
+ public int intValue() {
+ return ib.get(0);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.LongBuffer;
+
+/**
+ * Class for monitoring a PerfData Long instrument.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfLongMonitor extends AbstractMonitor implements LongMonitor {
+
+ /**
+ * The buffer containing the data for the long instrument.
+ */
+ LongBuffer lb;
+
+ /**
+ * Constructor to create a LongMonitor object for the long instrument
+ * represented by the data in the given buffer.
+ *
+ * @param name the name of the long instrument
+ * @param u the units of measure attribute
+ * @param v the variability attribute
+ * @param supported support level indicator
+ * @param lb the buffer containing the long instrument data.
+ */
+ public PerfLongMonitor(String name, Units u, Variability v,
+ boolean supported, LongBuffer lb) {
+ super(name, u, v, supported);
+ this.lb = lb;
+ }
+
+ /**
+ * {@inheritDoc}
+ * The object returned contains a Long object containing the
+ * current value of the LongInstrument.
+ *
+ * @return Object - the current value of the LongInstrument. The
+ * return type is guaranteed to be of type Long.
+ */
+ public Object getValue() {
+ return Long.valueOf(lb.get(0));
+ }
+
+ /**
+ * Return the current value of the LongInstrument as an long.
+ *
+ * @return long - the current value of the LongInstrument
+ */
+ public long longValue() {
+ return lb.get(0);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.ByteBuffer;
+
+/**
+ * Class for monitoring a constant PerfData String instrument. The
+ * value associated with a constant string instrument is fixed at
+ * the string instrument's creation time. Its value and length never
+ * change.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfStringConstantMonitor extends PerfStringMonitor {
+
+ /**
+ * The cached value of the string instrument.
+ */
+ String data;
+
+ /**
+ * Constructor to create a StringMonitor object for the constant string
+ * instrument object represented by the data in the given buffer.
+ *
+ * @param name the name of the instrumentation object
+ * @param supported support level indicator
+ * @param bb the buffer containing the string instrument data
+ */
+ public PerfStringConstantMonitor(String name, boolean supported,
+ ByteBuffer bb) {
+ super(name, Variability.CONSTANT, supported, bb);
+ this.data = super.stringValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getValue() {
+ return data; // return the cached string
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String stringValue() {
+ return data; // return the cached string
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+/**
+ * Class for monitoring a PerfData String instrument.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfStringMonitor extends PerfByteArrayMonitor
+ implements StringMonitor {
+
+ private static Charset defaultCharset = Charset.defaultCharset();
+
+ /**
+ * Constructor to create a StringMonitor object for the string instrument
+ * represented by the data in the given buffer.
+ *
+ * @param name the name of the string instrument
+ * @param v the variability attribute
+ * @param supported support level indicator
+ * @param bb the buffer containing the string instrument data.
+ */
+ public PerfStringMonitor(String name, Variability v, boolean supported,
+ ByteBuffer bb) {
+ this(name, v, supported, bb, bb.limit());
+ }
+
+ /**
+ * Constructor to create a StringMonitor object for the string instrument
+ * represented by the data in the given buffer.
+ *
+ * @param name the name of the string instrument
+ * @param v the variability attribute
+ * @param supported support level indicator
+ * @param bb the buffer containing the string instrument data.
+ * @param maxLength the maximum length of the string data.
+ */
+ public PerfStringMonitor(String name, Variability v, boolean supported,
+ ByteBuffer bb, int maxLength) {
+ super(name, Units.STRING, v, supported, bb, maxLength);
+ }
+
+ /**
+ * {@inheritDoc}
+ * The object returned contains a String with a copy of the current
+ * value of the StringInstrument.
+ *
+ * @return Object - a copy of the current value of the StringInstrument.
+ * The return value is guaranteed to be of type String.
+ */
+ public Object getValue() {
+ return stringValue();
+ }
+
+ /**
+ * Return the current value of the StringInstrument as a String.
+ *
+ * @return String - a copy of the current value of the StringInstrument.
+ */
+ public String stringValue() {
+ String str = "";
+ byte[] b = byteArrayValue();
+
+ // catch null strings
+ if ((b == null) || (b.length <= 1) || (b[0] == (byte)0)) {
+ return str;
+ }
+
+ int i;
+ for (i = 0; i < b.length && b[i] != (byte)0; i++);
+
+ return new String(b, 0, i, defaultCharset);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import sun.jvmstat.monitor.*;
+import java.nio.ByteBuffer;
+
+/**
+ *
+ * Class for monitoring a variable PerfData String instrument.
+ * The current value of a variable string instrument changes over time.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfStringVariableMonitor extends PerfStringMonitor {
+
+ /**
+ * Constructor to create a StringMonitor object for the variable string
+ * instrument represented by the data in the given buffer.
+ *
+ * @param name the name of the string instrument
+ * @param supported support level indicator
+ * @param bb the buffer containing the string instrument data.
+ */
+ public PerfStringVariableMonitor(String name, boolean supported,
+ ByteBuffer bb) {
+ this(name, supported, bb, bb.limit());
+ }
+
+ /**
+ * Constructor to create a StringMonitor object for the variable
+ * string instrument represented by the data in the given buffer.
+ *
+ * @param name the name of the string instrument
+ * @param bb the buffer containing the string instrument data.
+ * @param supported support level indicator
+ * @param maxLength the maximum length of the string data.
+ */
+ public PerfStringVariableMonitor(String name, boolean supported,
+ ByteBuffer bb, int maxLength) {
+ // account for the null terminator by adding 1 to maxLength
+ super(name, Variability.VARIABLE, supported, bb, maxLength+1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/SyntaxException.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+/**
+ * Class for encapsulating syntax exceptions generated by AliasFileParser.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+@SuppressWarnings("serial") // JDK implementation class
+public class SyntaxException extends Exception {
+ int lineno;
+
+ public SyntaxException(int lineno) {
+ this.lineno = lineno;
+ }
+
+ public String getMessage() {
+ return "syntax error at line " + lineno;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/package.html Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,39 @@
+<!doctype html public "-//IETF//DTD HTML/EN">
+<html>
+<head>
+<!--
+
+
+ Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ particular file as subject to the "Classpath" exception as provided
+ by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+
+-->
+</head>
+<body bgcolor="white">
+<p>
+Provides the monitoring implementation classes that utilize the HotSpot
+PerfData shared memory instrumentation buffer for discovery and monitoring
+of instrumentation exported by a HotSpot Java Virtual Machine.
+</p>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/FileMonitoredVm.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.file;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.monitor.event.VmListener;
+import sun.jvmstat.perfdata.monitor.*;
+import java.util.List;
+import java.lang.reflect.*;
+import java.io.*;
+
+/**
+ * Concrete implementation of the AbstractMonitoredVm class for the
+ * <em>file:</em> protocol for the HotSpot PerfData monitoring implementation.
+ * <p>
+ * This class provides the ability to attach to the instrumentation buffer
+ * (saved or live) of a target Java Virtual Machine by providing a
+ * <em>file</em> URI to a file containing the instrmentation buffer data.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class FileMonitoredVm extends AbstractMonitoredVm {
+
+ /**
+ * Create a FileMonitoredVm instance.
+ *
+ * @param vmid the vm identifier referring to the file
+ * @param interval sampling interval (unused in this protocol).
+ */
+ public FileMonitoredVm(VmIdentifier vmid, int interval)
+ throws MonitorException {
+ super(vmid, interval);
+ this.pdb = new PerfDataBuffer(vmid);
+ }
+
+ /**
+ * {@inheritDoc}.
+ *<p>
+ * Note - the <em>file:</em> protocol currently does not support
+ * the registration or notification of listeners.
+ */
+ public void addVmListener(VmListener l) { }
+
+ /**
+ * {@inheritDoc}.
+ *<p>
+ * Note - the <em>file:</em> protocol currently does not support
+ * the registration or notification of listeners.
+ */
+ public void removeVmListener(VmListener l) { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/MonitoredHostFileService.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.file;
+
+import sun.jvmstat.monitor.HostIdentifier;
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredHostService;
+
+public final class MonitoredHostFileService implements MonitoredHostService {
+
+ @Override
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId)
+ throws MonitorException {
+ return new MonitoredHostProvider(hostId);
+ }
+
+ @Override
+ public String getScheme() {
+ return "file";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/MonitoredHostProvider.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.file;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.monitor.event.HostListener;
+import sun.jvmstat.perfdata.monitor.*;
+import java.util.*;
+import java.net.*;
+
+/**
+ * Concrete implementation of the MonitoredHost interface for the
+ * <em>file:</em> protocol of the HotSpot PerfData monitoring implementation.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class MonitoredHostProvider extends MonitoredHost {
+
+ /**
+ * The default polling interval. Not used by the <em>file:</em> protocol.
+ */
+ public static final int DEFAULT_POLLING_INTERVAL = 0;
+
+ /**
+ * Create a MonitoredHostProvider instance using the given HostIdentifier.
+ *
+ * @param hostId the host identifier for this MonitoredHost
+ */
+ public MonitoredHostProvider(HostIdentifier hostId) {
+ this.hostId = hostId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public MonitoredVm getMonitoredVm(VmIdentifier vmid)
+ throws MonitorException {
+ return getMonitoredVm(vmid, DEFAULT_POLLING_INTERVAL);
+ }
+
+ /**
+ * {@inheritDoc}.
+ * <p>
+ * Note - the <em>file:</em> protocol silently ignores the
+ * {@code interval} parameter.
+ */
+ public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval)
+ throws MonitorException {
+ // don't attempt to resolve 'file:' based vmid
+ return new FileMonitoredVm(vmid, interval);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void detach(MonitoredVm vm) {
+ vm.detach();
+ }
+
+ /**
+ * {@inheritDoc}.
+ * <p>
+ * Note - the <em>file:</em> protocol currenly does not support
+ * registration or notification of event listeners. This method
+ * silently ignores the add request.
+ */
+ public void addHostListener(HostListener listener) {
+ // no HostListener support for 'file:' based VmIdentifiers
+ }
+
+ /**
+ * {@inheritDoc}.
+ * <p>
+ * Note - the <em>file:</em> protocol currenly does not support
+ * registration or notification of event listeners. This method
+ * silently ignores the remove request.
+ */
+ public void removeHostListener(HostListener listener) {
+ // no HostListener support for 'file:' based VmIdentifiers
+ }
+
+ /**
+ * {@inheritDoc}.
+ * <p>
+ * Note - the <em>file:</em> protocol currently does not support the
+ * notion of tracking active or inactive Java Virtual Machines. This
+ * method currently returns an empty set.
+ */
+ public Set<Integer> activeVms() {
+ return new HashSet<Integer>(0);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/PerfDataBuffer.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.file;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.io.*;
+import java.net.URI;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+/**
+ * The concrete PerfDataBuffer implementation for the <em>file:</em>
+ * protocol for the HotSpot PerfData monitoring implemetation.
+ * <p>
+ * This class is responsible for acquiring access to the instrumentation
+ * buffer stored in a file referenced by a file URI.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfDataBuffer extends AbstractPerfDataBuffer {
+
+ /**
+ * Create a PerfDataBuffer instance for accessing the specified
+ * instrumentation buffer.
+ *
+ * @param vmid the <em>file:</em> URI to the instrumentation buffer file
+ *
+ * @throws MonitorException
+ */
+ public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
+ File f = new File(vmid.getURI());
+ String mode = vmid.getMode();
+
+ try {
+ FileChannel fc = new RandomAccessFile(f, mode).getChannel();
+ ByteBuffer bb = null;
+
+ if (mode.compareTo("r") == 0) {
+ bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L, (int)fc.size());
+ } else if (mode.compareTo("rw") == 0) {
+ bb = fc.map(FileChannel.MapMode.READ_WRITE, 0L, (int)fc.size());
+ } else {
+ throw new IllegalArgumentException("Invalid mode: " + mode);
+ }
+
+ fc.close(); // doesn't need to remain open
+
+ createPerfDataBuffer(bb, 0);
+ } catch (FileNotFoundException e) {
+ throw new MonitorException("Could not find " + vmid.toString());
+ } catch (IOException e) {
+ throw new MonitorException("Could not read " + vmid.toString());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/package.html Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,38 @@
+<!doctype html public "-//IETF//DTD HTML/EN">
+<html>
+<head>
+<!--
+
+
+ Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ particular file as subject to the "Classpath" exception as provided
+ by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+
+-->
+</head>
+<body bgcolor="white">
+<p>
+Provides the implementation classes for the <em>file:</em> protocol for
+the HotSpot PerfData instrumentation buffer monitoring implementation.
+</p>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalEventTimer.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.MonitorStatus;
+import java.util.*;
+import java.util.regex.*;
+import java.io.*;
+
+/**
+ * Singleton Timer subclass to run polling tasks that generate events
+ * for local Java Virtual Machines..
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class LocalEventTimer extends Timer {
+ private static LocalEventTimer instance; // singleton instance
+
+ /**
+ * Creates the singleton LocalEventTimer instance.
+ */
+ private LocalEventTimer() {
+ super(true);
+ }
+
+ /**
+ * Get the singleton LocalEventTimer instance
+ *
+ * @return LocalEventTimer - the singleton LocalEventTimer instance
+ */
+ public static synchronized LocalEventTimer getInstance() {
+ if (instance == null) {
+ instance = new LocalEventTimer();
+ }
+ return instance;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import java.util.*;
+import java.lang.reflect.*;
+import java.io.*;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.monitor.event.*;
+import sun.jvmstat.perfdata.monitor.*;
+
+/**
+ * Concrete implementation of the AbstractMonitoredVm class for the
+ * <em>local:</em> protocol for the HotSpot PerfData monitoring implementation.
+ * <p>
+ * This class provides the ability to attach to the instrumentation buffer
+ * of a live target Java Virtual Machine through a HotSpot specific attach
+ * mechanism.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class LocalMonitoredVm extends AbstractMonitoredVm {
+
+ /**
+ * List of registered listeners.
+ */
+ private ArrayList<VmListener> listeners;
+
+ /**
+ * Task performing listener notification.
+ */
+ private NotifierTask task;
+
+ /**
+ * Create a LocalMonitoredVm instance.
+ *
+ * @param vmid the vm identifier specifying the target JVM
+ * @param interval the sampling interval
+ */
+ public LocalMonitoredVm(VmIdentifier vmid, int interval)
+ throws MonitorException {
+ super(vmid, interval);
+ this.pdb = new PerfDataBuffer(vmid);
+ listeners = new ArrayList<VmListener>();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ public void detach() {
+ if (interval > 0) {
+ /*
+ * if the notifier task is running, stop it, otherwise it can
+ * access non-existent memory once we've detached from the
+ * underlying buffer.
+ */
+ if (task != null) {
+ task.cancel();
+ task = null;
+ }
+ }
+ super.detach();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ public void addVmListener(VmListener l) {
+ synchronized(listeners) {
+ listeners.add(l);
+ if (task == null) {
+ task = new NotifierTask();
+ LocalEventTimer timer = LocalEventTimer.getInstance();
+ timer.schedule(task, interval, interval);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ public void removeVmListener(VmListener l) {
+ synchronized(listeners) {
+ listeners.remove(l);
+ if (listeners.isEmpty() && task != null) {
+ task.cancel();
+ task = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ public void setInterval(int newInterval) {
+ synchronized(listeners) {
+ if (newInterval == interval) {
+ return;
+ }
+
+ int oldInterval = interval;
+ super.setInterval(newInterval);
+
+ if (task != null) {
+ task.cancel();
+ NotifierTask oldTask = task;
+ task = new NotifierTask();
+ LocalEventTimer timer = LocalEventTimer.getInstance();
+ CountedTimerTaskUtils.reschedule(timer, oldTask, task,
+ oldInterval, newInterval);
+ }
+ }
+ }
+
+ /**
+ * Fire MonitoredVmStructureChanged events.
+ *
+ * @param inserted List of Monitor objects inserted.
+ * @param removed List of Monitor objects removed.
+ */
+ @SuppressWarnings("unchecked") // Cast of result of clone
+ void fireMonitorStatusChangedEvents(List<Monitor> inserted, List<Monitor> removed) {
+ MonitorStatusChangeEvent ev = null;
+ ArrayList<VmListener> registered = null;
+
+ synchronized (listeners) {
+ registered = (ArrayList)listeners.clone();
+ }
+
+ for (Iterator<VmListener> i = registered.iterator(); i.hasNext(); /* empty */) {
+ VmListener l = i.next();
+ // lazily create the event object;
+ if (ev == null) {
+ ev = new MonitorStatusChangeEvent(this, inserted, removed);
+ }
+ l.monitorStatusChanged(ev);
+ }
+ }
+
+ /**
+ * Fire MonitoredUpdated events.
+ */
+ void fireMonitorsUpdatedEvents() {
+ VmEvent ev = null;
+ ArrayList<VmListener> registered = null;
+
+ synchronized (listeners) {
+ registered = cast(listeners.clone());
+ }
+
+ for (VmListener l : registered) {
+ // lazily create the event object;
+ if (ev == null) {
+ ev = new VmEvent(this);
+ }
+ l.monitorsUpdated(ev);
+ }
+ }
+
+ /**
+ * Class to notify listeners of Monitor related events for
+ * the target JVM.
+ */
+ private class NotifierTask extends CountedTimerTask {
+ public void run() {
+ super.run();
+ try {
+ MonitorStatus status = getMonitorStatus();
+ List<Monitor> inserted = status.getInserted();
+ List<Monitor> removed = status.getRemoved();
+
+ if (!inserted.isEmpty() || !removed.isEmpty()) {
+ fireMonitorStatusChangedEvents(inserted, removed);
+ }
+ fireMonitorsUpdatedEvents();
+ } catch (MonitorException e) {
+ // XXX: use logging api
+ System.err.println("Exception updating monitors for "
+ + getVmIdentifier());
+ e.printStackTrace();
+ }
+ }
+ }
+ // Suppress unchecked cast warning msg.
+ @SuppressWarnings("unchecked")
+ static <T> T cast(Object x) {
+ return (T) x;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2004, 2007, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.monitor.event.*;
+import java.util.*;
+import java.util.regex.*;
+import java.io.*;
+
+/**
+ * Class for managing the LocalMonitoredVm instances on the local system.
+ * <p>
+ * This class is responsible for the mechanism that detects the active
+ * HotSpot Java Virtual Machines on the local host and possibly for a
+ * specific user. The ability to detect all possible HotSpot Java Virtual
+ * Machines on the local host may be limited by the permissions of the
+ * principal running this JVM.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class LocalVmManager {
+ private String userName; // user name for monitored jvm
+ private File tmpdir;
+ private Pattern userPattern;
+ private Matcher userMatcher;
+ private FilenameFilter userFilter;
+ private Pattern filePattern;
+ private Matcher fileMatcher;
+ private FilenameFilter fileFilter;
+ private Pattern tmpFilePattern;
+ private Matcher tmpFileMatcher;
+ private FilenameFilter tmpFileFilter;
+
+ /**
+ * Creates a LocalVmManager instance for the local system.
+ * <p>
+ * Manages LocalMonitoredVm instances for which the principal
+ * has appropriate permissions.
+ */
+ public LocalVmManager() {
+ this(null);
+ }
+
+ /**
+ * Creates a LocalVmManager instance for the given user.
+ * <p>
+ * Manages LocalMonitoredVm instances for all JVMs owned by the specified
+ * user.
+ *
+ * @param user the name of the user
+ */
+ public LocalVmManager(String user) {
+ this.userName = user;
+
+ if (userName == null) {
+ tmpdir = new File(PerfDataFile.getTempDirectory());
+ userPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
+ userMatcher = userPattern.matcher("");
+
+ userFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ userMatcher.reset(name);
+ return userMatcher.lookingAt();
+ }
+ };
+ } else {
+ tmpdir = new File(PerfDataFile.getTempDirectory(userName));
+ }
+
+ filePattern = Pattern.compile(PerfDataFile.fileNamePattern);
+ fileMatcher = filePattern.matcher("");
+
+ fileFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ fileMatcher.reset(name);
+ return fileMatcher.matches();
+ }
+ };
+
+ tmpFilePattern = Pattern.compile(PerfDataFile.tmpFileNamePattern);
+ tmpFileMatcher = tmpFilePattern.matcher("");
+
+ tmpFileFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ tmpFileMatcher.reset(name);
+ return tmpFileMatcher.matches();
+ }
+ };
+ }
+
+ /**
+ * Return the current set of monitorable Java Virtual Machines.
+ * <p>
+ * The set returned by this method depends on the user name passed
+ * to the constructor. If no user name was specified, then this
+ * method will return all candidate JVMs on the system. Otherwise,
+ * only the JVMs for the given user will be returned. This assumes
+ * that principal associated with this JVM has the appropriate
+ * permissions to access the target set of JVMs.
+ *
+ * @return Set - the Set of monitorable Java Virtual Machines
+ */
+ public synchronized Set<Integer> activeVms() {
+ /*
+ * This method is synchronized because the Matcher object used by
+ * fileFilter is not safe for concurrent use, and this method is
+ * called by multiple threads. Before this method was synchronized,
+ * we'd see strange file names being matched by the matcher.
+ */
+ Set<Integer> jvmSet = new HashSet<Integer>();
+
+ if (! tmpdir.isDirectory()) {
+ return jvmSet;
+ }
+
+ if (userName == null) {
+ /*
+ * get a list of all of the user temporary directories and
+ * iterate over the list to find any files within those directories.
+ */
+ File[] dirs = tmpdir.listFiles(userFilter);
+
+ for (int i = 0 ; i < dirs.length; i ++) {
+ if (!dirs[i].isDirectory()) {
+ continue;
+ }
+
+ // get a list of files from the directory
+ File[] files = dirs[i].listFiles(fileFilter);
+
+ if (files != null) {
+ for (int j = 0; j < files.length; j++) {
+ if (files[j].isFile() && files[j].canRead()) {
+ jvmSet.add(
+ PerfDataFile.getLocalVmId(files[j]));
+ }
+ }
+ }
+ }
+ } else {
+ /*
+ * Check if the user directory can be accessed. Any of these
+ * conditions may have asynchronously changed between subsequent
+ * calls to this method.
+ */
+
+ // get the list of files from the specified user directory
+ File[] files = tmpdir.listFiles(fileFilter);
+
+ if (files != null) {
+ for (int j = 0; j < files.length; j++) {
+ if (files[j].isFile() && files[j].canRead()) {
+ jvmSet.add(
+ PerfDataFile.getLocalVmId(files[j]));
+ }
+ }
+ }
+ }
+
+ // look for any 1.4.1 files
+ File[] files = tmpdir.listFiles(tmpFileFilter);
+ if (files != null) {
+ for (int j = 0; j < files.length; j++) {
+ if (files[j].isFile() && files[j].canRead()) {
+ jvmSet.add(
+ PerfDataFile.getLocalVmId(files[j]));
+ }
+ }
+ }
+
+ return jvmSet;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostLocalService.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import sun.jvmstat.monitor.HostIdentifier;
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredHostService;
+
+public final class MonitoredHostLocalService implements MonitoredHostService {
+
+ @Override
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId)
+ throws MonitorException {
+ return new MonitoredHostProvider(hostId);
+ }
+
+ @Override
+ public String getScheme() {
+ return "local";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostProvider.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.monitor.event.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.util.*;
+import java.net.*;
+
+/**
+ * Concrete implementation of the MonitoredHost interface for the
+ * <em>local</em> protocol of the HotSpot PerfData monitoring implementation.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class MonitoredHostProvider extends MonitoredHost {
+ private static final int DEFAULT_POLLING_INTERVAL = 1000;
+
+ private ArrayList<HostListener> listeners;
+ private NotifierTask task;
+ private HashSet<Integer> activeVms;
+ private LocalVmManager vmManager;
+
+ /**
+ * Create a MonitoredHostProvider instance using the given HostIdentifier.
+ *
+ * @param hostId the host identifier for this MonitoredHost
+ */
+ public MonitoredHostProvider(HostIdentifier hostId) {
+ this.hostId = hostId;
+ this.listeners = new ArrayList<HostListener>();
+ this.interval = DEFAULT_POLLING_INTERVAL;
+ this.activeVms = new HashSet<Integer>();
+ this.vmManager = new LocalVmManager();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public MonitoredVm getMonitoredVm(VmIdentifier vmid)
+ throws MonitorException {
+ return getMonitoredVm(vmid, DEFAULT_POLLING_INTERVAL);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval)
+ throws MonitorException {
+ try {
+ VmIdentifier nvmid = hostId.resolve(vmid);
+ return new LocalMonitoredVm(nvmid, interval);
+ } catch (URISyntaxException e) {
+ /*
+ * the VmIdentifier is expected to be a valid and it should
+ * resolve reasonably against the host identifier. A
+ * URISyntaxException here is most likely a programming error.
+ */
+ throw new IllegalArgumentException("Malformed URI: "
+ + vmid.toString(), e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void detach(MonitoredVm vm) {
+ vm.detach();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addHostListener(HostListener listener) {
+ synchronized(listeners) {
+ listeners.add(listener);
+ if (task == null) {
+ task = new NotifierTask();
+ LocalEventTimer timer = LocalEventTimer.getInstance();
+ timer.schedule(task, interval, interval);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeHostListener(HostListener listener) {
+ synchronized(listeners) {
+ listeners.remove(listener);
+ if (listeners.isEmpty() && (task != null)) {
+ task.cancel();
+ task = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setInterval(int newInterval) {
+ synchronized(listeners) {
+ if (newInterval == interval) {
+ return;
+ }
+
+ int oldInterval = interval;
+ super.setInterval(newInterval);
+
+ if (task != null) {
+ task.cancel();
+ NotifierTask oldTask = task;
+ task = new NotifierTask();
+ LocalEventTimer timer = LocalEventTimer.getInstance();
+ CountedTimerTaskUtils.reschedule(timer, oldTask, task,
+ oldInterval, newInterval);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<Integer> activeVms() {
+ return vmManager.activeVms();
+ }
+
+ /**
+ * Fire VmEvent events.
+ *
+ * @param active a set of Integer objects containing the vmid of
+ * the active Vms
+ * @param started a set of Integer objects containing the vmid of
+ * new Vms started since last interval.
+ * @param terminated a set of Integer objects containing the vmid of
+ * terminated Vms since last interval.
+ */
+ @SuppressWarnings("unchecked") // Cast of result of clone
+ private void fireVmStatusChangedEvents(Set<Integer> active, Set<Integer> started,
+ Set<Integer> terminated) {
+ ArrayList<HostListener> registered = null;
+ VmStatusChangeEvent ev = null;
+
+ synchronized(listeners) {
+ registered = (ArrayList)listeners.clone();
+ }
+
+ for (Iterator<HostListener> i = registered.iterator(); i.hasNext(); /* empty */) {
+ HostListener l = i.next();
+ if (ev == null) {
+ ev = new VmStatusChangeEvent(this, active, started, terminated);
+ }
+ l.vmStatusChanged(ev);
+ }
+ }
+
+ /**
+ * Class to poll the local system and generate event notifications.
+ */
+ private class NotifierTask extends CountedTimerTask {
+ public void run() {
+ super.run();
+
+ // save the last set of active JVMs
+ Set<Integer> lastActiveVms = activeVms;
+
+ // get the current set of active JVMs
+ activeVms = (HashSet<Integer>)vmManager.activeVms();
+
+ if (activeVms.isEmpty()) {
+ return;
+ }
+ Set<Integer> startedVms = new HashSet<>();
+ Set<Integer> terminatedVms = new HashSet<>();
+
+ for (Iterator<Integer> i = activeVms.iterator(); i.hasNext(); /* empty */) {
+ Integer vmid = i.next();
+ if (!lastActiveVms.contains(vmid)) {
+ // a new file has been detected, add to set
+ startedVms.add(vmid);
+ }
+ }
+
+ for (Iterator<Integer> i = lastActiveVms.iterator(); i.hasNext();
+ /* empty */) {
+ Integer o = i.next();
+ if (!activeVms.contains(o)) {
+ // JVM has terminated, remove it from the active list
+ terminatedVms.add(o);
+ }
+ }
+
+ if (!startedVms.isEmpty() || !terminatedVms.isEmpty()) {
+ fireVmStatusChangedEvents(activeVms, startedVms,
+ terminatedVms);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import jdk.internal.perf.Perf;
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.util.*;
+import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+
+/**
+ * The concrete PerfDataBuffer implementation for the <em>local:</em>
+ * protocol for the HotSpot PerfData monitoring implementation.
+ * <p>
+ * This class is responsible for acquiring access to the shared memory
+ * instrumentation buffer for the target HotSpot Java Virtual Machine.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+// Suppreess unchecked conversion warning at line 34.
+//@SuppressWarnings("unchecked")
+public class PerfDataBuffer extends AbstractPerfDataBuffer {
+ private static final Perf perf = AccessController.doPrivileged(new Perf.GetPerfAction());
+
+ /**
+ * Create a PerfDataBuffer instance for accessing the specified
+ * instrumentation buffer.
+ *
+ * @param vmid the <em>local:</em> URI specifying the target JVM.
+ *
+ * @throws MonitorException
+ */
+ public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
+ try {
+ // Try 1.4.2 and later first
+ ByteBuffer bb = perf.attach(vmid.getLocalVmId(), vmid.getMode());
+ createPerfDataBuffer(bb, vmid.getLocalVmId());
+
+ } catch (IllegalArgumentException e) {
+ // now try 1.4.1 by attempting to directly map the files.
+ try {
+ String filename = PerfDataFile.getTempDirectory()
+ + PerfDataFile.dirNamePrefix
+ + Integer.toString(vmid.getLocalVmId());
+
+ File f = new File(filename);
+
+ FileChannel fc = new RandomAccessFile(f, "r").getChannel();
+ ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L,
+ (int)fc.size());
+ fc.close();
+ createPerfDataBuffer(bb, vmid.getLocalVmId());
+
+ } catch (FileNotFoundException e2) {
+ // re-throw the exception from the 1.4.2 attach method
+ throw new MonitorException(vmid.getLocalVmId() + " not found",
+ e);
+ } catch (IOException e2) {
+ throw new MonitorException("Could not map 1.4.1 file for "
+ + vmid.getLocalVmId(), e2);
+ }
+ } catch (IOException e) {
+ throw new MonitorException("Could not attach to "
+ + vmid.getLocalVmId(), e);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.protocol.local;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import jdk.internal.vm.VMSupport;
+
+/**
+ * Class to provide translations from the local Vm Identifier
+ * name space into the file system name space and vice-versa.
+ * <p>
+ * Provides a factory for creating a File object to the backing
+ * store file for instrumentation shared memory region for a JVM
+ * identified by its Local Java Virtual Machine Identifier, or
+ * <em>lvmid</em>.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see java.io.File
+ */
+public class PerfDataFile {
+ private PerfDataFile() { };
+
+ /**
+ * The name of the of the system dependent temporary directory
+ */
+ public static final String tmpDirName;
+
+ /**
+ * The file name prefix for PerfData shared memory files.
+ * <p>
+ * This prefix must be kept in sync with the prefix used by the JVM.
+ */
+ public static final String dirNamePrefix = "hsperfdata_";
+
+ /**
+ * The directory name pattern for the user directories.
+ */
+ public static final String userDirNamePattern = "hsperfdata_\\S*";
+
+ /**
+ * The file name pattern for PerfData shared memory files.
+ * <p>
+ * This pattern must be kept in synch with the file name pattern
+ * used by the 1.4.2 and later HotSpot JVM.
+ */
+ public static final String fileNamePattern = "^[0-9]+$";
+
+ /**
+ * The file name pattern for 1.4.1 PerfData shared memory files.
+ * <p>
+ * This pattern must be kept in synch with the file name pattern
+ * used by the 1.4.1 HotSpot JVM.
+ */
+ public static final String tmpFileNamePattern =
+ "^hsperfdata_[0-9]+(_[1-2]+)?$";
+
+
+ /**
+ * Get a File object for the instrumentation backing store file
+ * for the JVM identified by the given local Vm Identifier.
+ * <p>
+ * This method looks for the most up to date backing store file for
+ * the given {@code lvmid}. It will search all the user specific
+ * directories in the temporary directory for the host operating
+ * system, which may be influenced by platform specific environment
+ * variables.
+ *
+ * @param lvmid the local Java Virtual Machine Identifier for the target
+ * @return File - a File object to the backing store file for the named
+ * shared memory region of the target JVM.
+ * @see java.io.File
+ * @see #getTempDirectory()
+ */
+ public static File getFile(int lvmid) {
+ if (lvmid == 0) {
+ /*
+ * lvmid == 0 is used to indicate the current Java Virtual Machine.
+ * If the SDK provided an API to get a unique Java Virtual Machine
+ * identifier, then a filename could be constructed with that
+ * identifier. In absence of such an api, return null.
+ */
+ return null;
+ }
+
+ /*
+ * iterate over all files in all directories in tmpDirName that
+ * match the file name patterns.
+ */
+ File tmpDir = new File(tmpDirName);
+ String[] files = tmpDir.list(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if (!name.startsWith(dirNamePrefix)) {
+ return false;
+ }
+ File candidate = new File(dir, name);
+ return ((candidate.isDirectory() || candidate.isFile())
+ && candidate.canRead());
+ }
+ });
+
+ long newestTime = 0;
+ File newest = null;
+
+ for (int i = 0; i < files.length; i++) {
+ File f = new File(tmpDirName + files[i]);
+ File candidate = null;
+
+ if (f.exists() && f.isDirectory()) {
+ /*
+ * found a directory matching the name patterns. This
+ * is a 1.4.2 hsperfdata_<user> directory. Check for
+ * file named <lvmid> in that directory
+ */
+ String name = Integer.toString(lvmid);
+ candidate = new File(f.getName(), name);
+
+ } else if (f.exists() && f.isFile()) {
+ /*
+ * found a file matching the name patterns. This
+ * is a 1.4.1 hsperfdata_<lvmid> file.
+ */
+ candidate = f;
+
+ } else {
+ // unexpected - let conditional below filter this one out
+ candidate = f;
+ }
+
+ if (candidate.exists() && candidate.isFile()
+ && candidate.canRead()) {
+ long modTime = candidate.lastModified();
+ if (modTime >= newestTime) {
+ newestTime = modTime;
+ newest = candidate;
+ }
+ }
+ }
+ return newest;
+ }
+
+ /**
+ * Return the File object for the backing store file for the specified Java
+ * Virtual Machine.
+ * <p>
+ * This method looks for the most up to date backing store file for
+ * the JVM identified by the given user name and lvmid. The directory
+ * searched is the temporary directory for the host operating system,
+ * which may be influenced by environment variables.
+ *
+ * @param user the user name
+ * @param lvmid the local Java Virtual Machine Identifier for the target
+ * @return File - a File object to the backing store file for the named
+ * shared memory region of the target JVM.
+ * @see java.io.File
+ * @see #getTempDirectory()
+ */
+ public static File getFile(String user, int lvmid) {
+ if (lvmid == 0) {
+ /*
+ * lvmid == 0 is used to indicate the current Java Virtual Machine.
+ * If the SDK provided an API to get a unique Java Virtual Machine
+ * identifier, then a filename could be constructed with that
+ * identifier. In absence of such an api, return null.
+ */
+ return null;
+ }
+
+ // first try for 1.4.2 and later JVMs
+ String basename = getTempDirectory(user) + Integer.toString(lvmid);
+ File f = new File(basename);
+
+ if (f.exists() && f.isFile() && f.canRead()) {
+ return f;
+ }
+
+ // No hit on 1.4.2 JVMs, try 1.4.1 files
+ long newestTime = 0;
+ File newest = null;
+ for (int i = 0; i < 2; i++) {
+ if (i == 0) {
+ basename = getTempDirectory() + Integer.toString(lvmid);
+ } else {
+ basename = getTempDirectory() + Integer.toString(lvmid)
+ + Integer.toString(i);
+ }
+
+ f = new File(basename);
+
+ if (f.exists() && f.isFile() && f.canRead()) {
+ long modTime = f.lastModified();
+ if (modTime >= newestTime) {
+ newestTime = modTime;
+ newest = f;
+ }
+ }
+ }
+ return newest;
+ }
+
+ /**
+ * Method to extract a local Java Virtual Machine Identifier from the
+ * file name of the given File object.
+ *
+ * @param file A File object representing the name of a
+ * shared memory region for a target JVM
+ * @return int - the local Java Virtual Machine Identifier for the target
+ * associated with the file
+ * @throws java.lang.IllegalArgumentException Thrown if the file name
+ * does not conform to the expected pattern
+ */
+ public static int getLocalVmId(File file) {
+ try {
+ // try 1.4.2 and later format first
+ return Integer.parseInt(file.getName());
+ } catch (NumberFormatException e) { }
+
+ // now try the 1.4.1 format
+ String name = file.getName();
+ if (name.startsWith(dirNamePrefix)) {
+ int first = name.indexOf('_');
+ int last = name.lastIndexOf('_');
+ try {
+ if (first == last) {
+ return Integer.parseInt(name.substring(first + 1));
+ } else {
+ return Integer.parseInt(name.substring(first + 1, last));
+ }
+ } catch (NumberFormatException e) { }
+ }
+ throw new IllegalArgumentException("file name does not match pattern");
+ }
+
+ /**
+ * Return the name of the temporary directory being searched for
+ * HotSpot PerfData backing store files.
+ * <p>
+ * This method generally returns the value of the java.io.tmpdir
+ * property. However, on some platforms it may return a different
+ * directory, as the JVM implementation may store the PerfData backing
+ * store files in a different directory for performance reasons.
+ *
+ * @return String - the name of the temporary directory.
+ */
+ public static String getTempDirectory() {
+ return tmpDirName;
+ }
+
+ /**
+ * Return the name of the temporary directory to be searched
+ * for HotSpot PerfData backing store files for a given user.
+ * <p>
+ * This method generally returns the name of a subdirectory of
+ * the directory indicated in the java.io.tmpdir property. However,
+ * on some platforms it may return a different directory, as the
+ * JVM implementation may store the PerfData backing store files
+ * in a different directory for performance reasons.
+ *
+ * @return String - the name of the temporary directory.
+ */
+ public static String getTempDirectory(String user) {
+ return tmpDirName + dirNamePrefix + user + File.separator;
+ }
+
+ static {
+ /*
+ * For this to work, the target VM and this code need to use
+ * the same directory. Instead of guessing which directory the
+ * VM is using, we will ask.
+ */
+ String tmpdir = VMSupport.getVMTemporaryDirectory();
+
+ /*
+ * Assure that the string returned has a trailing File.separator
+ * character. This check was added because the Linux implementation
+ * changed such that the java.io.tmpdir string no longer terminates
+ * with a File.separator character.
+ */
+ if (tmpdir.lastIndexOf(File.separator) != (tmpdir.length()-1)) {
+ tmpdir = tmpdir + File.separator;
+ }
+ tmpDirName = tmpdir;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/package.html Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,50 @@
+<!doctype html public "-//IETF//DTD HTML/EN">
+<html>
+<head>
+<!--
+
+
+ Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ particular file as subject to the "Classpath" exception as provided
+ by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+
+
+-->
+</head>
+<body bgcolor="white">
+<p>
+Provides the implementation classes for the <em>local:</em> protocol for
+the HotSpot PerfData instrumentation buffer monitoring implementation.
+</p>
+<p>
+The <em>local:</em> protocol is the default protocol for the PerfData
+implementation. It utilizes a name shared memory mechanism, identified
+by a backing store file in the file system name space. The location of
+the backing store file is platform specific and is dictated primarily by
+the JVM implementation. However, the <code>java.io.tmpdir</code> system
+property generally contains the location of the files, with the exception
+of the Solaris implementation, as the SDK and HotSpot JVM use different
+locations for their temporary file storage. The HotSpot JVM uses the
+<em>/tmp</em> directory and the SDK uses <em>/var/tmp</em>. The classes
+in this specifically use <em>/tmp</em> when running on Solaris.
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/BasicType.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.v1_0;
+
+/**
+ * A typesafe enumeration for describing Java basic types.
+ *
+ * <p> The enumeration values for this typesafe enumeration must be
+ * kept in synchronization with the BasicType enum in the
+ * globalsDefinitions.hpp file in the HotSpot source base.</p>
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class BasicType {
+
+ private final String name;
+ private final int value;
+
+ public static final BasicType BOOLEAN = new BasicType("boolean", 4);
+ public static final BasicType CHAR = new BasicType("char", 5);
+ public static final BasicType FLOAT = new BasicType("float", 6);
+ public static final BasicType DOUBLE = new BasicType("double", 7);
+ public static final BasicType BYTE = new BasicType("byte", 8);
+ public static final BasicType SHORT = new BasicType("short", 9);
+ public static final BasicType INT = new BasicType("int", 10);
+ public static final BasicType LONG = new BasicType("long", 11);
+ public static final BasicType OBJECT = new BasicType("object", 12);
+ public static final BasicType ARRAY = new BasicType("array", 13);
+ public static final BasicType VOID = new BasicType("void", 14);
+ public static final BasicType ADDRESS = new BasicType("address", 15);
+ public static final BasicType ILLEGAL = new BasicType("illegal", 99);
+
+ private static BasicType basicTypes[] = {
+ BOOLEAN, CHAR, FLOAT, DOUBLE, BYTE, SHORT, INT, LONG, OBJECT,
+ ARRAY, VOID, ADDRESS, ILLEGAL
+ };
+
+ /**
+ * Convert enumeration value to a String.
+ *
+ * @return String - the string representation for the enumeration.
+ */
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Convert enumeration to an integer value.
+ *
+ * @return int - the integer representation for the enumeration.
+ */
+ public int intValue() {
+ return value;
+ }
+
+ /**
+ * Map an integer value to its corresponding BasicType object.
+ *
+ * @param i an integer representation of a BasicType
+ * @return BasicType - The BasicType enumeration object matching
+ * the value of <code>i</code>
+ */
+ public static BasicType toBasicType(int i) {
+ for (int j = 0; j < basicTypes.length; j++) {
+ if (basicTypes[j].intValue() == j) {
+ return (basicTypes[j]);
+ }
+ }
+ return ILLEGAL;
+ }
+
+ private BasicType(String name, int value) {
+ this.name = name;
+ this.value = value;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,605 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.v1_0;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.util.*;
+import java.util.regex.*;
+import java.nio.*;
+
+/**
+ * The concrete implementation of version 1.0 of the HotSpot PerfData
+ * Instrumentation buffer. This class is responsible for parsing the
+ * instrumentation memory and constructing the necessary objects to
+ * represent and access the instrumentation objects contained in the
+ * memory buffer.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see AbstractPerfDataBuffer
+ */
+public class PerfDataBuffer extends PerfDataBufferImpl {
+
+ // 8028357 removed old, inefficient debug logging
+
+ private static final int syncWaitMs =
+ Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
+ private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<Monitor>(0);
+
+ /*
+ * the following constants must be kept in sync with struct
+ * PerfDataEntry in perfMemory.hpp
+ */
+ private final static int PERFDATA_ENTRYLENGTH_OFFSET=0;
+ private final static int PERFDATA_ENTRYLENGTH_SIZE=4; // sizeof(int)
+ private final static int PERFDATA_NAMELENGTH_OFFSET=4;
+ private final static int PERFDATA_NAMELENGTH_SIZE=4; // sizeof(int)
+ private final static int PERFDATA_VECTORLENGTH_OFFSET=8;
+ private final static int PERFDATA_VECTORLENGTH_SIZE=4; // sizeof(int)
+ private final static int PERFDATA_DATATYPE_OFFSET=12;
+ private final static int PERFDATA_DATATYPE_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_FLAGS_OFFSET=13;
+ private final static int PERFDATA_FLAGS_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_DATAUNITS_OFFSET=14;
+ private final static int PERFDATA_DATAUNITS_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_DATAATTR_OFFSET=15;
+ private final static int PERFDATA_DATAATTR_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_NAME_OFFSET=16;
+
+ PerfDataBufferPrologue prologue;
+ int nextEntry;
+ int pollForEntry;
+ int perfDataItem;
+ long lastModificationTime;
+ int lastUsed;
+ IntegerMonitor overflow;
+ ArrayList<Monitor> insertedMonitors;
+
+ /**
+ * Construct a PerfDataBufferImpl instance.
+ * <p>
+ * This class is dynamically loaded by
+ * {@link AbstractPerfDataBuffer#createPerfDataBuffer}, and this
+ * constructor is called to instantiate the instance.
+ *
+ * @param buffer the buffer containing the instrumentation data
+ * @param lvmid the Local Java Virtual Machine Identifier for this
+ * instrumentation buffer.
+ */
+ public PerfDataBuffer(ByteBuffer buffer, int lvmid)
+ throws MonitorException {
+ super(buffer, lvmid);
+ prologue = new PerfDataBufferPrologue(buffer);
+ this.buffer.order(prologue.getByteOrder());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void buildMonitorMap(Map<String, Monitor> map) throws MonitorException {
+ assert Thread.holdsLock(this);
+
+ // start at the beginning of the buffer
+ buffer.rewind();
+
+ // create pseudo monitors
+ buildPseudoMonitors(map);
+
+ // position buffer to start of the data section
+ buffer.position(prologue.getSize());
+ nextEntry = buffer.position();
+ perfDataItem = 0;
+
+ int used = prologue.getUsed();
+ long modificationTime = prologue.getModificationTimeStamp();
+
+ Monitor m = getNextMonitorEntry();
+ while (m != null) {
+ map.put(m.getName(), m);
+ m = getNextMonitorEntry();
+ }
+
+ /*
+ * set the last modification data. These are set to the values
+ * recorded before parsing the data structure. This allows the
+ * the data structure to be modified while the Map is being built.
+ * The Map may contain more entries than indicated based on the
+ * time stamp, but this is handled by ignoring duplicate entries
+ * when the Map is updated in getNewMonitors().
+ */
+ lastUsed = used;
+ lastModificationTime = modificationTime;
+
+ // synchronize with the target jvm
+ synchWithTarget(map);
+
+ // work around 1.4.2 counter inititization bugs
+ kludge(map);
+
+ insertedMonitors = new ArrayList<Monitor>(map.values());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
+ assert Thread.holdsLock(this);
+
+ int used = prologue.getUsed();
+ long modificationTime = prologue.getModificationTimeStamp();
+
+ if ((used > lastUsed) || (lastModificationTime > modificationTime)) {
+
+ lastUsed = used;
+ lastModificationTime = modificationTime;
+
+ Monitor monitor = getNextMonitorEntry();
+ while (monitor != null) {
+ String name = monitor.getName();
+
+ // guard against duplicate entries
+ if (!map.containsKey(name)) {
+ map.put(name, monitor);
+
+ /*
+ * insertedMonitors is null when called from pollFor()
+ * via buildMonitorMap(). Since we update insertedMonitors
+ * at the end of buildMonitorMap(), it's ok to skip the
+ * add here.
+ */
+ if (insertedMonitors != null) {
+ insertedMonitors.add(monitor);
+ }
+ }
+ monitor = getNextMonitorEntry();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected MonitorStatus getMonitorStatus(Map<String, Monitor> map) throws MonitorException {
+ assert Thread.holdsLock(this);
+ assert insertedMonitors != null;
+
+ // load any new monitors
+ getNewMonitors(map);
+
+ // current implementation doesn't support deletion or reuse of entries
+ ArrayList<Monitor> removed = EMPTY_LIST;
+ ArrayList<Monitor> inserted = insertedMonitors;
+
+ insertedMonitors = new ArrayList<Monitor>();
+ return new MonitorStatus(inserted, removed);
+ }
+
+ /**
+ * Build the pseudo monitors used to map the prolog data into counters.
+ */
+ protected void buildPseudoMonitors(Map<String, Monitor> map) {
+ Monitor monitor = null;
+ String name = null;
+ IntBuffer ib = null;
+
+ name = PerfDataBufferPrologue.PERFDATA_MAJOR_NAME;
+ ib = prologue.majorVersionBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.NONE,
+ Variability.CONSTANT, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_MINOR_NAME;
+ ib = prologue.minorVersionBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.NONE,
+ Variability.CONSTANT, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_BUFFER_SIZE_NAME;
+ ib = prologue.sizeBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.BYTES,
+ Variability.MONOTONIC, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_BUFFER_USED_NAME;
+ ib = prologue.usedBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.BYTES,
+ Variability.MONOTONIC, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_OVERFLOW_NAME;
+ ib = prologue.overflowBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.BYTES,
+ Variability.MONOTONIC, false, ib);
+ map.put(name, monitor);
+ this.overflow = (IntegerMonitor)monitor;
+
+ name = PerfDataBufferPrologue.PERFDATA_MODTIMESTAMP_NAME;
+ LongBuffer lb = prologue.modificationTimeStampBuffer();
+ monitor = new PerfLongMonitor(name, Units.TICKS,
+ Variability.MONOTONIC, false, lb);
+ map.put(name, monitor);
+ }
+
+ /**
+ * Method to provide a gross level of synchronization with the
+ * target monitored jvm.
+ *
+ * gross synchronization works by polling for the hotspot.rt.hrt.ticks
+ * counter, which is the last counter created by the StatSampler
+ * initialization code. The counter is updated when the watcher thread
+ * starts scheduling tasks, which is the last thing done in vm
+ * initialization.
+ */
+ protected void synchWithTarget(Map<String, Monitor> map) throws MonitorException {
+ /*
+ * synch must happen with syncWaitMs from now. Default is 5 seconds,
+ * which is reasonabally generous and should provide for extreme
+ * situations like startup delays due to allocation of large ISM heaps.
+ */
+ long timeLimit = System.currentTimeMillis() + syncWaitMs;
+
+ String name = "hotspot.rt.hrt.ticks";
+ LongMonitor ticks = (LongMonitor)pollFor(map, name, timeLimit);
+
+ /*
+ * loop waiting for the ticks counter to be non zero. This is
+ * an indication that the jvm is initialized.
+ */
+ while (ticks.longValue() == 0) {
+ try { Thread.sleep(20); } catch (InterruptedException e) { }
+
+ if (System.currentTimeMillis() > timeLimit) {
+ throw new MonitorException("Could Not Synchronize with target");
+ }
+ }
+ }
+
+ /**
+ * Method to poll the instrumentation memory for a counter with
+ * the given name. The polling period is bounded by the timeLimit
+ * argument.
+ */
+ protected Monitor pollFor(Map<String, Monitor> map, String name, long timeLimit)
+ throws MonitorException {
+ Monitor monitor = null;
+
+ pollForEntry = nextEntry;
+ while ((monitor = map.get(name)) == null) {
+
+ try { Thread.sleep(20); } catch (InterruptedException e) { }
+
+ long t = System.currentTimeMillis();
+ if ((t > timeLimit) || (overflow.intValue() > 0)) {
+ throw new MonitorException("Could not find expected counter");
+ }
+
+ getNewMonitors(map);
+ }
+ return monitor;
+ }
+
+ /**
+ * method to make adjustments for known counter problems. This
+ * method depends on the availability of certain counters, which
+ * is generally guaranteed by the synchWithTarget() method.
+ */
+ protected void kludge(Map<String, Monitor> map) {
+ if (Boolean.getBoolean("sun.jvmstat.perfdata.disableKludge")) {
+ // bypass all kludges
+ return;
+ }
+
+ String name = "java.vm.version";
+ StringMonitor jvm_version = (StringMonitor)map.get(name);
+ if (jvm_version == null) {
+ jvm_version = (StringMonitor)findByAlias(name);
+ }
+
+ name = "java.vm.name";
+ StringMonitor jvm_name = (StringMonitor)map.get(name);
+ if (jvm_name == null) {
+ jvm_name = (StringMonitor)findByAlias(name);
+ }
+
+ name = "hotspot.vm.args";
+ StringMonitor args = (StringMonitor)map.get(name);
+ if (args == null) {
+ args = (StringMonitor)findByAlias(name);
+ }
+
+ assert ((jvm_name != null) && (jvm_version != null) && (args != null));
+
+ if (jvm_name.stringValue().indexOf("HotSpot") >= 0) {
+ if (jvm_version.stringValue().startsWith("1.4.2")) {
+ kludgeMantis(map, args);
+ }
+ }
+ }
+
+ /**
+ * method to repair the 1.4.2 parallel scavenge counters that are
+ * incorrectly initialized by the JVM when UseAdaptiveSizePolicy
+ * is set. This bug couldn't be fixed for 1.4.2 FCS due to putback
+ * restrictions.
+ */
+ private void kludgeMantis(Map<String, Monitor> map, StringMonitor args) {
+ /*
+ * the HotSpot 1.4.2 JVM with the +UseParallelGC option along
+ * with its default +UseAdaptiveSizePolicy option has a bug with
+ * the initialization of the sizes of the eden and survivor spaces.
+ * See bugid 4890736.
+ *
+ * note - use explicit 1.4.2 counter names here - don't update
+ * to latest counter names or attempt to find aliases.
+ */
+
+ String cname = "hotspot.gc.collector.0.name";
+ StringMonitor collector = (StringMonitor)map.get(cname);
+
+ if (collector.stringValue().compareTo("PSScavenge") == 0) {
+ boolean adaptiveSizePolicy = true;
+
+ /*
+ * HotSpot processes the -XX:Flags/.hotspotrc arguments prior to
+ * processing the command line arguments. This allows the command
+ * line arguments to override any defaults set in .hotspotrc
+ */
+ cname = "hotspot.vm.flags";
+ StringMonitor flags = (StringMonitor)map.get(cname);
+ String allArgs = flags.stringValue() + " " + args.stringValue();
+
+ /*
+ * ignore the -XX: prefix as it only applies to the arguments
+ * passed from the command line (i.e. the invocation api).
+ * arguments passed through .hotspotrc omit the -XX: prefix.
+ */
+ int ahi = allArgs.lastIndexOf("+AggressiveHeap");
+ int aspi = allArgs.lastIndexOf("-UseAdaptiveSizePolicy");
+
+ if (ahi != -1) {
+ /*
+ * +AggressiveHeap was set, check if -UseAdaptiveSizePolicy
+ * is set after +AggressiveHeap.
+ */
+ //
+ if ((aspi != -1) && (aspi > ahi)) {
+ adaptiveSizePolicy = false;
+ }
+ } else {
+ /*
+ * +AggressiveHeap not set, must be +UseParallelGC. The
+ * relative position of -UseAdaptiveSizePolicy is not
+ * important in this case, as it will override the
+ * UseParallelGC default (+UseAdaptiveSizePolicy) if it
+ * appears anywhere in the JVM arguments.
+ */
+ if (aspi != -1) {
+ adaptiveSizePolicy = false;
+ }
+ }
+
+ if (adaptiveSizePolicy) {
+ // adjust the buggy AdaptiveSizePolicy size counters.
+
+ // first remove the real counters.
+ String eden_size = "hotspot.gc.generation.0.space.0.size";
+ String s0_size = "hotspot.gc.generation.0.space.1.size";
+ String s1_size = "hotspot.gc.generation.0.space.2.size";
+ map.remove(eden_size);
+ map.remove(s0_size);
+ map.remove(s1_size);
+
+ // get the maximum new generation size
+ String new_max_name = "hotspot.gc.generation.0.capacity.max";
+ LongMonitor new_max = (LongMonitor)map.get(new_max_name);
+
+ /*
+ * replace the real counters with pseudo counters that are
+ * initialized to the correct values. The maximum size of
+ * the eden and survivor spaces are supposed to be:
+ * max_eden_size = new_size - (2*alignment).
+ * max_survivor_size = new_size - (2*alignment).
+ * since we don't know the alignment value used, and because
+ * of other parallel scavenge bugs that result in oversized
+ * spaces, we just set the maximum size of each space to the
+ * full new gen size.
+ */
+ Monitor monitor = null;
+
+ LongBuffer lb = LongBuffer.allocate(1);
+ lb.put(new_max.longValue());
+ monitor = new PerfLongMonitor(eden_size, Units.BYTES,
+ Variability.CONSTANT, false, lb);
+ map.put(eden_size, monitor);
+
+ monitor = new PerfLongMonitor(s0_size, Units.BYTES,
+ Variability.CONSTANT, false, lb);
+ map.put(s0_size, monitor);
+
+ monitor = new PerfLongMonitor(s1_size, Units.BYTES,
+ Variability.CONSTANT, false, lb);
+ map.put(s1_size, monitor);
+ }
+ }
+ }
+
+ /**
+ * method to extract the next monitor entry from the instrumentation memory.
+ * assumes that nextEntry is the offset into the byte array
+ * at which to start the search for the next entry. method leaves
+ * next entry pointing to the next entry or to the end of data.
+ */
+ protected Monitor getNextMonitorEntry() throws MonitorException {
+ Monitor monitor = null;
+
+ // entries are always 4 byte aligned.
+ if ((nextEntry % 4) != 0) {
+ throw new MonitorStructureException(
+ "Entry index not properly aligned: " + nextEntry);
+ }
+
+ // protect against a corrupted shared memory region.
+ if ((nextEntry < 0) || (nextEntry > buffer.limit())) {
+ throw new MonitorStructureException(
+ "Entry index out of bounds: nextEntry = " + nextEntry
+ + ", limit = " + buffer.limit());
+ }
+
+ // check for the end of the buffer
+ if (nextEntry == buffer.limit()) {
+ return null;
+ }
+
+ buffer.position(nextEntry);
+
+ int entryStart = buffer.position();
+ int entryLength = buffer.getInt();
+
+ // check for valid entry length
+ if ((entryLength < 0) || (entryLength > buffer.limit())) {
+ throw new MonitorStructureException(
+ "Invalid entry length: entryLength = " + entryLength);
+ }
+
+ // check if last entry occurs before the eof.
+ if ((entryStart + entryLength) > buffer.limit()) {
+ throw new MonitorStructureException(
+ "Entry extends beyond end of buffer: "
+ + " entryStart = " + entryStart
+ + " entryLength = " + entryLength
+ + " buffer limit = " + buffer.limit());
+ }
+
+ if (entryLength == 0) {
+ // end of data
+ return null;
+ }
+
+ int nameLength = buffer.getInt();
+ int vectorLength = buffer.getInt();
+ byte dataType = buffer.get();
+ byte flags = buffer.get();
+ Units u = Units.toUnits(buffer.get());
+ Variability v = Variability.toVariability(buffer.get());
+ boolean supported = (flags & 0x01) != 0;
+
+ // defend against corrupt entries
+ if ((nameLength <= 0) || (nameLength > entryLength)) {
+ throw new MonitorStructureException(
+ "Invalid Monitor name length: " + nameLength);
+ }
+
+ if ((vectorLength < 0) || (vectorLength > entryLength)) {
+ throw new MonitorStructureException(
+ "Invalid Monitor vector length: " + vectorLength);
+ }
+
+ // read in the perfData item name, casting bytes to chars. skip the
+ // null terminator
+ //
+ byte[] nameBytes = new byte[nameLength-1];
+ for (int i = 0; i < nameLength-1; i++) {
+ nameBytes[i] = buffer.get();
+ }
+
+ // convert name into a String
+ String name = new String(nameBytes, 0, nameLength-1);
+
+ if (v == Variability.INVALID) {
+ throw new MonitorDataException("Invalid variability attribute:"
+ + " entry index = " + perfDataItem
+ + " name = " + name);
+ }
+ if (u == Units.INVALID) {
+ throw new MonitorDataException("Invalid units attribute: "
+ + " entry index = " + perfDataItem
+ + " name = " + name);
+ }
+
+ int offset;
+ if (vectorLength == 0) {
+ // scalar Types
+ if (dataType == BasicType.LONG.intValue()) {
+ offset = entryStart + entryLength - 8; /* 8 = sizeof(long) */
+ buffer.position(offset);
+ LongBuffer lb = buffer.asLongBuffer();
+ lb.limit(1);
+ monitor = new PerfLongMonitor(name, u, v, supported, lb);
+ perfDataItem++;
+ } else {
+ // bad data types.
+ throw new MonitorTypeException("Invalid Monitor type:"
+ + " entry index = " + perfDataItem
+ + " name = " + name
+ + " type = " + dataType);
+ }
+ } else {
+ // vector types
+ if (dataType == BasicType.BYTE.intValue()) {
+ if (u != Units.STRING) {
+ // only byte arrays of type STRING are currently supported
+ throw new MonitorTypeException("Invalid Monitor type:"
+ + " entry index = " + perfDataItem
+ + " name = " + name
+ + " type = " + dataType);
+ }
+
+ offset = entryStart + PERFDATA_NAME_OFFSET + nameLength;
+ buffer.position(offset);
+ ByteBuffer bb = buffer.slice();
+ bb.limit(vectorLength);
+ bb.position(0);
+
+ if (v == Variability.CONSTANT) {
+ monitor = new PerfStringConstantMonitor(name, supported,
+ bb);
+ } else if (v == Variability.VARIABLE) {
+ monitor = new PerfStringVariableMonitor(name, supported,
+ bb, vectorLength-1);
+ } else {
+ // Monotonically increasing byte arrays are not supported
+ throw new MonitorDataException(
+ "Invalid variability attribute:"
+ + " entry index = " + perfDataItem
+ + " name = " + name
+ + " variability = " + v);
+ }
+ perfDataItem++;
+ } else {
+ // bad data types.
+ throw new MonitorTypeException(
+ "Invalid Monitor type:" + " entry index = "
+ + perfDataItem + " name = " + name
+ + " type = " + dataType);
+ }
+ }
+
+ // setup index to next entry for next iteration of the loop.
+ nextEntry = entryStart + entryLength;
+ return monitor;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBufferPrologue.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.v1_0;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.nio.*;
+
+/**
+ * Class representing the 1.0 version of the HotSpot PerfData instrumentation
+ * buffer header.
+ * <p>
+ * The PerfDataBufferPrologue2_0 class supports parsing of the version
+ * specific portions of the PerfDataPrologue C structure:
+ * <pre>
+ * typedef struct {
+ * ... // handled by superclass
+ * jint used; // number of PerfData memory bytes used
+ * jint overflow; // number of bytes of overflow
+ * jlong mod_time_stamp; // time stamp of the last structural modification
+ * } PerfDataPrologue
+ * </pre>
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfDataBufferPrologue extends AbstractPerfDataBufferPrologue {
+
+ private static final int SUPPORTED_MAJOR_VERSION = 1;
+ private static final int SUPPORTED_MINOR_VERSION = 0;
+
+ /*
+ * the following constants must match the field offsets and sizes
+ * in the PerfDataPrologue structure in perfMemory.hpp
+ */
+ final static int PERFDATA_PROLOG_USED_OFFSET=8;
+ final static int PERFDATA_PROLOG_USED_SIZE=4; // sizeof(int)
+ final static int PERFDATA_PROLOG_OVERFLOW_OFFSET=12;
+ final static int PERFDATA_PROLOG_OVERFLOW_SIZE=4; // sizeof(int)
+ final static int PERFDATA_PROLOG_MODTIMESTAMP_OFFSET=16;
+ final static int PERFDATA_PROLOG_MODTIMESTAMP_SIZE=8; // sizeof(long)
+ final static int PERFDATA_PROLOG_SIZE=24; // sizeof(struct PerfDataProlog)
+
+ // counter names for prologue psuedo counters
+ final static String PERFDATA_BUFFER_SIZE_NAME = "sun.perfdata.size";
+ final static String PERFDATA_BUFFER_USED_NAME = "sun.perfdata.used";
+ final static String PERFDATA_OVERFLOW_NAME = "sun.perfdata.overflow";
+ final static String PERFDATA_MODTIMESTAMP_NAME = "sun.perfdata.timestamp";
+
+ /**
+ * Create an instance of PerfDataBufferPrologue from the given
+ * ByteBuffer object.
+ *
+ * @param byteBuffer the buffer containing the binary header data
+ */
+ public PerfDataBufferPrologue(ByteBuffer byteBuffer)
+ throws MonitorException {
+ super(byteBuffer);
+ assert ((getMajorVersion() == 1) && (getMinorVersion() == 0));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean supportsAccessible() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAccessible() {
+ return true;
+ }
+
+ /**
+ * Get the utilization of the instrumentation memory buffer.
+ *
+ * @return int - the utilization of the buffer
+ */
+ public int getUsed() {
+ byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
+ return byteBuffer.getInt();
+ }
+
+ /**
+ * Get the size of the instrumentation memory buffer.
+ *
+ * @return int - the size of the buffer
+ */
+ public int getBufferSize() {
+ return byteBuffer.capacity();
+ }
+
+ /**
+ * Get the buffer overflow amount. This value is non-zero if the
+ * HotSpot JVM has overflowed the instrumentation memory buffer.
+ * The target JVM can be restarted with -XX:PerfDataMemSize=X to
+ * create a larger memory buffer.
+ *
+ * @return int - the size of the buffer
+ */
+ public int getOverflow() {
+ byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
+ return byteBuffer.getInt();
+ }
+
+ /**
+ * Get the time of last modification for the instrumentation
+ * memory buffer. This method returns the time, as ticks since the
+ * start of the target JVM, of the last structural modification to
+ * the instrumentation buffer. Structural modifications correspond to
+ * the addition or deletion of instrumentation objects. Updates to
+ * counter values are not structural modifications.
+ */
+ public long getModificationTimeStamp() {
+ byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
+ return byteBuffer.getLong();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getSize() {
+ return PERFDATA_PROLOG_SIZE; // sizeof(struct PerfDataProlog)
+ }
+
+ /**
+ * Return an IntBuffer that accesses the used value. This is used
+ * to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the used value
+ * in the instrumentation buffer header.
+ * @see #getUsed()
+ */
+ public IntBuffer usedBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
+ IntBuffer ib = byteBuffer.asIntBuffer();
+ ib.limit(1);
+ return ib;
+ }
+
+ /**
+ * Return an IntBuffer that accesses the size value. This is used
+ * to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the size value
+ * in the instrumentation buffer header.
+ * @see #getBufferSize()
+ */
+ public IntBuffer sizeBuffer() {
+ IntBuffer ib = IntBuffer.allocate(1);
+ ib.put(byteBuffer.capacity());
+ return ib;
+ }
+
+ /**
+ * Return an IntBuffer that accesses the overflow value. This is used
+ * to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the overflow value
+ * in the instrumentation buffer header.
+ * @see #getOverflow()
+ */
+ public IntBuffer overflowBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
+ IntBuffer ib = byteBuffer.asIntBuffer();
+ ib.limit(1);
+ return ib;
+ }
+
+ /**
+ * Return an LongBuffer that accesses the modification timestamp value.
+ * This is used* to create a Monitor object for this value.
+ *
+ * @return LongBuffer - a ByteBuffer that accesses the modification time
+ * stamp value in the instrumentation buffer header.
+ * @see #getModificationTimeStamp()
+ */
+ public LongBuffer modificationTimeStampBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
+ LongBuffer lb = byteBuffer.asLongBuffer();
+ lb.limit(1);
+ return lb;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.v2_0;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.util.*;
+import java.util.regex.*;
+import java.nio.*;
+
+/**
+ * The concrete implementation of version 2.0 of the HotSpot PerfData
+ * Instrumentation buffer. This class is responsible for parsing the
+ * instrumentation memory and constructing the necessary objects to
+ * represent and access the instrumentation objects contained in the
+ * memory buffer.
+ * <p>
+ * The structure of the 2.0 entry is defined in struct PerfDataEnry
+ * as decsribed in perfMemory.hpp. This structure looks like:
+ * <pre>
+ * typedef struct {
+ * jint entry_length; // entry length in bytes
+ * jint name_offset; // offset to entry name, relative to start
+ * // of entry
+ * jint vector_length; // length of the vector. If 0, then scalar.
+ * jbyte data_type; // JNI field descriptor type
+ * jbyte flags; // miscellaneous attribute flags
+ * // 0x01 - supported
+ * jbyte data_units; // unit of measure attribute
+ * jbyte data_variability; // variability attribute
+ * jbyte data_offset; // offset to data item, relative to start
+ * // of entry.
+ * } PerfDataEntry;
+ * </pre>
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ * @see AbstractPerfDataBuffer
+ */
+public class PerfDataBuffer extends PerfDataBufferImpl {
+
+ // 8028357 removed old, inefficient debug logging
+
+ private static final int syncWaitMs =
+ Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
+ private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<>(0);
+
+ /*
+ * These are primarily for documentary purposes and the match up
+ * with the PerfDataEntry structure in perfMemory.hpp. They are
+ * generally unused in this code, but they are kept consistent with
+ * the data structure just in case some unforseen need arrises.
+ */
+ private final static int PERFDATA_ENTRYLENGTH_OFFSET=0;
+ private final static int PERFDATA_ENTRYLENGTH_SIZE=4; // sizeof(int)
+ private final static int PERFDATA_NAMEOFFSET_OFFSET=4;
+ private final static int PERFDATA_NAMEOFFSET_SIZE=4; // sizeof(int)
+ private final static int PERFDATA_VECTORLENGTH_OFFSET=8;
+ private final static int PERFDATA_VECTORLENGTH_SIZE=4; // sizeof(int)
+ private final static int PERFDATA_DATATYPE_OFFSET=12;
+ private final static int PERFDATA_DATATYPE_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_FLAGS_OFFSET=13;
+ private final static int PERFDATA_FLAGS_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_DATAUNITS_OFFSET=14;
+ private final static int PERFDATA_DATAUNITS_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_DATAVAR_OFFSET=15;
+ private final static int PERFDATA_DATAVAR_SIZE=1; // sizeof(byte)
+ private final static int PERFDATA_DATAOFFSET_OFFSET=16;
+ private final static int PERFDATA_DATAOFFSET_SIZE=4; // sizeof(int)
+
+ PerfDataBufferPrologue prologue;
+ int nextEntry;
+ long lastNumEntries;
+ IntegerMonitor overflow;
+ ArrayList<Monitor> insertedMonitors;
+
+ /**
+ * Construct a PerfDataBuffer instance.
+ * <p>
+ * This class is dynamically loaded by
+ * {@link AbstractPerfDataBuffer#createPerfDataBuffer}, and this
+ * constructor is called to instantiate the instance.
+ *
+ * @param buffer the buffer containing the instrumentation data
+ * @param lvmid the Local Java Virtual Machine Identifier for this
+ * instrumentation buffer.
+ */
+ public PerfDataBuffer(ByteBuffer buffer, int lvmid)
+ throws MonitorException {
+ super(buffer, lvmid);
+ prologue = new PerfDataBufferPrologue(buffer);
+ this.buffer.order(prologue.getByteOrder());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void buildMonitorMap(Map<String, Monitor> map) throws MonitorException {
+ assert Thread.holdsLock(this);
+
+ // start at the beginning of the buffer
+ buffer.rewind();
+
+ // create pseudo monitors
+ buildPseudoMonitors(map);
+
+ // wait for the target JVM to indicate that it's intrumentation
+ // buffer is safely accessible
+ synchWithTarget();
+
+ // parse the currently defined entries starting at the first entry.
+ nextEntry = prologue.getEntryOffset();
+
+ // record the number of entries before parsing the structure
+ int numEntries = prologue.getNumEntries();
+
+ // start parsing
+ Monitor monitor = getNextMonitorEntry();
+ while (monitor != null) {
+ map.put(monitor.getName(), monitor);
+ monitor = getNextMonitorEntry();
+ }
+
+ /*
+ * keep track of the current number of entries in the shared
+ * memory for new entry detection purposes. It's possible for
+ * the data structure to be modified while the Map is being
+ * built and the entry count in the header might change while
+ * we are parsing it. The map will contain all the counters
+ * found, but the number recorded in numEntries might be small
+ * than what than the number we actually parsed (due to asynchronous
+ * updates). This discrepency is handled by ignoring any re-parsed
+ * entries when updating the Map in getNewMonitors().
+ */
+ lastNumEntries = numEntries;
+
+ // keep track of the monitors just added.
+ insertedMonitors = new ArrayList<Monitor>(map.values());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
+ assert Thread.holdsLock(this);
+
+ int numEntries = prologue.getNumEntries();
+
+ if (numEntries > lastNumEntries) {
+ lastNumEntries = numEntries;
+ Monitor monitor = getNextMonitorEntry();
+
+ while (monitor != null) {
+ String name = monitor.getName();
+
+ // guard against re-parsed entries
+ if (!map.containsKey(name)) {
+ map.put(name, monitor);
+ if (insertedMonitors != null) {
+ insertedMonitors.add(monitor);
+ }
+ }
+ monitor = getNextMonitorEntry();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected MonitorStatus getMonitorStatus(Map<String, Monitor> map) throws MonitorException {
+ assert Thread.holdsLock(this);
+ assert insertedMonitors != null;
+
+ // load any new monitors
+ getNewMonitors(map);
+
+ // current implementation doesn't support deletion of reuse of entries
+ ArrayList<Monitor> removed = EMPTY_LIST;
+ ArrayList<Monitor> inserted = insertedMonitors;
+
+ insertedMonitors = new ArrayList<>();
+ return new MonitorStatus(inserted, removed);
+ }
+
+ /**
+ * Build the pseudo monitors used to map the prolog data into counters.
+ */
+ protected void buildPseudoMonitors(Map<String, Monitor> map) {
+ Monitor monitor = null;
+ String name = null;
+ IntBuffer ib = null;
+
+ name = PerfDataBufferPrologue.PERFDATA_MAJOR_NAME;
+ ib = prologue.majorVersionBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.NONE,
+ Variability.CONSTANT, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_MINOR_NAME;
+ ib = prologue.minorVersionBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.NONE,
+ Variability.CONSTANT, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_BUFFER_SIZE_NAME;
+ ib = prologue.sizeBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.BYTES,
+ Variability.MONOTONIC, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_BUFFER_USED_NAME;
+ ib = prologue.usedBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.BYTES,
+ Variability.MONOTONIC, false, ib);
+ map.put(name, monitor);
+
+ name = PerfDataBufferPrologue.PERFDATA_OVERFLOW_NAME;
+ ib = prologue.overflowBuffer();
+ monitor = new PerfIntegerMonitor(name, Units.BYTES,
+ Variability.MONOTONIC, false, ib);
+ map.put(name, monitor);
+ this.overflow = (IntegerMonitor)monitor;
+
+ name = PerfDataBufferPrologue.PERFDATA_MODTIMESTAMP_NAME;
+ LongBuffer lb = prologue.modificationTimeStampBuffer();
+ monitor = new PerfLongMonitor(name, Units.TICKS,
+ Variability.MONOTONIC, false, lb);
+ map.put(name, monitor);
+ }
+
+ /**
+ * Method that waits until the target jvm indicates that
+ * its shared memory is safe to access.
+ */
+ protected void synchWithTarget() throws MonitorException {
+ /*
+ * synch must happen with syncWaitMs from now. Default is 5 seconds,
+ * which is reasonabally generous and should provide for extreme
+ * situations like startup delays due to allocation of large ISM heaps.
+ */
+ long timeLimit = System.currentTimeMillis() + syncWaitMs;
+
+ // loop waiting for the accessible indicater to be non-zero
+ while (!prologue.isAccessible()) {
+
+ // give the target jvm a chance to complete initializatoin
+ try { Thread.sleep(20); } catch (InterruptedException e) { }
+
+ if (System.currentTimeMillis() > timeLimit) {
+ throw new MonitorException("Could not synchronize with target");
+ }
+ }
+ }
+
+ /**
+ * method to extract the next monitor entry from the instrumentation memory.
+ * assumes that nextEntry is the offset into the byte array
+ * at which to start the search for the next entry. method leaves
+ * next entry pointing to the next entry or to the end of data.
+ */
+ protected Monitor getNextMonitorEntry() throws MonitorException {
+ Monitor monitor = null;
+
+ // entries are always 4 byte aligned.
+ if ((nextEntry % 4) != 0) {
+ throw new MonitorStructureException(
+ "Misaligned entry index: "
+ + Integer.toHexString(nextEntry));
+ }
+
+ // protect againt a corrupted shard memory region.
+ if ((nextEntry < 0) || (nextEntry > buffer.limit())) {
+ throw new MonitorStructureException(
+ "Entry index out of bounds: "
+ + Integer.toHexString(nextEntry)
+ + ", limit = " + Integer.toHexString(buffer.limit()));
+ }
+
+ // check for end of the buffer
+ if (nextEntry == buffer.limit()) {
+ return null;
+ }
+
+ buffer.position(nextEntry);
+
+ int entryStart = buffer.position();
+ int entryLength = buffer.getInt();
+
+ // check for valid entry length
+ if ((entryLength < 0) || (entryLength > buffer.limit())) {
+ throw new MonitorStructureException(
+ "Invalid entry length: entryLength = " + entryLength
+ + " (0x" + Integer.toHexString(entryLength) + ")");
+ }
+
+ // check if last entry occurs before the eof.
+ if ((entryStart + entryLength) > buffer.limit()) {
+ throw new MonitorStructureException(
+ "Entry extends beyond end of buffer: "
+ + " entryStart = 0x" + Integer.toHexString(entryStart)
+ + " entryLength = 0x" + Integer.toHexString(entryLength)
+ + " buffer limit = 0x" + Integer.toHexString(buffer.limit()));
+ }
+
+ if (entryLength == 0) {
+ // end of data
+ return null;
+ }
+
+ // we can safely read this entry
+ int nameOffset = buffer.getInt();
+ int vectorLength = buffer.getInt();
+ byte typeCodeByte = buffer.get();
+ byte flags = buffer.get();
+ byte unitsByte = buffer.get();
+ byte varByte = buffer.get();
+ int dataOffset = buffer.getInt();
+
+ // convert common attributes to their object types
+ Units units = Units.toUnits(unitsByte);
+ Variability variability = Variability.toVariability(varByte);
+ TypeCode typeCode = null;
+ boolean supported = (flags & 0x01) != 0;
+
+ try {
+ typeCode = TypeCode.toTypeCode(typeCodeByte);
+
+ } catch (IllegalArgumentException e) {
+ throw new MonitorStructureException(
+ "Illegal type code encountered:"
+ + " entry_offset = 0x" + Integer.toHexString(nextEntry)
+ + ", type_code = " + Integer.toHexString(typeCodeByte));
+ }
+
+ // verify that the name_offset is contained within the entry bounds
+ if (nameOffset > entryLength) {
+ throw new MonitorStructureException(
+ "Field extends beyond entry bounds"
+ + " entry_offset = 0x" + Integer.toHexString(nextEntry)
+ + ", name_offset = 0x" + Integer.toHexString(nameOffset));
+ }
+
+ // verify that the data_offset is contained within the entry bounds
+ if (dataOffset > entryLength) {
+ throw new MonitorStructureException(
+ "Field extends beyond entry bounds:"
+ + " entry_offset = 0x" + Integer.toHexString(nextEntry)
+ + ", data_offset = 0x" + Integer.toHexString(dataOffset));
+ }
+
+ // validate the variability and units fields
+ if (variability == Variability.INVALID) {
+ throw new MonitorDataException(
+ "Invalid variability attribute:"
+ + " entry_offset = 0x" + Integer.toHexString(nextEntry)
+ + ", variability = 0x" + Integer.toHexString(varByte));
+ }
+
+ if (units == Units.INVALID) {
+ throw new MonitorDataException(
+ "Invalid units attribute: entry_offset = 0x"
+ + Integer.toHexString(nextEntry)
+ + ", units = 0x" + Integer.toHexString(unitsByte));
+ }
+
+ // the entry looks good - parse the variable length components
+
+ /*
+ * The name starts at nameOffset and continues up to the first null
+ * byte. however, we don't know the length, but we can approximate it
+ * without searching for the null by using the offset for the data
+ * field, which follows the name field.
+ */
+ assert (buffer.position() == (entryStart + nameOffset));
+ assert (dataOffset > nameOffset);
+
+ // include possible pad space
+ int maxNameLength = dataOffset-nameOffset;
+
+ // maxNameLength better be less than the total entry length
+ assert (maxNameLength < entryLength);
+
+ // collect the characters, but do not collect the null byte,
+ // as the String(byte[]) constructor does not ignore it!
+ byte[] nameBytes = new byte[maxNameLength];
+ int nameLength = 0;
+ byte b;
+ while (((b = buffer.get()) != 0) && (nameLength < maxNameLength)) {
+ nameBytes[nameLength++] = b;
+ }
+
+ assert (nameLength < maxNameLength);
+
+ // we should before or at the start of the data field
+ assert (buffer.position() <= (entryStart + dataOffset));
+
+ // convert the name bytes into a String
+ String name = new String(nameBytes, 0, nameLength);
+
+ /*
+ * compute the size of the data item - this includes pad
+ * characters used to align the next entry.
+ */
+ int dataSize = entryLength - dataOffset;
+
+ // set the position to the start of the data item
+ buffer.position(entryStart + dataOffset);
+
+ if (vectorLength == 0) {
+ // create a scalar Monitor object
+ if (typeCode == TypeCode.LONG) {
+ LongBuffer lb = buffer.asLongBuffer();
+ lb.limit(1); // limit buffer size to one long value.
+ monitor = new PerfLongMonitor(name, units, variability,
+ supported, lb);
+ } else {
+ /*
+ * unexpected type code - coding error or uncoordinated
+ * JVM change
+ */
+ throw new MonitorTypeException(
+ "Unexpected type code encountered:"
+ + " entry_offset = 0x" + Integer.toHexString(nextEntry)
+ + ", name = " + name
+ + ", type_code = " + typeCode
+ + " (0x" + Integer.toHexString(typeCodeByte) + ")");
+ }
+ } else {
+ // create a vector Monitor object
+ if (typeCode == TypeCode.BYTE) {
+ if (units != Units.STRING) {
+ // only byte arrays of type STRING are currently supported
+ throw new MonitorTypeException(
+ "Unexpected vector type encounterd:"
+ + " entry_offset = "
+ + Integer.toHexString(nextEntry)
+ + ", name = " + name
+ + ", type_code = " + typeCode + " (0x"
+ + Integer.toHexString(typeCodeByte) + ")"
+ + ", units = " + units + " (0x"
+ + Integer.toHexString(unitsByte) + ")");
+ }
+
+ ByteBuffer bb = buffer.slice();
+ bb.limit(vectorLength); // limit buffer length to # of chars
+
+ if (variability == Variability.CONSTANT) {
+ monitor = new PerfStringConstantMonitor(name, supported,
+ bb);
+ } else if (variability == Variability.VARIABLE) {
+ monitor = new PerfStringVariableMonitor(name, supported,
+ bb, vectorLength-1);
+ } else if (variability == Variability.MONOTONIC) {
+ // Monotonically increasing byte arrays are not supported
+ throw new MonitorDataException(
+ "Unexpected variability attribute:"
+ + " entry_offset = 0x"
+ + Integer.toHexString(nextEntry)
+ + " name = " + name
+ + ", variability = " + variability + " (0x"
+ + Integer.toHexString(varByte) + ")");
+ } else {
+ // variability was validated above, so this unexpected
+ assert false;
+ }
+ } else {
+ // coding error or uncoordinated JVM change
+ throw new MonitorTypeException(
+ "Unexpected type code encountered:"
+ + " entry_offset = 0x"
+ + Integer.toHexString(nextEntry)
+ + ", name = " + name
+ + ", type_code = " + typeCode + " (0x"
+ + Integer.toHexString(typeCodeByte) + ")");
+ }
+ }
+
+ // setup index to next entry for next iteration of the loop.
+ nextEntry = entryStart + entryLength;
+ return monitor;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBufferPrologue.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.v2_0;
+
+import sun.jvmstat.monitor.*;
+import sun.jvmstat.perfdata.monitor.*;
+import java.nio.*;
+
+/**
+ * Class representing the 2.0 version of the HotSpot PerfData instrumentation
+ * buffer header.
+ * <p>
+ * The PerfDataBufferPrologue class supports parsing of the version
+ * specific portions of the PerfDataPrologue C structure:
+ * <pre>
+ * typedef struct {
+ * ... // handled by superclass
+ * jint used; // number of PerfData memory bytes used
+ * jint overflow; // number of bytes of overflow
+ * jlong mod_time_stamp; // time stamp of the last structural modification
+ * jint entry_offset; // offset of the first PerfDataEntry
+ * jint num_entries; // number of allocated PerfData entries
+ * } PerfDataPrologue
+ * </pre>
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class PerfDataBufferPrologue extends AbstractPerfDataBufferPrologue {
+
+ private final static int SUPPORTED_MAJOR_VERSION = 2;
+ private final static int SUPPORTED_MINOR_VERSION = 0;
+
+ /*
+ * the following constants must match the field offsets and sizes
+ * in the PerfDataPrologue structure in perfMemory.hpp. offsets are
+ * relative to the start of the PerfDataPrologue structure.
+ *
+ * note that PERFDATA_PROLOG_ACCESSIBLE_OFFSET redefines
+ * PERFDATA_PROLOG_RESERVEDB1_OFFSET from AbstractPerfDataBufferPrologue.
+ */
+ final static int PERFDATA_PROLOG_ACCESSIBLE_OFFSET=7;
+ final static int PERFDATA_PROLOG_ACCESSIBLE_SIZE=1; // sizeof(byte)
+ final static int PERFDATA_PROLOG_USED_OFFSET=8;
+ final static int PERFDATA_PROLOG_USED_SIZE=4; // sizeof(int)
+ final static int PERFDATA_PROLOG_OVERFLOW_OFFSET=12;
+ final static int PERFDATA_PROLOG_OVERFLOW_SIZE=4; // sizeof(int)
+ final static int PERFDATA_PROLOG_MODTIMESTAMP_OFFSET=16;
+ final static int PERFDATA_PROLOG_MODTIMESTAMP_SIZE=8; // sizeof(long)
+ final static int PERFDATA_PROLOG_ENTRYOFFSET_OFFSET=24;
+ final static int PERFDATA_PROLOG_ENTRYOFFSET_SIZE=4; // sizeof(int)
+ final static int PERFDATA_PROLOG_NUMENTRIES_OFFSET=28;
+ final static int PERFDATA_PROLOG_NUMENTRIES_SIZE=4; // sizeof(int)
+
+ final static int PERFDATA_PROLOG_SIZE=32; // sizeof(struct PerfDataProlog)
+
+ // names for counters that expose prologue fields
+ final static String PERFDATA_BUFFER_SIZE_NAME = "sun.perfdata.size";
+ final static String PERFDATA_BUFFER_USED_NAME = "sun.perfdata.used";
+ final static String PERFDATA_OVERFLOW_NAME = "sun.perfdata.overflow";
+ final static String PERFDATA_MODTIMESTAMP_NAME = "sun.perfdata.timestamp";
+ final static String PERFDATA_NUMENTRIES_NAME = "sun.perfdata.entries";
+
+ /**
+ * Create an instance of PerfDataBufferPrologue from the given
+ * ByteBuffer object.
+ *
+ * @param byteBuffer the buffer containing the binary header data
+ */
+ public PerfDataBufferPrologue(ByteBuffer byteBuffer)
+ throws MonitorException {
+ super(byteBuffer);
+ assert ((getMajorVersion() == 2) && (getMinorVersion() == 0));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean supportsAccessible() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAccessible() {
+ assert supportsAccessible();
+ byteBuffer.position(PERFDATA_PROLOG_ACCESSIBLE_OFFSET);
+ byte value = byteBuffer.get();
+ return value != 0;
+ }
+
+ /**
+ * Get the utilization of the instrumentation memory buffer.
+ *
+ * @return int - the utilization of the buffer
+ */
+ public int getUsed() {
+ byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
+ return byteBuffer.getInt();
+ }
+
+ /**
+ * Get the size of the instrumentation memory buffer.
+ *
+ * @return int - the size of the buffer
+ */
+ public int getBufferSize() {
+ return byteBuffer.capacity();
+ }
+
+ /**
+ * Get the buffer overflow amount. This value is non-zero if the
+ * HotSpot JVM has overflowed the instrumentation memory buffer.
+ * The target JVM can be restarted with -XX:PerfDataMemSize=X to
+ * create a larger memory buffer.
+ *
+ * @return int - the size of the buffer
+ */
+ public int getOverflow() {
+ byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
+ return byteBuffer.getInt();
+ }
+
+ /**
+ * Get the time of last modification for the instrumentation
+ * memory buffer. This method returns the time, as ticks since the
+ * start of the target JVM, of the last structural modification to
+ * the instrumentation buffer. Structural modifications correspond to
+ * the addition or deletion of instrumentation objects. Updates to
+ * counter values are not structural modifications.
+ */
+ public long getModificationTimeStamp() {
+ byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
+ return byteBuffer.getLong();
+ }
+
+ /**
+ * Get the offset of the first PerfDataEntry.
+ */
+ public int getEntryOffset() {
+ byteBuffer.position(PERFDATA_PROLOG_ENTRYOFFSET_OFFSET);
+ return byteBuffer.getInt();
+ }
+
+ /**
+ * Get the offset of the first PerfDataEntry.
+ */
+ public int getNumEntries() {
+ byteBuffer.position(PERFDATA_PROLOG_NUMENTRIES_OFFSET);
+ return byteBuffer.getInt();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getSize() {
+ return PERFDATA_PROLOG_SIZE; // sizeof(struct PerfDataProlog)
+ }
+
+ /**
+ * Return an IntBuffer that accesses the used value. This is used
+ * to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the used value
+ * in the instrumentation buffer header.
+ * @see #getUsed()
+ */
+ IntBuffer usedBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
+ IntBuffer ib = byteBuffer.asIntBuffer();
+ ib.limit(1);
+ return ib;
+ }
+
+ /**
+ * Return an IntBuffer that accesses the size value. This is used
+ * to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the size value
+ * in the instrumentation buffer header.
+ * @see #getBufferSize()
+ */
+ IntBuffer sizeBuffer() {
+ IntBuffer ib = IntBuffer.allocate(1);
+ ib.put(byteBuffer.capacity());
+ return ib;
+ }
+
+ /**
+ * Return an IntBuffer that accesses the overflow value. This is used
+ * to create a Monitor object for this value.
+ *
+ * @return IntBuffer - a ByteBuffer that accesses the overflow value
+ * in the instrumentation buffer header.
+ * @see #getOverflow()
+ */
+ IntBuffer overflowBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
+ IntBuffer ib = byteBuffer.asIntBuffer();
+ ib.limit(1);
+ return ib;
+ }
+
+ /**
+ * Return a LongBuffer that accesses the modification timestamp value.
+ * This is used to create a Monitor object for this value.
+ *
+ * @return LongBuffer - a ByteBuffer that accesses the modification time
+ * stamp value in the instrumentation buffer header.
+ * @see #getModificationTimeStamp()
+ */
+ LongBuffer modificationTimeStampBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
+ LongBuffer lb = byteBuffer.asLongBuffer();
+ lb.limit(1);
+ return lb;
+ }
+
+ /**
+ * Return an IntBuffer that accesses the number of entries value.
+ * This is used to create a Monitor object for this value.
+ *
+ * @return LongBuffer - a ByteBuffer that accesses the num_entries
+ * value in the instrumentation buffer header.
+ * @see #getNumEntries()
+ */
+ IntBuffer numEntriesBuffer() {
+ byteBuffer.position(PERFDATA_PROLOG_NUMENTRIES_OFFSET);
+ IntBuffer ib = byteBuffer.asIntBuffer();
+ ib.limit(1);
+ return ib;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/TypeCode.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.jvmstat.perfdata.monitor.v2_0;
+
+/**
+ * A typesafe enumeration for describing standard Java type codes.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public class TypeCode {
+
+ private final String name;
+ private final char value;
+
+ public static final TypeCode BOOLEAN = new TypeCode("boolean", 'Z');
+ public static final TypeCode CHAR = new TypeCode("char", 'C');
+ public static final TypeCode FLOAT = new TypeCode("float", 'F');
+ public static final TypeCode DOUBLE = new TypeCode("double", 'D');
+ public static final TypeCode BYTE = new TypeCode("byte", 'B');
+ public static final TypeCode SHORT = new TypeCode("short", 'S');
+ public static final TypeCode INT = new TypeCode("int", 'I');
+ public static final TypeCode LONG = new TypeCode("long", 'J');
+ public static final TypeCode OBJECT = new TypeCode("object", 'L');
+ public static final TypeCode ARRAY = new TypeCode("array", '[');
+ public static final TypeCode VOID = new TypeCode("void", 'V');
+
+ private static TypeCode basicTypes[] = {
+ LONG, BYTE, BOOLEAN, CHAR, FLOAT, DOUBLE,
+ SHORT, INT, OBJECT, ARRAY, VOID
+ };
+
+ /**
+ * Convert enumeration value to a String.
+ *
+ * @return String - the string representation for the enumeration.
+ */
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Convert enumeration to its character representation.
+ *
+ * @return int - the integer representation for the enumeration.
+ */
+ public int toChar() {
+ return value;
+ }
+
+ /**
+ * Map a character value to its corresponding TypeCode object.
+ *
+ * @param c an character representing a Java TypeCode
+ * @return TypeCode - The TypeCode enumeration object for the given
+ * character.
+ * @throws IllegalArgumentException Thrown if <code>c</code> is not
+ * a valid Java TypeCode.
+ */
+ public static TypeCode toTypeCode(char c) {
+ for (int j = 0; j < basicTypes.length; j++) {
+ if (basicTypes[j].value == c) {
+ return (basicTypes[j]);
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * Map a character value to its corresponding TypeCode object.
+ *
+ * @param b a byte representing a Java TypeCode. This value is
+ * converted into a char and used to find the corresponding
+ * TypeCode.
+ * @return TypeCode - The TypeCode enumeration object for the given byte.
+ * @throws IllegalArgumentException Thrown if <code>v</code> is not
+ * a valid Java TypeCode.
+ */
+ public static TypeCode toTypeCode(byte b) {
+ return toTypeCode((char)b);
+ }
+
+ private TypeCode(String name, char value) {
+ this.name = name;
+ this.value = value;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/resources/aliasmap Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,593 @@
+/*
+*
+* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
+* particular file as subject to the "Classpath" exception as provided
+* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*/
+
+/*
+ * This file provides the mappings for renamed counters. The key for the
+ * mapping is the counter name of the counter in the latest release, and
+ * follows the reserved word 'alias'. Following the key counter name is
+ * a white space separated list of counter names from previous releases.
+ * The convention is to order these alias names from newest to oldest
+ * releases, but this is only a convention.
+ *
+ * The counter name aliasing mechanism does not provide for aliases that
+ * are dynamcially generated based on some JVM configuration parameters.
+ * For such cases, the largest possible set of counter names must be
+ * explicitly enumerated in this file. It does not provide for aliases
+ * that have dependencies on the values of other counters, resulting in
+ * one-to-many mappings.
+ */
+
+/***************************** java.* counters *****************************/
+// java.ci
+alias java.ci.totalTime // 1.5.0 b39
+ hotspot.ci.total.time // 1.4.1
+
+// java.cls
+alias java.cls.loadedClasses // 1.5.0 b39
+ hotspot.rt.cl.classes.loaded // 1.4.1
+alias java.cls.unloadedClasses // 1.5.0 b39
+ hotspot.rt.cl.classes.unloaded // 1.4.1
+
+// java.property
+alias java.property.java.class.path // 1.5.0 b39
+ java.class.path // 1.4.1
+alias java.property.java.endorsed.dirs // 1.5.0 b39
+ java.endorsed.dirs // 1.4.1
+alias java.property.java.ext.dirs // 1.5.0 b39
+ java.ext.dirs // 1.4.1
+alias java.property.java.home // 1.5.0 b39
+ java.home // 1.4.1
+alias java.property.java.library.path // 1.5.0 b39
+ java.library.path // 1.4.1
+alias java.property.java.vm.info // 1.5.0 b39
+ java.vm.info // 1.4.1
+alias java.property.java.vm.name // 1.5.0 b39
+ java.vm.name // 1.4.1
+alias java.property.java.vm.specification.name // 1.5.0 b39
+ java.vm.specification.name // 1.4.1
+alias java.property.java.vm.specification.vendor // 1.5.0 b39
+ java.vm.specification.vendor // 1.4.1
+alias java.property.java.vm.specification.version // 1.5.0 b39
+ java.vm.specification.version // 1.4.1
+alias java.property.java.vm.vendor // 1.5.0 b39
+ java.vm.vendor // 1.4.1
+alias java.property.java.vm.version // 1.5.0 b39
+ java.vm.version // 1.4.1
+
+// java.rt
+alias java.rt.vmArgs // 1.5.0 b39
+ hotspot.vm.args // 1.4.1
+alias java.rt.vmFlags // 1.5.0 b39
+ hotspot.vm.flags // 1.4.1
+
+// java.threads
+alias java.threads.daemon // 1.5.0 b39
+ hotspot.threads.daemon.count // 1.4.1
+alias java.threads.live // 1.5.0 b39
+ hotspot.threads.live.count // 1.4.1
+alias java.threads.livePeak // 1.5.0 b39
+ hotspot.threads.live.peak // 1.4.1
+alias java.threads.started // 1.5.0 b39
+ hotspot.threads.total.created // 1.4.1
+
+/***************************** com.sun.* counters **************************/
+
+/***************************** sun.* counters ******************************/
+// sun.ci
+alias sun.ci.adapterThread.compiles // 1.5.0 b39
+ hotspot.ci.AdapterThread.compiles // 1.4.2
+alias sun.ci.adapterThread.method // 1.5.0 b39
+ hotspot.ci.AdapterThread.method // 1.4.2
+alias sun.ci.adapterThread.time // 1.5.0 b39
+ hotspot.ci.AdapterThread.time // 1.4.2
+alias sun.ci.adapterThread.type // 1.5.0 b39
+ hotspot.ci.AdapterThread.type // 1.4.2
+alias sun.ci.compilerThread.0.compiles // 1.5.0 b39
+ hotspot.ci.CompilerThread0.compiles // 1.4.2
+alias sun.ci.compilerThread.0.method // 1.5.0 b39
+ hotspot.ci.CompilerThread0.method // 1.4.2
+alias sun.ci.compilerThread.0.time // 1.5.0 b39
+ hotspot.ci.CompilerThread0.time // 1.4.2
+alias sun.ci.compilerThread.0.type // 1.5.0 b39
+ hotspot.ci.CompilerThread0.type // 1.4.2
+alias sun.ci.compilerThread.1.compiles // 1.5.0 b39
+ hotspot.ci.CompilerThread1.compiles // 1.4.2
+alias sun.ci.compilerThread.1.method // 1.5.0 b39
+ hotspot.ci.CompilerThread1.method // 1.4.2
+alias sun.ci.compilerThread.1.time // 1.5.0 b39
+ hotspot.ci.CompilerThread1.time // 1.4.2
+alias sun.ci.compilerThread.1.type // 1.5.0 b39
+ hotspot.ci.CompilerThread1.type // 1.4.2
+alias sun.ci.compilerThread.2.compiles // 1.5.0 b39
+ hotspot.ci.CompilerThread2.compiles // 1.4.2
+alias sun.ci.compilerThread.2.method // 1.5.0 b39
+ hotspot.ci.CompilerThread2.method // 1.4.2
+alias sun.ci.compilerThread.2.time // 1.5.0 b39
+ hotspot.ci.CompilerThread2.time // 1.4.2
+alias sun.ci.compilerThread.2.type // 1.5.0 b39
+ hotspot.ci.CompilerThread2.type // 1.4.2
+alias sun.ci.compilerThread.3.compiles // 1.5.0 b39
+ hotspot.ci.CompilerThread3.compiles // 1.4.2
+alias sun.ci.compilerThread.3.method // 1.5.0 b39
+ hotspot.ci.CompilerThread3.method // 1.4.2
+alias sun.ci.compilerThread.3.time // 1.5.0 b39
+ hotspot.ci.CompilerThread3.time // 1.4.2
+alias sun.ci.compilerThread.3.type // 1.5.0 b39
+ hotspot.ci.CompilerThread3.type // 1.4.2
+alias sun.ci.lastFailedMethod // 1.5.0 b39
+ hotspot.ci.failed.method // 1.4.2
+alias sun.ci.lastFailedType // 1.5.0 b39
+ hotspot.ci.failed.type // 1.4.2
+alias sun.ci.lastInvalidatedMethod // 1.5.0 b39
+ hotspot.ci.invalidated.method // 1.4.2
+alias sun.ci.lastInvalidatedType // 1.5.0 b39
+ hotspot.ci.invalidated.type // 1.4.2
+alias sun.ci.lastMethod // 1.5.0 b39
+ hotspot.ci.last.method // 1.4.2
+alias sun.ci.lastSize // 1.5.0 b39
+ hotspot.ci.last.size // 1.4.2
+alias sun.ci.lastType // 1.5.0 b39
+ hotspot.ci.last.type // 1.4.2
+alias sun.ci.nativeCompiles // 1.5.0 b39
+ hotspot.ci.native.compiles // 1.4.2
+alias sun.ci.nativeTime // 1.5.0 b39
+ hotspot.ci.native.time // 1.4.2
+alias sun.ci.nmethodCodeSize // 1.5.0 b39
+ hotspot.ci.nmethod.codesize // 1.4.2
+alias sun.ci.nmethodSize // 1.5.0 b39
+ hotspot.ci.nmethod.size // 1.4.2
+alias sun.ci.osrBytes // 1.5.0 b39
+ hotspot.ci.osr.bytes // 1.4.2
+alias sun.ci.osrCompiles // 1.5.0 b39
+ hotspot.ci.osr.compiles // 1.4.2
+alias sun.ci.osrTime // 1.5.0 b39
+ hotspot.ci.osr.time // 1.4.2
+alias sun.ci.standardBytes // 1.5.0 b39
+ hotspot.ci.standard.bytes // 1.4.2
+alias sun.ci.standardCompiles // 1.5.0 b39
+ hotspot.ci.standard.compiles // 1.4.2
+alias sun.ci.standardTime // 1.5.0 b39
+ hotspot.ci.standard.time // 1.4.2
+alias sun.ci.threads // 1.5.0 b39
+ hotspot.ci.threads // 1.4.2
+alias sun.ci.totalBailouts // 1.5.0 b39
+ hotspot.ci.total.bailout // 1.4.2
+alias sun.ci.totalCompiles // 1.5.0 b39
+ hotspot.ci.total.compiles // 1.4.2
+alias sun.ci.totalInvalidates // 1.5.0 b39
+ hotspot.ci.total.invalid // 1.4.2
+
+// sun.cls
+alias sun.cls.classInitTime // 1.5.0 b39
+ hotspot.rt.cl.class.init.time // 1.5.0 b21
+alias sun.cls.classVerifyTime // 1.5.0 b39
+ hotspot.rt.cl.class.verify.time // 1.5.0 b21
+alias sun.cls.initializedClasses // 1.5.0 b39
+ hotspot.rt.cl.classes.initialized // 1.5.0 b21
+alias sun.cls.loadedBytes // 1.5.0 b39
+ hotspot.rt.cl.bytes.loaded // 1.4.2
+alias sun.cls.methodBytes // 1.5.0 b39
+ hotspot.rt.cl.methods.size // 1.4.2
+alias sun.cls.time // 1.5.0 b39
+ hotspot.rt.cl.time // 1.4.2
+alias sun.cls.unloadedBytes // 1.5.0 b39
+ hotspot.rt.cl.bytes.unloaded // 1.4.2
+
+// sun.gc
+alias sun.gc.cause // 1.5.0 b39
+ hotspot.gc.cause // 1.4.2_02
+
+// sun.gc.collector.0
+alias sun.gc.collector.0.invocations // 1.5.0 b39
+ hotspot.gc.collector.0.invocations // 1.4.2
+ hotspot.gc.new.eden.invocations // 1.4.1
+alias sun.gc.collector.0.lastEntryTime // 1.5.0 b39
+ hotspot.gc.collector.0.last_entry // 1.4.2
+alias sun.gc.collector.0.lastExitTime // 1.5.0 b39
+ hotspot.gc.collector.0.last_exit // 1.4.2
+alias sun.gc.collector.0.name // 1.5.0 b39
+ hotspot.gc.collector.0.name // 1.4.2
+alias sun.gc.collector.0.time // 1.5.0 b39
+ hotspot.gc.collector.0.time // 1.4.2
+ hotspot.gc.new.eden.time // 1.4.1
+
+// sun.gc.collector.1
+alias sun.gc.collector.1.invocations // 1.5.0 b39
+ hotspot.gc.collector.1.invocations // 1.4.2
+ hotspot.gc.new.eden.invocations // 1.4.1
+alias sun.gc.collector.1.lastEntryTime // 1.5.0 b39
+ hotspot.gc.collector.1.last_entry // 1.4.2
+alias sun.gc.collector.1.lastExitTime // 1.5.0 b39
+ hotspot.gc.collector.1.last_exit // 1.4.2
+alias sun.gc.collector.1.name // 1.5.0 b39
+ hotspot.gc.collector.1.name // 1.4.2
+alias sun.gc.collector.1.time // 1.5.0 b39
+ hotspot.gc.collector.1.time // 1.4.2
+ hotspot.gc.new.eden.time // 1.4.1
+
+// sun.gc.finalizer
+alias sun.gc.finalizer.queue.length // 1.5.0 b39
+ hotspot.gc.finalizer.queue.length // 1.4.2
+alias sun.gc.finalizer.queue.maxLength // 1.5.0 b39
+ hotspot.gc.finalizer.queue.maxlength // 1.4.2
+alias sun.gc.finalizer.time // 1.5.0 b39
+ hotspot.gc.finalizer.ticks // 1.4.2
+alias sun.gc.finalizer.objects // 1.5.0 b39
+ hotspot.gc.finalizer.count // 1.4.2
+
+// sun.gc.generation.0.agetable
+alias sun.gc.generation.0.agetable.bytes.00 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.00 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.01 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.01 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.02 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.02 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.03 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.03 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.04 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.04 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.05 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.05 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.06 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.06 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.07 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.07 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.08 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.08 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.09 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.09 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.10 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.10 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.11 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.11 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.12 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.12 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.13 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.13 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.14 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.14 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.15 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.15 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.16 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.16 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.17 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.17 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.18 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.18 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.19 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.19 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.20 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.20 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.21 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.21 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.22 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.22 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.23 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.23 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.24 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.24 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.25 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.25 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.26 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.26 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.27 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.27 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.28 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.28 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.29 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.29 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.30 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.30 // 1.4.1
+alias sun.gc.generation.0.agetable.bytes.31 // 1.5.0 b39
+ hotspot.gc.agetable.bytes.31 // 1.4.1
+alias sun.gc.generation.0.agetable.size // 1.5.0 b39
+ hotspot.gc.agetable.size // 1.4.1
+
+// sun.gc.generation.0
+alias sun.gc.generation.0.capacity // 1.5.0 b39
+ hotspot.gc.generation.0.capacity.current // 1.4.2
+alias sun.gc.generation.0.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.0.capacity.max // 1.4.2
+alias sun.gc.generation.0.minCapacity // 1.5.0 b39
+ hotspot.gc.generation.0.capacity.min // 1.4.2
+alias sun.gc.generation.0.name // 1.5.0 b39
+ hotspot.gc.generation.0.name // 1.4.2
+alias sun.gc.generation.0.space.0.capacity // 1.5.0 b39
+ hotspot.gc.generation.0.space.0.capacity // 1.4.2
+ hotspot.gc.new.eden.capacity // 1.4.1
+alias sun.gc.generation.0.space.0.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.0.space.0.size // 1.4.2
+ hotspot.gc.new.eden.capacity // 1.4.1
+alias sun.gc.generation.0.space.0.name // 1.5.0 b39
+ hotspot.gc.generation.0.space.0.name // 1.4.2
+alias sun.gc.generation.0.space.0.used // 1.5.0 b39
+ hotspot.gc.generation.0.space.0.used // 1.4.2
+ hotspot.gc.new.eden.used // 1.4.1
+alias sun.gc.generation.0.space.1.capacity // 1.5.0 b39
+ hotspot.gc.generation.0.space.1.capacity // 1.4.2
+ hotspot.gc.new.s0.capacity // 1.4.1
+alias sun.gc.generation.0.space.1.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.0.space.1.size // 1.4.2
+ hotspot.gc.new.s0.capacity // 1.4.1
+alias sun.gc.generation.0.space.1.name // 1.5.0 b39
+ hotspot.gc.generation.0.space.1.name // 1.4.2
+alias sun.gc.generation.0.space.1.used // 1.5.0 b39
+ hotspot.gc.generation.0.space.1.used // 1.4.2
+ hotspot.gc.new.s0.used // 1.4.1
+alias sun.gc.generation.0.space.2.capacity // 1.5.0 b39
+ hotspot.gc.generation.0.space.2.capacity // 1.4.2
+ hotspot.gc.new.s1.capacity // 1.4.1
+alias sun.gc.generation.0.space.2.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.0.space.2.size // 1.4.2
+ hotspot.gc.new.s1.capacity // 1.4.1
+alias sun.gc.generation.0.space.2.name // 1.5.0 b39
+ hotspot.gc.generation.0.space.2.name // 1.4.2
+alias sun.gc.generation.0.space.2.used // 1.5.0 b39
+ hotspot.gc.generation.0.space.2.used // 1.4.2
+ hotspot.gc.new.s1.used // 1.4.1
+alias sun.gc.generation.0.spaces // 1.5.0 b39
+ hotspot.gc.generation.0.spaces // 1.4.2
+alias sun.gc.generation.0.threads // 1.5.0 b39
+ hotspot.gc.generation.0.threads // 1.4.2
+
+// sun.gc.generation.1
+alias sun.gc.generation.1.capacity // 1.5.0 b39
+ hotspot.gc.generation.1.capacity.current // 1.4.2
+alias sun.gc.generation.1.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.1.capacity.max // 1.4.2
+alias sun.gc.generation.1.minCapacity // 1.5.0 b39
+ hotspot.gc.generation.1.capacity.min // 1.4.2
+alias sun.gc.generation.1.name // 1.5.0 b39
+ hotspot.gc.generation.1.name // 1.4.2
+alias sun.gc.generation.1.space.0.capacity // 1.5.0 b39
+ hotspot.gc.generation.1.space.0.capacity // 1.4.2
+ hotspot.gc.tenured.capacity // 1.4.1
+alias sun.gc.generation.1.space.0.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.1.space.0.size // 1.4.2
+ hotspot.gc.tenured.capacity // 1.4.1
+alias sun.gc.generation.1.space.0.name // 1.5.0 b39
+ hotspot.gc.generation.1.space.0.name // 1.4.2
+alias sun.gc.generation.1.space.0.used // 1.5.0 b39
+ hotspot.gc.generation.1.space.0.used // 1.4.2
+ hotspot.gc.tenured.used // 1.4.1
+alias sun.gc.generation.1.spaces // 1.5.0 b39
+ hotspot.gc.generation.1.spaces // 1.4.2
+
+// sun.gc.generation.2
+alias sun.gc.generation.2.capacity // 1.5.0 b39
+ hotspot.gc.generation.2.capacity.current // 1.4.2
+alias sun.gc.generation.2.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.2.capacity.max // 1.4.2
+alias sun.gc.generation.2.minCapacity // 1.5.0 b39
+ hotspot.gc.generation.2.capacity.min // 1.4.2
+alias sun.gc.generation.2.name // 1.5.0 b39
+ hotspot.gc.generation.2.name // 1.4.2
+alias sun.gc.generation.2.space.0.capacity // 1.5.0 b39
+ hotspot.gc.generation.2.space.0.capacity // 1.4.2
+ hotspot.gc.perm.capacity // 1.4.1
+alias sun.gc.generation.2.space.0.maxCapacity // 1.5.0 b39
+ hotspot.gc.generation.2.space.0.size // 1.4.2
+ hotspot.gc.perm.capacity // 1.4.1
+alias sun.gc.generation.2.space.0.name // 1.5.0 b39
+ hotspot.gc.generation.2.space.0.name // 1.4.2
+alias sun.gc.generation.2.space.0.used // 1.5.0 b39
+ hotspot.gc.generation.2.space.0.used // 1.4.2
+ hotspot.gc.perm.used // 1.4.1
+alias sun.gc.generation.2.spaces // 1.5.0 b39
+ hotspot.gc.generation.2.spaces // 1.4.2
+
+// sun.gc
+alias sun.gc.lastCause // 1.5.0 b39
+ hotspot.gc.last_cause // 1.4.2_02
+
+// sun.gc.policy
+alias sun.gc.policy.avgBaseFootprint // 1.5.0 b39
+ hotspot.gc.policy.avg_base_footprint // 1.5.0 b21
+alias sun.gc.policy.avgMajorIntervalTime // 1.5.0 b39
+ hotspot.gc.policy.avg_major_interval // 1.5.0 b21
+alias sun.gc.policy.avgMajorPauseTime // 1.5.0 b39
+ hotspot.gc.policy.avg_major_pause // 1.5.0 b21
+alias sun.gc.policy.avgMinorIntervalTime // 1.5.0 b39
+ hotspot.gc.policy.avg_minor_interval // 1.5.0 b21
+alias sun.gc.policy.avgMinorPauseTime // 1.5.0 b39
+ hotspot.gc.policy.avg_minor_pause // 1.5.0 b21
+alias sun.gc.policy.avgOldLive // 1.5.0 b39
+ hotspot.gc.policy.avg_old_live // 1.5.0 b21
+alias sun.gc.policy.avgPretenuredPaddedAvg // 1.5.0 b39
+ hotspot.gc.policy.avg_pretenured_padded_avg // 1.5.0 b21
+alias sun.gc.policy.avgPromotedAvg // 1.5.0 b39
+ hotspot.gc.policy.avg_promoted_avg // 1.5.0 b21
+alias sun.gc.policy.avgPromotedDev // 1.5.0 b39
+ hotspot.gc.policy.avg_promoted_dev // 1.5.0 b21
+alias sun.gc.policy.avgPromotedPaddedAvg // 1.5.0 b39
+ hotspot.gc.policy.avg_promoted_padded_avg // 1.5.0 b21
+alias sun.gc.policy.avgSurvivedAvg // 1.5.0 b39
+ hotspot.gc.policy.avg_survived_avg // 1.5.0 b21
+alias sun.gc.policy.avgSurvivedDev // 1.5.0 b39
+ hotspot.gc.policy.avg_survived_dev // 1.5.0 b21
+alias sun.gc.policy.avgSurvivedPaddedAvg // 1.5.0 b39
+ hotspot.gc.policy.avg_survived_padded_avg // 1.5.0 b21
+alias sun.gc.policy.avgYoungLive // 1.5.0 b39
+ hotspot.gc.policy.avg_young_live // 1.5.0 b21
+alias sun.gc.policy.boundaryMoved // 1.5.0 b39
+ hotspot.gc.policy.boundary_moved // 1.5.0 b21
+alias sun.gc.policy.changeOldGenForMajPauses // 1.5.0 b39
+ hotspot.gc.policy.change_old_gen_for_maj_pauses // 1.5.0 b21
+alias sun.gc.policy.changeOldGenForMinPauses // 1.5.0 b39
+ hotspot.gc.policy.change_old_gen_for_min_pauses // 1.5.0 b21
+alias sun.gc.policy.changeYoungGenForMajPauses // 1.5.0 b39
+ hotspot.gc.policy.change_young_gen_for_maj_pauses // 1.5.0 b21
+alias sun.gc.policy.changeYoungGenForMinPauses // 1.5.0 b39
+ hotspot.gc.policy.change_young_gen_for_min_pauses // 1.5.0 b21
+alias sun.gc.policy.collectors // 1.5.0 b39
+ hotspot.gc.policy.collectors // 1.4.2
+alias sun.gc.policy.decideAtFullGc // 1.5.0 b39
+ hotspot.gc.policy.decide_at_full_gc // 1.5.0 b21
+alias sun.gc.policy.decreaseForFootprint // 1.5.0 b39
+ hotspot.gc.policy.decrease_for_footprint // 1.5.0 b21
+alias sun.gc.policy.decrementTenuringThresholdForGcCost // 1.5.0 b39
+ hotspot.gc.policy.decrement_tenuring_threshold_for_gc_cost // 1.5.0 b21
+alias sun.gc.policy.decrementTenuringThresholdForSurvivorLimit // 1.5.0 b39
+ hotspot.gc.policy.decrement_tenuring_threshold_for_survivor_limit // 1.5.0 b21
+alias sun.gc.policy.desiredSurvivorSize // 1.5.0 b39
+ hotspot.gc.policy.desired_survivor_size // 1.5.0 b21
+ hotspot.gc.agetable.dss // 1.4.1
+alias sun.gc.policy.edenSize // 1.5.0 b39
+ hotspot.gc.policy.eden_size // 1.5.0 b21
+alias sun.gc.policy.freeSpace // 1.5.0 b39
+ hotspot.gc.policy.free_space // 1.5.0 b21
+alias sun.gc.policy.fullFollowsScavenge // 1.5.0 b39
+ hotspot.gc.policy.full_follows_scavenge // 1.5.0 b21
+alias sun.gc.policy.gcTimeLimitExceeded // 1.5.0 b39
+ hotspot.gc.policy.gc_time_limit_exceeded // 1.5.0 b21
+alias sun.gc.policy.generations // 1.5.0 b39
+ hotspot.gc.policy.generations // 1.4.2
+alias sun.gc.policy.increaseOldGenForThroughput // 1.5.0 b39
+ hotspot.gc.policy.increase_old_gen_for_throughput // 1.5.0 b21
+alias sun.gc.policy.increaseYoungGenForThroughput // 1.5.0 b39
+ hotspot.gc.policy.increase_young_gen_for_throughput // 1.5.0 b21
+alias sun.gc.policy.incrementTenuringThresholdForGcCost // 1.5.0 b39
+ hotspot.gc.policy.increment_tenuring_threshold_for_gc_cost // 1.5.0 b21
+alias sun.gc.policy.liveAtLastFullGc // 1.5.0 b39
+ hotspot.gc.policy.live_at_last_full_gc // 1.5.0 b21
+alias sun.gc.policy.liveSpace // 1.5.0 b39
+ hotspot.gc.policy.live_space // 1.5.0 b21
+alias sun.gc.policy.majorCollectionSlope // 1.5.0 b39
+ hotspot.gc.policy.major_collection_slope // 1.5.0 b21
+alias sun.gc.policy.majorGcCost // 1.5.0 b39
+ hotspot.gc.policy.major_gc_cost // 1.5.0 b21
+alias sun.gc.policy.majorPauseOldSlope // 1.5.0 b39
+ hotspot.gc.policy.major_pause_old_slope // 1.5.0 b21
+alias sun.gc.policy.majorPauseYoungSlope // 1.5.0 b39
+ hotspot.gc.policy.major_pause_young_slope // 1.5.0 b21
+alias sun.gc.policy.maxTenuringThreshold // 1.5.0 b39
+ hotspot.gc.max_tenuring_threshold // 1.5.0 b21
+ hotspot.gc.agetable.mtt // 1.4.1
+alias sun.gc.policy.minorCollectionSlope // 1.5.0 b39
+ hotspot.gc.policy.minor_collection_slope // 1.5.0 b21
+alias sun.gc.policy.minorGcCost // 1.5.0 b39
+ hotspot.gc.policy.minor_gc_cost // 1.5.0 b21
+alias sun.gc.policy.minorPauseOldSlope // 1.5.0 b39
+ hotspot.gc.policy.minor_pause_old_slope // 1.5.0 b21
+alias sun.gc.policy.minorPauseYoungSlope // 1.5.0 b39
+ hotspot.gc.policy.minor_pause_young_slope // 1.5.0 b21
+alias sun.gc.policy.mutatorCost // 1.5.0 b39
+ hotspot.gc.policy.mutator_cost // 1.5.0 b21
+alias sun.gc.policy.name // 1.5.0 b39
+ hotspot.gc.policy.name // 1.5.0 b21
+alias sun.gc.policy.oldCapacity // 1.5.0 b39
+ hotspot.gc.policy.old_capacity // 1.5.0 b21
+alias sun.gc.policy.oldEdenSize // 1.5.0 b39
+ hotspot.gc.policy.old_eden_size // 1.5.0 b21
+alias sun.gc.policy.oldPromoSize // 1.5.0 b39
+ hotspot.gc.policy.old_promo_size // 1.5.0 b21
+alias sun.gc.policy.promoSize // 1.5.0 b39
+ hotspot.gc.policy.promo_size // 1.5.0 b21
+alias sun.gc.policy.promoted // 1.5.0 b39
+ hotspot.gc.policy.promoted // 1.5.0 b21
+alias sun.gc.policy.scavengeSkipped // 1.5.0 b39
+ hotspot.gc.policy.scavenge_skipped // 1.5.0 b21
+alias sun.gc.policy.survived // 1.5.0 b39
+ hotspot.gc.policy.survived // 1.5.0 b21
+alias sun.gc.policy.survivorOverflowed // 1.5.0 b39
+ hotspot.gc.policy.survivor_overflowed // 1.5.0 b21
+alias sun.gc.policy.tenuringThreshold // 1.5.0 b39
+ hotspot.gc.policy.tenuring_threshold // 1.5.0 b21
+ hotspot.gc.agetable.tt // 1.4.1
+alias sun.gc.policy.youngCapacity // 1.5.0 b39
+ hotspot.gc.policy.young_capacity // 1.5.0 b21
+
+// sun.gc.tlab
+alias sun.gc.tlab.alloc // 1.5.0 b39
+ hotspot.gc.tlab.alloc // 1.5.0 b21
+alias sun.gc.tlab.allocThreads // 1.5.0 b39
+ hotspot.gc.tlab.alloc_thrds // 1.5.0 b21
+alias sun.gc.tlab.fastWaste // 1.5.0 b39
+ hotspot.gc.tlab.fastwaste // 1.5.0 b21
+alias sun.gc.tlab.fills // 1.5.0 b39
+ hotspot.gc.tlab.fills // 1.5.0 b21
+alias sun.gc.tlab.gcWaste // 1.5.0 b39
+ hotspot.gc.tlab.gcwaste // 1.5.0 b21
+alias sun.gc.tlab.maxFastWaste // 1.5.0 b39
+ hotspot.gc.tlab.maxfastwaste // 1.5.0 b21
+alias sun.gc.tlab.maxFills // 1.5.0 b39
+ hotspot.gc.tlab.maxfills // 1.5.0 b21
+alias sun.gc.tlab.maxGcWaste // 1.5.0 b39
+ hotspot.gc.tlab.maxgcwaste // 1.5.0 b21
+alias sun.gc.tlab.maxSlowAlloc // 1.5.0 b39
+ hotspot.gc.tlab.maxslowalloc // 1.5.0 b21
+alias sun.gc.tlab.maxSlowWaste // 1.5.0 b39
+ hotspot.gc.tlab.maxslowwaste // 1.5.0 b21
+alias sun.gc.tlab.slowAlloc // 1.5.0 b39
+ hotspot.gc.tlab.slowalloc // 1.5.0 b21
+alias sun.gc.tlab.slowWaste // 1.5.0 b39
+ hotspot.gc.tlab.slowwaste // 1.5.0 b21
+
+// sun.os
+alias sun.os.hrt.frequency // 1.5.0 b39
+ hotspot.rt.hrt.frequency // 1.4.1
+alias sun.os.hrt.ticks // 1.5.0 b39
+ hotspot.rt.hrt.ticks // 1.4.1
+
+// sun.perfdata
+alias sun.perfdata.overflow // 1.5.0 b39
+ hotspot.perfdata.overflow // 1.4.1
+alias sun.perfdata.size // 1.5.0 b39
+ hotspot.perfdata.size // 1.4.1
+alias sun.perfdata.timestamp // 1.5.0 b39
+ hotspot.perfdata.timestamp // 1.4.1
+alias sun.perfdata.used // 1.5.0 b39
+ hotspot.perfdata.used // 1.4.1
+alias sun.perfdata.majorVersion // 1.5.0 b39
+ hotspot.perfdata.version.major // 1.4.1
+alias sun.perfdata.minorVersion // 1.5.0 b39
+ hotspot.perfdata.version.minor // 1.4.1
+
+// sun.property
+alias sun.property.sun.boot.class.path // 1.5.0 b39
+ sun.boot.class.path // 1.4.1
+alias sun.property.sun.boot.library.path // 1.5.0 b39
+ sun.boot.library.path // 1.4.1
+
+// sun.rt
+alias sun.rt.applicationTime // 1.5.0 b39
+ hotspot.rt.application.time // 1.5.0 b21
+alias sun.rt.createVmBeginTime // 1.5.0 b39
+ hotspot.rt.vm.create.begin // 1.5.0 b21
+alias sun.rt.createVmEndTime // 1.5.0 b39
+ hotspot.rt.vm.create.end // 1.5.0 b21
+alias sun.rt.internalVersion // 1.5.0 b39
+ hotspot.internal.version // 1.5.0 b21
+alias sun.rt.javaCommand // 1.5.0 b39
+ sun.java.command // 1.4.1
+alias sun.rt.safepointSyncTime // 1.5.0 b39
+ hotspot.rt.safepoint.sync.time // 1.5.0 b21
+alias sun.rt.safepointTime // 1.5.0 b39
+ hotspot.rt.safepoint.time // 1.5.0 b21
+alias sun.rt.safepoints // 1.5.0 b39
+ hotspot.rt.safepoint.count // 1.5.0 b21
+alias sun.rt.vmInitDoneTime // 1.5.0 b39
+ hotspot.rt.vm.init.done // 1.5.0 b21
--- a/jdk/src/jdk.jcmd/share/classes/module-info.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/jdk.jcmd/share/classes/module-info.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. 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
@@ -25,5 +25,5 @@
module jdk.jcmd {
requires jdk.attach;
- requires jdk.jvmstat;
+ requires jdk.internal.jvmstat;
}
--- a/jdk/src/jdk.jconsole/share/classes/module-info.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/jdk.jconsole/share/classes/module-info.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. 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
@@ -29,7 +29,7 @@
requires java.logging;
requires java.rmi;
requires jdk.attach;
- requires jdk.jvmstat;
+ requires jdk.internal.jvmstat;
requires jdk.management;
exports com.sun.tools.jconsole;
uses com.sun.tools.jconsole.JConsolePlugin;
--- a/jdk/src/jdk.jstatd/share/classes/module-info.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/src/jdk.jstatd/share/classes/module-info.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. 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
@@ -25,7 +25,7 @@
module jdk.jstatd {
requires java.rmi;
- requires jdk.jvmstat;
+ requires jdk.internal.jvmstat;
// RMI needs to serialize types in this package
exports sun.jvmstat.monitor.remote to java.rmi;
--- a/jdk/src/jdk.jvmstat/share/classes/module-info.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module jdk.jvmstat {
- exports sun.jvmstat.monitor to
- jdk.attach,
- jdk.jcmd,
- jdk.jconsole,
- jdk.jstatd;
- exports sun.jvmstat.monitor.event to
- jdk.jcmd,
- jdk.jstatd;
- exports sun.jvmstat.perfdata.monitor to
- jdk.jstatd;
-
- uses sun.jvmstat.monitor.MonitoredHostService;
- provides sun.jvmstat.monitor.MonitoredHostService with
- sun.jvmstat.perfdata.monitor.protocol.file.MonitoredHostFileService,
- sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostLocalService;
-}
-
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/AbstractMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * The base class for Instrumentation Monitoring Objects. This base class
- * provides implementations of the {@link Monitor} methods that are common
- * to all classes implementing the Monitor interface..
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public abstract class AbstractMonitor implements Monitor {
- protected String name;
- protected Units units;
- protected Variability variability;
- protected int vectorLength;
- protected boolean supported;
-
- /**
- * Create a vector instrumentation monitoring object with the given
- * name and attributes.
- *
- * @param name the name to assign to this instrumentation object.
- * @param units the units of measure attribute
- * @param variability the variability attribute
- * @param supported support level indicator
- * @param vectorLength the length of the vector, or 0 if not a vector type.
- */
- protected AbstractMonitor(String name, Units units, Variability variability,
- boolean supported, int vectorLength) {
- this.name = name;
- this.units = units;
- this.variability = variability;
- this.vectorLength = vectorLength;
- this.supported = supported;
- }
-
- /**
- * Create a scalar instrumentation monitoring object with the given
- * name and attributes.
- *
- * @param name the name to assign to this instrumentation object.
- * @param units the units of measure attribute
- * @param variability the variability attribute
- * @param supported support level indicator
- */
- protected AbstractMonitor(String name, Units units, Variability variability,
- boolean supported) {
- this(name, units, variability, supported, 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName() {
- return name;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getBaseName() {
- int baseIndex = name.lastIndexOf('.') + 1;
- return name.substring(baseIndex);
- }
-
- /**
- * {@inheritDoc}
- */
- public Units getUnits() {
- return units;
- }
-
- /**
- * {@inheritDoc}
- */
- public Variability getVariability() {
- return variability;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isVector() {
- return vectorLength > 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getVectorLength() {
- return vectorLength;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isSupported() {
- return supported;
- }
-
- /**
- * {@inheritDoc}
- */
- public abstract Object getValue();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/BufferedMonitoredVm.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-import sun.jvmstat.monitor.*;
-
-/**
- * Interface to support asynchronous polling of the exported
- * instrumentation of a target Java Virtual Machine.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public interface BufferedMonitoredVm extends MonitoredVm {
-
- /**
- * Interface to get the bytes associated with the instrumentation
- * for the target Java Virtual Machine.
- *
- * @return byte[] - a byte array containing the current bytes
- * for the instrumentation exported by the
- * target Java Virtual Machine.
- */
- byte[] getBytes();
-
- /**
- * Interface to get the size of the instrumentation buffer
- * for the target Java Virtual Machine.
- *
- * @return int - the size of the instrumentation buffer for the
- * target Java Virtual Machine.
- */
- int getCapacity();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/ByteArrayMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Interface for Monitoring ByteArrayInstrument objects.
- *
- * This interface is provided to support the StringMonitor interface. No
- * instrumentation objects of this direct type can currently be created
- * or monitored.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see sun.jvmstat.instrument.ByteArrayInstrument
- */
-public interface ByteArrayMonitor extends Monitor {
-
- /**
- * Get a copy of the current values of the elements of the
- * ByteArrayInstrument object.
- *
- * @return byte[] - a copy of the bytes in the associated
- * instrumenattion object.
- */
- public byte[] byteArrayValue();
-
- /**
- * Get the current value of an element of the ByteArrayInstrument object.
- *
- * @return byte - the byte value at the specified index in the
- * associated instrumentation object.
- */
- public byte byteAt(int index);
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/HostIdentifier.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,568 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-import java.net.*;
-
-/**
- * An abstraction that identifies a target host and communications
- * protocol. The HostIdentifier, or hostid, provides a convenient string
- * representation of the information needed to locate and communicate with
- * a target host. The string, based on a {@link URI}, may specify the
- * the communications protocol, host name, and protocol specific information
- * for a target host. The format for a HostIdentifier string is:
- * <pre>
- * [<I>protocol</I>:][[<I>//</I>]<I>hostname</I>][<I>:port</I>][<I>/servername</I>]
- * </pre>
- * There are actually no required components of this string, as a null string
- * is interpreted to mean a local connection to the local host and is equivalent
- * to the string <em>local://localhost</em>. The components of the
- * HostIdentifier are:
- * <ul>
- * <li><p>{@code protocol} - The communications protocol. If omitted,
- * and a hostname is not specified, then default local protocol,
- * <em>local:</em>, is assumed. If the protocol is omitted and a
- * hostname is specified then the default remote protocol,
- * <em>rmi:</em> is assumed.
- * </p></li>
- * <li><p>{@code hostname} - The hostname. If omitted, then
- * <em>localhost</em> is assumed. If the protocol is also omitted,
- * then default local protocol <em>local:</em> is also assumed.
- * If the hostname is not omitted but the protocol is omitted,
- * then the default remote protocol, <em>rmi:</em> is assumed.
- * </p></li>
- * <li><p>{@code port} - The port for the communications protocol.
- * Treatment of the {@code port} parameter is implementation
- * (protocol) specific. It is unused by the default local protocol,
- * <em>local:</em>. For the default remote protocol, <em>rmi:</em>,
- * {@code port} indicates the port number of the <em>rmiregistry</em>
- * on the target host and defaults to port 1099.
- * </p></li>
- * <li><p>{@code servername} - The treatment of the Path, Query, and
- * Fragment components of the HostIdentifier are implementation
- * (protocol) dependent. These components are ignored by the
- * default local protocol, <em>local:</em>. For the default remote
- * protocol, <em>rmi</em>, the Path component is interpreted as
- * the name of the RMI remote object. The Query component may
- * contain an access mode specifier <em>?mode=</em> specifying
- * <em>"r"</em> or <em>"rw"</em> access (write access currently
- * ignored). The Fragment part is ignored.
- * </p></li>
- * </ul>
- * <p>
- * All HostIdentifier objects are represented as absolute, hierarchical URIs.
- * The constructors accept relative URIs, but these will generally be
- * transformed into an absolute URI specifying a default protocol. A
- * HostIdentifier differs from a URI in that certain contractions and
- * illicit syntactical constructions are allowed. The following are all
- * valid HostIdentifier strings:
- *
- * <ul>
- * <li>{@code <null>} - transformed into "//localhost"</li>
- * <li>localhost - transformed into "//localhost"</li>
- * <li>hostname - transformed into "//hostname"</li>
- * <li>hostname:port - transformed into "//hostname:port"</li>
- * <li>proto:hostname - transformed into "proto://hostname"</li>
- * <li>proto:hostname:port - transformed into
- * "proto://hostname:port"</li>
- * <li>proto://hostname:port</li>
- * </ul>
- *
- * @see URI
- * @see VmIdentifier
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class HostIdentifier {
- private URI uri;
-
- /**
- * creates a canonical representation of the uriString. This method
- * performs certain translations depending on the type of URI generated
- * by the string.
- */
- private URI canonicalize(String uriString) throws URISyntaxException {
- if ((uriString == null) || (uriString.compareTo("localhost") == 0)) {
- uriString = "//localhost";
- return new URI(uriString);
- }
-
- URI u = new URI(uriString);
-
- if (u.isAbsolute()) {
- if (u.isOpaque()) {
- /*
- * this code is here to deal with a special case. For ease of
- * use, we'd like to be able to handle the case where the user
- * specifies hostname:port, not requiring the scheme part.
- * This introduces some subtleties.
- * hostname:port - scheme = hostname
- * - schemespecificpart = port
- * - hostname = null
- * - userinfo=null
- * however, someone could also enter scheme:hostname:port and
- * get into this code. the strategy is to consider this
- * syntax illegal and provide some code to defend against it.
- * Basically, we test that the string contains only one ":"
- * and that the ssp is numeric. If we get two colons, we will
- * attempt to insert the "//" after the first colon and then
- * try to create a URI from the resulting string.
- */
- String scheme = u.getScheme();
- String ssp = u.getSchemeSpecificPart();
- String frag = u.getFragment();
- URI u2 = null;
-
- int c1index = uriString.indexOf(':');
- int c2index = uriString.lastIndexOf(':');
- if (c2index != c1index) {
- /*
- * this is the scheme:hostname:port case. Attempt to
- * transform this to scheme://hostname:port. If a path
- * part is part of the original strings, it will be
- * included in the SchemeSpecificPart. however, the
- * fragment part must be handled separately.
- */
- if (frag == null) {
- u2 = new URI(scheme + "://" + ssp);
- } else {
- u2 = new URI(scheme + "://" + ssp + "#" + frag);
- }
- return u2;
- }
- /*
- * here we have the <string>:<string> case, possibly with
- * optional path and fragment components. we assume that
- * the part following the colon is a number. we don't check
- * this condition here as it will get detected later anyway.
- */
- u2 = new URI("//" + uriString);
- return u2;
- } else {
- return u;
- }
- } else {
- /*
- * This is the case where we were given a hostname followed
- * by a path part, fragment part, or both a path and fragment
- * part. The key here is that no scheme part was specified.
- * For this case, if the scheme specific part does not begin
- * with "//", then we prefix the "//" to the given string and
- * attempt to create a URI from the resulting string.
- */
- String ssp = u.getSchemeSpecificPart();
- if (ssp.startsWith("//")) {
- return u;
- } else {
- return new URI("//" + uriString);
- }
- }
- }
-
- /**
- * Create a HostIdentifier instance from a string value.
- *
- * @param uriString a string representing a target host. The syntax of
- * the string must conform to the rules specified in the
- * class documentation.
- *
- * @throws URISyntaxException Thrown when the uriString or its canonical
- * form is poorly formed. This exception may
- * get encapsulated into a MonitorException in
- * a future version.
- *
- */
- public HostIdentifier(String uriString) throws URISyntaxException {
- uri = canonicalize(uriString);
- }
-
- /**
- * Create a HostIdentifier instance from component parts of a URI.
- *
- * @param scheme the {@link URI#getScheme} component of a URI.
- * @param authority the {@link URI#getAuthority} component of a URI.
- * @param path the {@link URI#getPath} component of a URI.
- * @param query the {@link URI#getQuery} component of a URI.
- * @param fragment the {@link URI#getFragment} component of a URI.
- *
- * @throws URISyntaxException Thrown when the uriString or its canonical
- * form is poorly formed. This exception may
- * get encapsulated into a MonitorException in
- * a future version.
- * @see URI
- */
- public HostIdentifier(String scheme, String authority, String path,
- String query, String fragment)
- throws URISyntaxException {
- uri = new URI(scheme, authority, path, query, fragment);
- }
-
- /**
- * Create a HostIdentifier instance from a VmIdentifier.
- *
- * The necessary components of the VmIdentifier are extracted and
- * reassembled into a HostIdentifier. If a "file:" scheme (protocol)
- * is specified, the returned HostIdentifier will always be
- * equivalent to HostIdentifier("file://localhost").
- *
- * @param vmid the VmIdentifier use to construct the HostIdentifier.
- */
- public HostIdentifier(VmIdentifier vmid) {
- /*
- * Extract all components of the VmIdentifier URI except the
- * user-info part of the authority (the lvmid).
- */
- StringBuilder sb = new StringBuilder();
- String scheme = vmid.getScheme();
- String host = vmid.getHost();
- String authority = vmid.getAuthority();
-
- // check for 'file:' VmIdentifiers and handled as a special case.
- if ((scheme != null) && (scheme.compareTo("file") == 0)) {
- try {
- uri = new URI("file://localhost");
- } catch (URISyntaxException e) { };
- return;
- }
-
- if ((host != null) && (host.compareTo(authority) == 0)) {
- /*
- * this condition occurs when the VmIdentifier specifies only
- * the authority (i.e. the lvmid ), and not a host name.
- */
- host = null;
- }
-
- if (scheme == null) {
- if (host == null) {
- scheme = "local"; // default local scheme
- } else {
- /*
- * rmi is the default remote scheme. if the VmIdentifier
- * specifies some other protocol, this default is overridden.
- */
- scheme = "rmi";
- }
- }
-
- sb.append(scheme).append("://");
-
- if (host == null) {
- sb.append("localhost"); // default host name
- } else {
- sb.append(host);
- }
-
- int port = vmid.getPort();
- if (port != -1) {
- sb.append(":").append(port);
- }
-
- String path = vmid.getPath();
- if ((path != null) && (path.length() != 0)) {
- sb.append(path);
- }
-
- String query = vmid.getQuery();
- if (query != null) {
- sb.append("?").append(query);
- }
-
- String frag = vmid.getFragment();
- if (frag != null) {
- sb.append("#").append(frag);
- }
-
- try {
- uri = new URI(sb.toString());
- } catch (URISyntaxException e) {
- // shouldn't happen, as we were passed a valid VmIdentifier
- throw new RuntimeException("Internal Error", e);
- }
- }
-
- /**
- * Resolve a VmIdentifier with this HostIdentifier. A VmIdentifier, such
- * as <em>1234</em> or <em>1234@hostname</em> or any other string that
- * omits certain components of the URI string may be valid, but is certainly
- * incomplete. They are missing critical information for identifying the
- * the communications protocol, target host, or other parameters. A
- * VmIdentifier of this form is considered <em>unresolved</em>. This method
- * uses components of the HostIdentifier to resolve the missing components
- * of the VmIdentifier.
- * <p>
- * Specified components of the unresolved VmIdentifier take precedence
- * over their HostIdentifier counterparts. For example, if the VmIdentifier
- * indicates <em>1234@hostname:2099</em> and the HostIdentifier indicates
- * <em>rmi://hostname:1099/</em>, then the resolved VmIdentifier will
- * be <em>rmi://1234@hostname:2099</em>. Any component not explicitly
- * specified or assumed by the HostIdentifier, will remain unresolved in
- * resolved VmIdentifier.
- * <p>
- * A VmIdentifier specifying a <em>file:</em> scheme (protocol), is
- * not changed in any way by this method.
- *
- * @param vmid the unresolved VmIdentifier.
- * @return VmIdentifier - the resolved VmIdentifier. If vmid was resolved
- * on entry to this method, then the returned
- * VmIdentifier will be equal, but not identical, to
- * vmid.
- */
- public VmIdentifier resolve(VmIdentifier vmid)
- throws URISyntaxException, MonitorException {
- String scheme = vmid.getScheme();
- String host = vmid.getHost();
- String authority = vmid.getAuthority();
-
- if ((scheme != null) && (scheme.compareTo("file") == 0)) {
- // don't attempt to resolve a file based VmIdentifier.
- return vmid;
- }
-
- if ((host != null) && (host.compareTo(authority) == 0)) {
- /*
- * this condition occurs when the VmIdentifier specifies only
- * the authority (i.e. an lvmid), and not a host name.
- */
- host = null;
- }
-
- if (scheme == null) {
- scheme = getScheme();
- }
-
- URI nuri = null;
-
- StringBuilder sb = new StringBuilder();
-
- sb.append(scheme).append("://");
-
- String userInfo = vmid.getUserInfo();
- if (userInfo != null) {
- sb.append(userInfo);
- } else {
- sb.append(vmid.getAuthority());
- }
-
- if (host == null) {
- host = getHost();
- }
- sb.append("@").append(host);
-
- int port = vmid.getPort();
- if (port == -1) {
- port = getPort();
- }
-
- if (port != -1) {
- sb.append(":").append(port);
- }
-
- String path = vmid.getPath();
- if ((path == null) || (path.length() == 0)) {
- path = getPath();
- }
-
- if ((path != null) && (path.length() > 0)) {
- sb.append(path);
- }
-
- String query = vmid.getQuery();
- if (query == null) {
- query = getQuery();
- }
- if (query != null) {
- sb.append("?").append(query);
- }
-
- String fragment = vmid.getFragment();
- if (fragment == null) {
- fragment = getFragment();
- }
- if (fragment != null) {
- sb.append("#").append(fragment);
- }
-
- String s = sb.toString();
- return new VmIdentifier(s);
- }
-
- /**
- * Return the Scheme, or protocol, portion of this HostIdentifier.
- *
- * @return String - the scheme for this HostIdentifier.
- * @see URI#getScheme()
- */
- public String getScheme() {
- return uri.isAbsolute() ? uri.getScheme() : null;
- }
-
- /**
- * Return the Scheme Specific Part of this HostIdentifier.
- *
- * @return String - the scheme specific part for this HostIdentifier.
- * @see URI#getSchemeSpecificPart()
- */
- public String getSchemeSpecificPart() {
- return uri.getSchemeSpecificPart();
- }
-
- /**
- * Return the User Info part of this HostIdentifier.
- *
- * @return String - the user info part for this HostIdentifier.
- * @see URI#getUserInfo()
- */
- public String getUserInfo() {
- return uri.getUserInfo();
- }
-
- /**
- * Return the Host part of this HostIdentifier.
- *
- * @return String - the host part for this HostIdentifier, or
- * "localhost" if the URI.getHost() returns null.
- * @see URI#getUserInfo()
- */
- public String getHost() {
- return (uri.getHost() == null) ? "localhost" : uri.getHost();
- }
-
- /**
- * Return the Port for of this HostIdentifier.
- *
- * @return String - the port for this HostIdentifier
- * @see URI#getPort()
- */
- public int getPort() {
- return uri.getPort();
- }
-
- /**
- * Return the Path part of this HostIdentifier.
- *
- * @return String - the path part for this HostIdentifier.
- * @see URI#getPath()
- */
- public String getPath() {
- return uri.getPath();
- }
-
- /**
- * Return the Query part of this HostIdentifier.
- *
- * @return String - the query part for this HostIdentifier.
- * @see URI#getQuery()
- */
- public String getQuery() {
- return uri.getQuery();
- }
-
- /**
- * Return the Fragment part of this HostIdentifier.
- *
- * @return String - the fragment part for this HostIdentifier.
- * @see URI#getFragment()
- */
- public String getFragment() {
- return uri.getFragment();
- }
-
- /**
- * Return the mode indicated in this HostIdentifier.
- *
- * @return String - the mode string. If no mode is specified, then "r"
- * is returned. otherwise, the specified mode is returned.
- */
- public String getMode() {
- String query = getQuery();
- if (query != null) {
- String[] queryArgs = query.split("\\+");
- for (int i = 0; i < queryArgs.length; i++) {
- if (queryArgs[i].startsWith("mode=")) {
- int index = queryArgs[i].indexOf('=');
- return queryArgs[i].substring(index+1);
- }
- }
- }
- return "r";
- }
-
- /**
- * Return the URI associated with the HostIdentifier.
- *
- * @return URI - the URI.
- * @see URI
- */
- public URI getURI() {
- return uri;
- }
-
- /**
- * Return the hash code for this HostIdentifier. The hash code is
- * identical to the hash code for the contained URI.
- *
- * @return int - the hashcode.
- * @see URI#hashCode()
- */
- public int hashCode() {
- return uri.hashCode();
- }
-
- /**
- * Test for quality with other objects.
- *
- * @param object the object to be test for equality.
- * @return boolean - returns true if the given object is of type
- * HostIdentifier and its URI field is equal to this
- * object's URI field. Otherwise, returns false.
- *
- * @see URI#equals(Object)
- */
- public boolean equals(Object object) {
- if (object == this) {
- return true;
- }
- if (!(object instanceof HostIdentifier)) {
- return false;
- }
- return uri.equals(((HostIdentifier)object).uri);
- }
-
-
- /**
- * Convert to a string representation. Conversion is identical to
- * calling getURI().toString(). This may change in a future release.
- *
- * @return String - a String representation of the HostIdentifier.
- *
- * @see URI#toString()
- */
- public String toString() {
- return uri.toString();
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/IntegerMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Interface for Monitoring Integer Instrument Objects.
- *
- * The IntegerMonitor interface does not currently have a IntInstrument
- * counterpart. It is used in limited situations to expose certain
- * implementation specifics as performance counters. Typically,
- * a LongInstrument serves as a reasonable replacement for the
- * an IntInstrument class.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public interface IntegerMonitor extends Monitor {
-
- /**
- * Get the value of this Integer Instrumentation Object
- *
- * return int - the current value of this instrumentation object
- */
- public int intValue();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/LongMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Interface for Monitoring LongInstrument objects.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see sun.jvmstat.instrument.LongInstrument
- */
-public interface LongMonitor extends Monitor {
-
- /**
- * Get the current value of this LongInstrument object.
- *
- * @return long - the current value of the associated LongInstrument object.
- */
- public long longValue();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/Monitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Interface provided by Instrumentation Monitoring Objects.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public interface Monitor {
-
- /**
- * Returns the name of this instrumentation object.
- *
- * @return String - the name assigned to this instrumentation monitoring
- * object
- */
- String getName();
-
- /**
- * Returns the base name of this instrumentation object.
- * The base name is the component of the name following the last
- * "." character in the name.
- *
- * @return String - the base name of the name assigned to this
- * instrumentation monitoring object.
- */
- String getBaseName();
-
- /**
- * Returns the Units for this instrumentation monitoring object.
- *
- * @return Units - the units of measure attribute
- */
- Units getUnits();
-
- /**
- * Returns the Variability for this instrumentation object.
- *
- *@return Variability - the variability attribute
- */
- Variability getVariability();
-
- /**
- * Test if the instrumentation object is a vector type.
- *
- * @return boolean - true if this instrumentation object is a vector type,
- * false otherwise.
- */
- boolean isVector();
-
- /**
- * Return the length of the vector.
- * @return int - the length of the vector or zero if this instrumentation
- * object is a scalar type.
- */
- int getVectorLength();
-
- /**
- * Test if the instrumentation object is supported.
- */
- boolean isSupported();
-
- /**
- * Return an Object that encapsulates this instrumentation object's
- * current data value.
- */
- Object getValue();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitorException.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Base class for exceptions that occur while interfacing with the
- * Monitoring interfaces.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class MonitorException extends Exception {
-
- /**
- * Create a MonitorException
- */
- public MonitorException() {
- super();
- }
-
- /**
- * Create a MonitorException with the given message.
- *
- * @param message the message to associate with the exception.
- */
- public MonitorException(String message) {
- super(message);
- }
-
- /**
- * Create a MonitorException with the given message and cause.
- *
- * @param message the message to associate with the exception.
- * @param cause the exception causing this exception.
- */
- public MonitorException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Create an InstrumentationException with the given cause.
- *
- * @param cause the exception causing this exception.
- */
- public MonitorException(Throwable cause) {
- super(cause);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredHost.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,363 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.Set;
-
-import sun.jvmstat.monitor.event.HostListener;
-
-/**
- * An abstraction for a host that contains instrumented Java Virtual
- * Machines. The class provides abstract factory methods for creating
- * concrete instances of this class and factory methods for creating
- * {@link MonitoredVm} instances. Concrete implementations of this class
- * provide methods for managing the communications protocols and provide
- * for event notification.
- *
- * @author Brian Doherty
- * @since 1.5
- *
- * @see HostIdentifier
- * @see VmIdentifier
- * @see MonitoredVm
- * @see HostListener
- */
-public abstract class MonitoredHost {
- private static Map<HostIdentifier, MonitoredHost> monitoredHosts =
- new HashMap<HostIdentifier, MonitoredHost>();
-
- /*
- * The default optimized local protocol override mechanism. The value
- * of this property is used to construct the default package name
- * for the default optimized local protocol as follows:
- * <IMPL_PACKAGE>.monitor.<LOCAL_PROTOCOL>
- * This property is not expected to be set under normal circumstances.
- */
- private static final String LOCAL_PROTOCOL_PROP_NAME =
- "sun.jvmstat.monitor.local";
- private static final String LOCAL_PROTOCOL =
- System.getProperty(LOCAL_PROTOCOL_PROP_NAME, "local");
-
- /*
- * The default remote protocol override mechanism. The value of
- * this property is used to construct the default package name
- * for the default remote protocol protocol as follows:
- * <IMPL_PACKAGE>.monitor.protocol.<REMOTE_PROTOCOL>
- * This property is not expected to be set under normal circumstances.
- */
- private static final String REMOTE_PROTOCOL_PROP_NAME =
- "sun.jvmstat.monitor.remote";
- private static final String REMOTE_PROTOCOL =
- System.getProperty(REMOTE_PROTOCOL_PROP_NAME, "rmi");
-
- /**
- * The HostIdentifier for this MonitoredHost instance.
- */
- protected HostIdentifier hostId;
-
- /**
- * The polling interval, in milliseconds, for this MonitoredHost instance.
- */
- protected int interval;
-
- /**
- * The last Exception encountered while polling this MonitoredHost.
- */
- protected Exception lastException;
-
- /**
- * Factory method to construct MonitoredHost instances to manage
- * connections to the host indicated by {@code hostIdString}
- *
- * @param hostIdString a String representation of a {@link HostIdentifier}
- * @return MonitoredHost - the MonitoredHost instance for communicating
- * with the indicated host using the protocol
- * specified in hostIdString.
- * @throws MonitorException Thrown if monitoring errors occur.
- * @throws URISyntaxException Thrown when the hostIdString is poorly
- * formed. This exception may get encapsulated
- * into MonitorException in a future revision.
- */
- public static MonitoredHost getMonitoredHost(String hostIdString)
- throws MonitorException, URISyntaxException {
- HostIdentifier hostId = new HostIdentifier(hostIdString);
- return getMonitoredHost(hostId);
- }
-
- /**
- * Factory method to construct a MonitoredHost instance to manage the
- * connection to the Java Virtual Machine indicated by {@code vmid}.
- *
- * This method provide a convenient short cut for attaching to a specific
- * instrumented Java Virtual Machine. The information in the VmIdentifier
- * is used to construct a corresponding HostIdentifier, which in turn is
- * used to create the MonitoredHost instance.
- *
- * @param vmid The identifier for the target Java Virtual Machine.
- * @return MonitoredHost - The MonitoredHost object needed to attach to
- * the target Java Virtual Machine.
- *
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public static MonitoredHost getMonitoredHost(VmIdentifier vmid)
- throws MonitorException {
- // use the VmIdentifier to construct the corresponding HostIdentifier
- HostIdentifier hostId = new HostIdentifier(vmid);
- return getMonitoredHost(hostId);
- }
-
-
- /*
- * Load the MonitoredHostServices
- */
- private static ServiceLoader<MonitoredHostService> monitoredHostServiceLoader =
- ServiceLoader.load(MonitoredHostService.class, MonitoredHostService.class.getClassLoader());
-
- /**
- * Factory method to construct a MonitoredHost instance to manage the
- * connection to the host indicated by {@code hostId}.
- *
- * @param hostId the identifier for the target host.
- * @return MonitoredHost - The MonitoredHost object needed to attach to
- * the target host.
- *
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public static MonitoredHost getMonitoredHost(HostIdentifier hostId)
- throws MonitorException {
- MonitoredHost mh = null;
-
- synchronized(monitoredHosts) {
- mh = monitoredHosts.get(hostId);
- if (mh != null) {
- if (mh.isErrored()) {
- monitoredHosts.remove(hostId);
- } else {
- return mh;
- }
- }
- }
-
- hostId = resolveHostId(hostId);
-
- for (MonitoredHostService mhs : monitoredHostServiceLoader) {
- if (mhs.getScheme().equals(hostId.getScheme())) {
- mh = mhs.getMonitoredHost(hostId);
- }
- }
-
- if (mh == null) {
- throw new IllegalArgumentException("Could not find MonitoredHost for scheme: " + hostId.getScheme());
- }
-
- synchronized(monitoredHosts) {
- monitoredHosts.put(mh.hostId, mh);
- }
-
- return mh;
- }
-
- /**
- * Method to resolve unspecified components of the given HostIdentifier
- * by constructing a new HostIdentifier that replaces the unspecified
- * components with the default values.
- *
- * @param hostId the unresolved HostIdentifier.
- * @return HostIdentifier - a resolved HostIdentifier.
- *
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- protected static HostIdentifier resolveHostId(HostIdentifier hostId)
- throws MonitorException {
- String hostname = hostId.getHost();
- String scheme = hostId.getScheme();
- StringBuilder sb = new StringBuilder();
-
- assert hostname != null;
-
- if (scheme == null) {
- if (hostname.compareTo("localhost") == 0) {
- scheme = LOCAL_PROTOCOL;
- } else {
- scheme = REMOTE_PROTOCOL;
- }
- }
-
- sb.append(scheme).append(":").append(hostId.getSchemeSpecificPart());
-
- String frag = hostId.getFragment();
- if (frag != null) {
- sb.append("#").append(frag);
- }
-
- try {
- return new HostIdentifier(sb.toString());
- } catch (URISyntaxException e) {
- // programming error - HostIdentifier was valid.
- assert false;
- throw new IllegalArgumentException("Malformed URI created: "
- + sb.toString());
- }
- }
-
- /**
- * Return the resolved HostIdentifier for this MonitoredHost.
- *
- * @return HostIdentifier - the resolved HostIdentifier.
- */
- public HostIdentifier getHostIdentifier() {
- return hostId;
- }
-
- /* ---- Methods to support polled MonitoredHost Implementations ----- */
-
- /**
- * Set the polling interval for this MonitoredHost.
- *
- * @param interval the polling interval, in milliseconds
- */
- public void setInterval(int interval) {
- this.interval = interval;
- }
-
- /**
- * Get the polling interval.
- *
- * @return int - the polling interval in milliseconds for this MonitoredHost
- */
- public int getInterval() {
- return interval;
- }
-
- /**
- * Set the last exception encountered while polling this MonitoredHost.
- *
- * @param lastException the last exception encountered;
- */
- public void setLastException(Exception lastException) {
- this.lastException = lastException;
- }
-
- /**
- * Get the last exception encountered while polling this MonitoredHost.
- *
- * @return Exception - the last exception occurred while polling this
- * MonitoredHost, or {@code null} if no exception
- * has occurred or the exception has been cleared,
- */
- public Exception getLastException() {
- return lastException;
- }
-
- /**
- * Clear the last exception.
- */
- public void clearLastException() {
- lastException = null;
- }
-
- /**
- * Test if this MonitoredHost is in the errored state. If this method
- * returns true, then the Exception returned by getLastException()
- * indicates the Exception that caused the error condition.
- *
- * @return boolean - true if the MonitoredHost instance has experienced
- * an error, or false if it hasn't or if any past
- * error has been cleared.
- */
- public boolean isErrored() {
- return lastException != null;
- }
-
- /**
- * Get the MonitoredVm for the given Java Virtual Machine. The default
- * sampling interval is used for the MonitoredVm instance.
- *
- * @param id the VmIdentifier specifying the target Java Virtual Machine.
- * @return MonitoredVm - the MonitoredVm instance for the target Java
- * Virtual Machine.
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public abstract MonitoredVm getMonitoredVm(VmIdentifier id)
- throws MonitorException;
-
- /**
- * Get the MonitoredVm for the given Java Virtual Machine. The sampling
- * interval is set to the given interval.
- *
- * @param id the VmIdentifier specifying the target Java Virtual Machine.
- * @param interval the sampling interval for the target Java Virtual Machine.
- * @return MonitoredVm - the MonitoredVm instance for the target Java
- * Virtual Machine.
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public abstract MonitoredVm getMonitoredVm(VmIdentifier id, int interval)
- throws MonitorException;
-
- /**
- * Detach from the indicated MonitoredVm.
- *
- * @param vm the monitored Java Virtual Machine.
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public abstract void detach(MonitoredVm vm) throws MonitorException;
-
- /**
- * Add a HostListener. The given listener is added to the list
- * of HostListener objects to be notified of MonitoredHost related events.
- *
- * @param listener the HostListener to add.
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public abstract void addHostListener(HostListener listener)
- throws MonitorException;
-
- /**
- * Remove a HostListener. The given listener is removed from the list
- * of HostListener objects to be notified of MonitoredHost related events.
- *
- * @param listener the HostListener to add.
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public abstract void removeHostListener(HostListener listener)
- throws MonitorException;
-
- /**
- * Return the current set of active Java Virtual Machines for this
- * MonitoredHost. The returned Set contains {@link Integer} instances
- * holding the local virtual machine identifier, or <em>lvmid</em>
- * for each instrumented Java Virtual Machine currently available.
- *
- * @return Set - the current set of active Java Virtual Machines associated
- * with this MonitoredHost, or the empty set of none.
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public abstract Set<Integer> activeVms() throws MonitorException;
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredHostService.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-public interface MonitoredHostService {
-
- /**
- * Construct a MonitoredHost instance to manage the
- * connection to the host indicated by {@code hostId}.
- *
- * @param hostId the identifier for the target host.
- * @return MonitoredHost - The MonitoredHost object needed to attach to
- * the target host.
- *
- * @throws MonitorException Thrown if monitoring errors occur.
- */
- public MonitoredHost getMonitoredHost(HostIdentifier hostId) throws MonitorException;
-
- /**
- * Get the scheme that this service supports.
- *
- * @return scheme name
- */
- public String getScheme();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVm.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-import java.util.List;
-
-import sun.jvmstat.monitor.event.VmListener;
-
-/**
- * Interface for interacting with a monitorable Java Virtual Machine.
- * The MonitoredVm interface provides methods for discovery of exported
- * instrumentation, for attaching event listeners, and for overall
- * maintenance of the connection to the target.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public interface MonitoredVm {
-
- /**
- * Get the VmIdentifier associated with this MonitoredVm
- *
- * @return VmIdentifier - the fully resolved Vm identifier associated
- * with this MonitoredVm.
- */
- VmIdentifier getVmIdentifier();
-
- /**
- * Find a named Instrumentation object.
- *
- * This method will look for the named instrumentation object in the
- * instrumentation exported by this Java Virtual Machine. If an
- * instrumentation object with the given name exists, a Monitor interface
- * to that object will be return. Otherwise, the method returns
- * {@code null}.
- *
- * @param name the name of the Instrumentation object to find.
- * @return Monitor - the {@link Monitor} object that can be used to
- * monitor the named instrumentation object, or
- * {@code null} if the named object doesn't exist.
- * @throws MonitorException Thrown if an error occurs while communicating
- * with the target Java Virtual Machine.
- */
- Monitor findByName(String name) throws MonitorException;
-
- /**
- * Find all Instrumentation objects with names matching the given pattern.
- *
- * This method returns a {@link List} of Monitor objects such that
- * the name of each object matches the given pattern.
- *
- * @param patternString a string containing a pattern as described in
- * {@link java.util.regex.Pattern}.
- * @return {@code List<Monitor>} - a List of {@link Monitor}
- * objects that can be used to
- * monitor the instrumentation objects whose names match
- * the given pattern. If no instrumentation objects have
- * names matching the given pattern, then an empty List
- * is returned.
- * @throws MonitorException Thrown if an error occurs while communicating
- * with the target Java Virtual Machine.
- * @see java.util.regex.Pattern
- */
- List<Monitor> findByPattern(String patternString) throws MonitorException;
-
- /**
- * Detach from target Java Virtual Machine.
- *
- * After calling this method, updates of the instrumentation data values
- * may be halted. All event notifications are halted. Further interactions
- * with this object should be avoided.
- */
- void detach();
-
-
- /* ---- Methods to support polled MonitoredVm Implementations ---- */
-
- /**
- * Set the polling interval to {@code interval} milliseconds.
- *
- * Polling based monitoring implementations need to refresh the
- * instrumentation data on a periodic basis. This interface allows
- * the interval to override the implementation specific default
- * interval.
- *
- * @param interval the polling interval in milliseconds
- */
- void setInterval(int interval);
-
- /**
- * Get the polling interval.
- *
- * @return int - the current polling interval in milliseconds.
- * @see #setInterval
- */
- int getInterval();
-
- /**
- * Set the last exception encountered while polling this MonitoredVm.
- *
- * Polling implementations may choose to poll asynchronously. This
- * method allows an asynchronous task to communicate any polling related
- * exceptions with the application. When an a non-null exception is reported
- * through this interface, the MonitoredVm instance is considered to
- * be in the <em>errored</em> state.
- *
- * @param cause the exception to record.
- * @see #isErrored
- */
- void setLastException(Exception cause);
-
- /**
- * Get the last exception encountered while polling this MonitoredVm.
- *
- * Returns the last exception observed by the implementation dependent
- * polling task or {@code null} if no such error has occurred.
- *
- * @return Exception - the last exception that occurred during polling
- * or {@code null} if no error condition exists.
- * @see #isErrored
- * @see #setLastException
- */
- Exception getLastException();
-
- /**
- * Clear the last exception.
- *
- * Calling this method will clear the <em>errored</em> state of this
- * MonitoredVm. However, there is no guarantee that clearing the
- * the errored state return the asynchronous polling task to an
- * operational state.
- *
- */
- void clearLastException();
-
- /**
- * Test if this MonitoredVm is in the errored state.
- * The errored state exists only if an error was reported with
- * call to {@link #setLastException} and only if the parameter to
- * that call was non-null and no subsequent calls are made to
- * {@link #clearLastException}.
- *
- * @return boolean - true if the instance has a non-null error condition
- * set, false otherwise.
- *
- * @see #setLastException
- * @see #getLastException
- */
- boolean isErrored();
-
- /**
- * Add a VmListener. The given listener is added to the list of
- * VmListener objects to be notified of MonitoredVm related events.
- *
- * @param listener the VmListener to add.
- * @throws MonitorException Thrown if any problems occur while attempting
- * to add this listener.
- */
- void addVmListener(VmListener listener) throws MonitorException;
-
- /**
- * Remove a VmListener. The given listener is removed from the list of
- * VmListener objects to be notified of MonitoredVm related events.
- *
- * @param listener the VmListener to be removed.
- * @throws MonitorException Thrown if any problems occur while attempting
- * to remove this listener.
- */
- void removeVmListener(VmListener listener) throws MonitorException;
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVmUtil.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Utility class proving concenience methods for extracting various
- * information from an MonitoredVm object.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class MonitoredVmUtil {
-
- /**
- * Private constructor - prevent instantiation.
- */
- private MonitoredVmUtil() { }
-
- /**
- * Return the Java Virtual Machine Version.
- *
- * @param vm the target MonitoredVm
- * @return String - contains the version of the target JVM or the
- * the string "Unknown" if the version cannot be
- * determined.
- */
- public static String vmVersion(MonitoredVm vm) throws MonitorException {
- StringMonitor ver =
- (StringMonitor)vm.findByName("java.property.java.vm.version");
- return (ver == null) ? "Unknown" : ver.stringValue();
- }
-
- /**
- * Return the command line for the target Java application.
- *
- * @param vm the target MonitoredVm
- * @return String - contains the command line of the target Java
- * application or the string "Unknown" if the
- * command line cannot be determined.
- */
- public static String commandLine(MonitoredVm vm) throws MonitorException {
- StringMonitor cmd = (StringMonitor)vm.findByName("sun.rt.javaCommand");
- return (cmd == null) ? "Unknown" : cmd.stringValue();
- }
-
- /**
- * Return the arguments to the main class for the target Java application.
- * Returns the arguments to the main class. If the arguments can't be
- * found, the string "Unknown" is returned.
- *
- * @param vm the target MonitoredVm
- * @return String - contains the arguments to the main class for the
- * target Java application or the string "Unknown"
- * if the command line cannot be determined.
- */
- public static String mainArgs(MonitoredVm vm) throws MonitorException {
- String commandLine = commandLine(vm);
-
- int firstSpace = commandLine.indexOf(' ');
- if (firstSpace > 0) {
- return commandLine.substring(firstSpace + 1);
- } else if (commandLine.compareTo("Unknown") == 0) {
- return commandLine;
- } else {
- return null;
- }
- }
-
- /**
- * Return the main class for the target Java application.
- * Returns the main class or the name of the jar file if the application
- * was started with the <em>-jar</em> option.
- *
- * @param vm the target MonitoredVm
- * @param fullPath include the full path to Jar file, where applicable
- * @return String - contains the main class of the target Java
- * application or the string "Unknown" if the
- * command line cannot be determined.
- */
- public static String mainClass(MonitoredVm vm, boolean fullPath)
- throws MonitorException {
- String cmdLine = commandLine(vm);
- int firstSpace = cmdLine.indexOf(' ');
- if (firstSpace > 0) {
- cmdLine = cmdLine.substring(0, firstSpace);
- }
- if (fullPath) {
- return cmdLine;
- }
- /*
- * Can't use File.separator() here because the separator for the target
- * jvm may be different than the separator for the monitoring jvm.
- * And we also strip embedded module e.g. "module/MainClass"
- */
- int lastSlash = cmdLine.lastIndexOf("/");
- int lastBackslash = cmdLine.lastIndexOf("\\");
- int lastSeparator = lastSlash > lastBackslash ? lastSlash : lastBackslash;
- if (lastSeparator > 0) {
- cmdLine = cmdLine.substring(lastSeparator + 1);
- }
-
- int lastPackageSeparator = cmdLine.lastIndexOf('.');
- if (lastPackageSeparator > 0) {
- String lastPart = cmdLine.substring(lastPackageSeparator + 1);
- /*
- * We could have a relative path "my.module" or
- * a module called "my.module" and a jar file called "my.jar" or
- * class named "jar" in package "my", e.g. "my.jar".
- * We can never be sure here, but we assume *.jar is a jar file
- */
- if (lastPart.equals("jar")) {
- return cmdLine; /* presumably a file name without path */
- }
- return lastPart; /* presumably a class name without package */
- }
-
- return cmdLine;
- }
-
- /**
- * Return the JVM arguments for the target Java application.
- *
- * @param vm the target MonitoredVm
- * @return String - contains the arguments passed to the JVM for the
- * target Java application or the string "Unknown"
- * if the command line cannot be determined.
- */
- public static String jvmArgs(MonitoredVm vm) throws MonitorException {
- StringMonitor jvmArgs = (StringMonitor)vm.findByName("java.rt.vmArgs");
- return (jvmArgs == null) ? "Unknown" : jvmArgs.stringValue();
- }
-
- /**
- * Return the JVM flags for the target Java application.
- *
- * @param vm the target MonitoredVm
- * @return String - contains the flags passed to the JVM for the
- * target Java application or the string "Unknown"
- * if the command line cannot be determined.
- */
- public static String jvmFlags(MonitoredVm vm) throws MonitorException {
- StringMonitor jvmFlags =
- (StringMonitor)vm.findByName("java.rt.vmFlags");
- return (jvmFlags == null) ? "Unknown" : jvmFlags.stringValue();
- }
-
- // Index of the sun.rt.jvmCapabilities counter
- private static int IS_ATTACHABLE = 0;
- private static int IS_KERNEL_VM = 1;
-
- /**
- * Returns true if the VM supports attach-on-demand.
- *
- * @param vm the target MonitoredVm
- */
- public static boolean isAttachable(MonitoredVm vm) throws MonitorException {
- StringMonitor jvmCapabilities =
- (StringMonitor)vm.findByName("sun.rt.jvmCapabilities");
- if (jvmCapabilities == null) {
- return false;
- } else {
- return jvmCapabilities.stringValue().charAt(IS_ATTACHABLE) == '1';
- }
- }
-
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/StringMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-/**
- * Interface for Monitoring StringInstrument objects.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see sun.jvmstat.instrument.StringInstrument
- */
-public interface StringMonitor extends Monitor {
-
- /**
- * Get a copy of the current value of the StringInstrument object.
- *
- * @return String - a String object containing a copy of the value of
- * the associated StringInstrument.
- */
- public String stringValue();
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/Units.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.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;
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/Variability.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.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/jdk.jvmstat/share/classes/sun/jvmstat/monitor/VmIdentifier.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,450 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor;
-
-import java.net.*;
-
-/**
- * An abstraction that identifies a target Java Virtual Machine.
- * The VmIdentifier, or vmid, provides a convenient string representation
- * of the information needed to locate and communicate with a target
- * Java Virtual Machine. The string, based on a {@link URI}, may specify
- * the communications protocol, host name, local vm identifier, and protocol
- * specific information for a target Java Virtual Machine. The format for
- * a VmIdentifier string is:
- * <pre>
- * [<I>protocol</I>:][<I>//</I>]<I><B>lvmid</B></I>[<I>@hostname</I>][<I>:port</I>][<I>/servername</I>]
- * </pre>
- * The only required component of this string is the Local Virtual Machine
- * Identifier, or {@code lvmid}, which uniquely identifies the target
- * Java Virtual Machine on a host. The optional components of the VmIdentifier
- * include:
- * <ul>
- * <li>{@code protocol} - The communications protocol. A VmIdentifier
- * omitting the protocol must be resolved against a HostIdentifier
- * using {@link HostIdentifier#resolve}.
- * </li>
- * <li>{@code hostname} - A hostname or IP address indicating the target
- * host. A VmIdentifier omitting the protocol must be resolved
- * against a HostIdentifier using {@link HostIdentifier#resolve}.
- * </li>
- * <li>{@code port} - The port for the communications protocol.
- * Treatment of the {@code port} parameter is implementation
- * (protocol) specific. A VmIdentifier omitting the protocol should
- * be resolved against a HostIdentifier using
- * {@link HostIdentifier#resolve}.
- * </li>
- * <li>{@code servername} - The treatment of the Path, Query, and
- * Fragment components of the VmIdentifier are implementation
- * (protocol) dependent. A VmIdentifier omitting the protocol should
- * be resolved against a HostIdentifier using
- * {@link HostIdentifier#resolve}.
- * </li>
- * </ul>
- * <p>
- * All VmIdentifier instances are constructed as absolute, hierarchical URIs.
- * The constructors will accept relative (and even some malformed,
- * though convenient) URI strings. Such strings are transformed into
- * legitimate, absolute URI strings.
- * <p>
- * With the exception of <em>file:</em> based VmIdentifier strings, all
- * VmIdentifier strings must include a {@code lvmid}. Attempting to construct
- * a non-file based VmIdentifier that doesn't include a {@code lvmid}
- * component will result in a {@code MonitorException}.
- * <p>
- * Here are some examples of VmIdentifier strings.
- * <ul>
- * <li>Relative URIs
- * <ul>
- * <li><em>1234</em> - Specifies the Java Virtual Machine
- * identified by lvmid <em>1234</em> on an unnamed host.
- * This string is transformed into the absolute form
- * <em>//1234</em>, which must be resolved against a
- * HostIdentifier.
- * </li>
- * <li><em>1234@hostname</em> - Specifies the Java Virtual
- * Machine identified by lvmid <em>1234</em> on host
- * <em>hostname</em> with an unnamed protocol.
- * This string is transformed into the absolute form
- * <em>//1234@hostname</em>, which must be resolved against
- * a HostIdentifier.
- * </li>
- * <li><em>1234@hostname:2099</em> - Specifies the Java Virtual
- * Machine identified by lvmid <em>1234</em> on host
- * <em>hostname</em> with an unnamed protocol, but with
- * port <em>2099</em>. This string is transformed into
- * the absolute form <em>//1234@hostname:2099</em>, which
- * must be resolved against a HostIdentifier.
- * </li>
- * </ul>
- * </li>
- * <li>Absolute URIs
- * <ul>
- * <li><em>rmi://1234@hostname:2099/remoteobjectname</em> -
- * Specifies the Java Virtual Machine identified by lvmid
- * <em>1234</em> on host <em>hostname</em> accessed
- * using the <em>rmi:</em> protocol through the rmi remote
- * object named <em>remoteobjectname</em> as registered with
- * the <em>rmiserver</em> on port <em>2099</em> on host
- * <em>hostname</em>.
- * </li>
- * <li><em>file:/path/file</em> - Identifies a Java Virtual Machine
- * through accessing a special file based protocol to use as
- * the communications mechanism.
- * </li>
- * </ul>
- * </li>
- * </ul>
- *
- * @see URI
- * @see HostIdentifier
- * @author Brian Doherty
- * @since 1.5
- */
-public class VmIdentifier {
- private URI uri;
-
- /**
- * creates a canonical representation of the uriString. This method
- * performs certain translations depending on the type of URI generated
- * by the string.
- */
- private URI canonicalize(String uriString) throws URISyntaxException {
- if (uriString == null) {
- uriString = "local://0@localhost";
- return new URI(uriString);
- }
-
- URI u = new URI(uriString);
-
- if (u.isAbsolute()) {
- if (u.isOpaque()) {
- /*
- * rmi:1234@hostname/path#fragment converted to
- * rmi://1234@hostname/path#fragment
- */
- u = new URI(u.getScheme(), "//" + u.getSchemeSpecificPart(),
- u.getFragment());
- }
- } else {
- /*
- * make the uri absolute, if possible. A relative URI doesn't
- * specify the scheme part, so it's safe to prepend a "//" and
- * try again.
- */
- if (!uriString.startsWith("//")) {
- if (u.getFragment() == null) {
- u = new URI("//" + u.getSchemeSpecificPart());
- } else {
- u = new URI("//" + u.getSchemeSpecificPart() + "#"
- + u.getFragment());
- }
- }
- }
- return u;
- }
-
- /**
- * check that the VmIdentifier includes a unique numerical identifier
- * for the target JVM.
- */
- private void validate() throws URISyntaxException {
- // file:// uri, which is a special case where the lvmid is not required.
- String s = getScheme();
- if ((s != null) && (s.compareTo("file") == 0)) {
- return;
- }
- if (getLocalVmId() == -1) {
- throw new URISyntaxException(uri.toString(), "Local vmid required");
- }
- }
-
- /**
- * Create a VmIdentifier instance from a string value.
- *
- * @param uriString a string representing a target Java Virtual Machine.
- * The syntax of the string must conforms to the rules
- * specified in the class documentation.
- * @throws URISyntaxException Thrown when the uriString or its canonical
- * form is poorly formed.
- */
- public VmIdentifier(String uriString) throws URISyntaxException {
- URI u;
- try {
- u = canonicalize(uriString);
- } catch (URISyntaxException e) {
- /*
- * a vmid of the form 1234@hostname:1098 causes an exception,
- * so try again with a leading "//"
- */
- if (uriString.startsWith("//")) {
- throw e;
- }
- u = canonicalize("//"+uriString);
- }
-
- uri = u;
-
- // verify that we have a valid lvmid
- validate();
- }
-
- /**
- * Create a VmIdentifier instance from a URI object.
- *
- * @param uri a well formed, absolute URI indicating the
- * target Java Virtual Machine.
- * @throws URISyntaxException Thrown if the URI is missing some
- * required component.
- */
- public VmIdentifier(URI uri) throws URISyntaxException {
- this.uri = uri;
- validate();
- }
-
- /**
- * Return the corresponding HostIdentifier for this VmIdentifier.
- * <p>
- * This method constructs a HostIdentifier object from the VmIdentifier.
- * If the VmIdentifier is not specific about the protocol or other
- * components of the URI, then the resulting HostIdentifier will
- * be constructed based on this missing information. Typically, the
- * missing components will have result in the HostIdentifier assigning
- * assumed defaults that allow the VmIdentifier to be resolved according
- * to those defaults.
- * <p>
- * For example, a VmIdentifier that specifies only a {@code lvmid}
- * will result in a HostIdentifier for <em>localhost</em> utilizing
- * the default local protocol, <em>local:</em>. A VmIdentifier that
- * specifies both a {@code vmid} and a {@code hostname} will result
- * in a HostIdentifier for the specified host with the default remote
- * protocol, <em>rmi:</em>, using the protocol defaults for the
- * {@code port} and {@code servername} components.
- *
- * @return HostIdentifier - the host identifier for the host containing
- * the Java Virtual Machine represented by this
- * VmIdentifier.
- * @throws URISyntaxException Thrown if a bad host URI is constructed.
- * This exception may get encapsulated into
- * a MonitorException in a future version.
- */
- public HostIdentifier getHostIdentifier() throws URISyntaxException {
- StringBuilder sb = new StringBuilder();
- if (getScheme() != null) {
- sb.append(getScheme()).append(":");
- }
- sb.append("//").append(getHost());
- if (getPort() != -1) {
- sb.append(":").append(getPort());
- }
- if (getPath() != null) {
- sb.append(getPath());
- }
- return new HostIdentifier(sb.toString());
- }
-
- /**
- * Return the Scheme, or protocol, portion of this VmIdentifier.
- *
- * @return String - the scheme for this VmIdentifier.
- * @see URI#getScheme()
- */
- public String getScheme() {
- return uri.getScheme();
- }
-
- /**
- * Return the Scheme Specific Part of this VmIdentifier.
- *
- * @return String - the Scheme Specific Part for this VmIdentifier.
- * @see URI#getSchemeSpecificPart()
- */
- public String getSchemeSpecificPart() {
- return uri.getSchemeSpecificPart();
- }
-
- /**
- * Return the UserInfo part of this VmIdentifier.
- *
- * @return String - the UserInfo part for this VmIdentifier.
- * @see URI#getUserInfo()
- */
- public String getUserInfo() {
- return uri.getUserInfo();
- }
-
- /**
- * Return the Host part of this VmIdentifier.
- *
- * @return String - the Host part for this VmIdentifier.
- * @see URI#getHost()
- */
- public String getHost() {
- return uri.getHost();
- }
-
- /**
- * Return the Port part of this VmIdentifier.
- *
- * @return int - the Port part for this VmIdentifier.
- * @see URI#getPort()
- */
- public int getPort() {
- return uri.getPort();
- }
-
- /**
- * Return the Authority part of this VmIdentifier.
- *
- * @return String - the Authority part for this VmIdentifier.
- * @see URI#getAuthority()
- */
- public String getAuthority() {
- return uri.getAuthority();
- }
-
- /**
- * Return the Path part of this VmIdentifier.
- *
- * @return String - the Path part for this VmIdentifier.
- * @see URI#getPath()
- */
- public String getPath() {
- return uri.getPath();
- }
-
- /**
- * Return the Query part of this VmIdentifier.
- *
- * @return String - the Query part for this VmIdentifier.
- * @see URI#getQuery()
- */
- public String getQuery() {
- return uri.getQuery();
- }
-
- /**
- * Return the Fragment part of this VmIdentifier.
- *
- * @return String - the Fragment part for this VmIdentifier.
- * @see URI#getFragment()
- */
- public String getFragment() {
- return uri.getFragment();
- }
-
- /**
- * Return the Local Virtual Machine Identifier for this VmIdentifier.
- * The Local Virtual Machine Identifier is also known as the
- * <em>lvmid</em>.
- *
- * @return int - the lvmid for this VmIdentifier.
- */
- public int getLocalVmId() {
- int result = -1;
- try {
- if (uri.getUserInfo() == null) {
- result = Integer.parseInt(uri.getAuthority());
- } else {
- result = Integer.parseInt(uri.getUserInfo());
- }
- } catch (NumberFormatException e) { }
- return result;
- }
-
- /**
- * Return the mode indicated in this VmIdentifier.
- *
- * @return String - the mode string. If no mode is specified, then "r"
- * is returned. otherwise, the specified mode is returned.
- */
- public String getMode() {
- String query = getQuery();
- if (query != null) {
- String[] queryArgs = query.split("\\+");
- for (int i = 0; i < queryArgs.length; i++) {
- if (queryArgs[i].startsWith("mode=")) {
- int index = queryArgs[i].indexOf('=');
- return queryArgs[i].substring(index+1);
- }
- }
- }
- return "r";
- }
-
- /**
- * Return the URI associated with the VmIdentifier.
- *
- * @return URI - the URI.
- * @see URI
- */
- public URI getURI() {
- return uri;
- }
-
- /**
- * Return the hash code for this VmIdentifier. The hash code is
- * identical to the hash code for the contained URI.
- *
- * @return int - the hashcode.
- * @see URI#hashCode()
- */
- public int hashCode() {
- return uri.hashCode();
- }
-
- /**
- * Test for quality with other objects.
- *
- * @param object the object to be test for equality.
- * @return boolean - returns true if the given object is of type
- * VmIdentifier and its URI field is equal to
- * this object's URI field. Otherwise, return false.
- *
- * @see URI#equals(Object)
- */
- public boolean equals(Object object) {
- if (object == this) {
- return true;
- }
- if (!(object instanceof VmIdentifier)) {
- return false;
- }
- return uri.equals(((VmIdentifier)object).uri);
- }
-
- /**
- * Convert to a string representation. Conversion is identical to
- * calling getURI().toString(). This may change in a future release.
- *
- * @return String - a String representation of the VmIdentifier.
- *
- * @see URI#toString()
- */
- public String toString() {
- return uri.toString();
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/HostEvent.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor.event;
-
-import java.util.EventObject;
-import sun.jvmstat.monitor.MonitoredHost;
-
-/**
- * Base class for events emitted by a {@link MonitoredHost}.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class HostEvent extends EventObject {
-
- /**
- * Construct a new HostEvent instance.
- *
- * @param host the MonitoredHost source of the event.
- */
- public HostEvent(MonitoredHost host) {
- super(host);
- }
-
- /**
- * Return the MonitoredHost source of this event.
- *
- * @return MonitoredHost - the source of this event.
- */
- public MonitoredHost getMonitoredHost() {
- return (MonitoredHost)source;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/HostListener.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor.event;
-
-import java.util.EventListener;
-
-/**
- * Interface for listeners of MonitoredHost events.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see sun.jvmstat.monitor.MonitoredHost
- */
-public interface HostListener extends EventListener {
-
- /**
- * Invoked when the status of Java Virtual Machine changes.
- *
- * @param event the object describing the event.
- */
- void vmStatusChanged(VmStatusChangeEvent event);
-
- /**
- * Invoked when the connection to the MonitoredHost has disconnected
- * due to communication errors.
- *
- * @param event the object describing the event.
- */
- void disconnected(HostEvent event);
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/MonitorStatusChangeEvent.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor.event;
-
-import java.util.List;
-import sun.jvmstat.monitor.MonitoredVm;
-import sun.jvmstat.monitor.Monitor;
-
-/**
- * Provides a description of a change in status of the instrumentation
- * exported by the MonitoredVm.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class MonitorStatusChangeEvent extends VmEvent {
-
- /**
- * List of instrumentation objects inserted since the last event.
- * Elements of this list will always be of type Monitor.
- */
- protected List<Monitor> inserted;
-
- /**
- * List of instrumentation objects removed since the last event.
- * Elements of this list will always be of type Monitor.
- */
- protected List<Monitor> removed;
-
- /**
- * Construct a new MonitorStatusChangeEvent.
- *
- * @param vm the MonitoredVm source of the event.
- * @param inserted the list of instrumentation objects inserted since
- * the last event.
- * @param removed the list of instrumentation objects removed since
- * the last event.
- */
- public MonitorStatusChangeEvent(MonitoredVm vm, List<Monitor> inserted,
- List<Monitor> removed) {
- super(vm);
- this.inserted = inserted;
- this.removed = removed;
- }
-
- /**
- * Return the list of instrumentation objects that were inserted
- * since the last event notification.
- *
- * @return List - a List of Monitor objects that were inserted into the
- * instrumentation exported by the MonitoredHost. If no
- * new instrumentation was inserted, an emply List is
- * returned.
- */
- public List<Monitor> getInserted() {
- return inserted;
- }
-
- /**
- * Return the set of instrumentation objects that were removed
- * since the last event notification.
- *
- * @return List - a List of Monitor objects that were removed from the
- * instrumentation exported by the MonitoredHost. If no
- * instrumentation was removed, an emply List is returned.
- */
- public List<Monitor> getRemoved() {
- return removed;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/VmEvent.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor.event;
-
-import java.util.EventObject;
-import sun.jvmstat.monitor.MonitoredVm;
-
-/**
- * Base class for events emitted by a {@link MonitoredVm}.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class VmEvent extends EventObject {
-
- /**
- * Construct a new VmEvent instance.
- *
- * @param vm the MonitoredVm source of the event.
- */
- public VmEvent(MonitoredVm vm) {
- super(vm);
- }
-
- /**
- * Return the MonitoredVm source of this event.
- *
- * @return MonitoredVm - the source of this event.
- */
- public MonitoredVm getMonitoredVm() {
- return (MonitoredVm)source;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/VmListener.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor.event;
-
-import java.util.EventListener;
-
-/**
- * Interface for listeners of MonitoredVm events.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see sun.jvmstat.monitor.MonitoredVm
- */
-public interface VmListener extends EventListener {
-
- /**
- * Invoked when instrumentation objects are inserted into or removed
- * from the MonitoredVm.
- *
- * @param event the object describing the event.
- */
- void monitorStatusChanged(MonitorStatusChangeEvent event);
-
- /**
- * Invoked when instrumentation objects are updated. This event is
- * generated at a fixed interval as determined by the polling rate
- * of the MonitoredVm that the VmListener is registered with.
- *
- * @param event the object describing the event.
- */
- void monitorsUpdated(VmEvent event);
-
- /**
- * Invoked when the connection to the MonitoredVm has disconnected
- * due to communication errors.
- *
- * @param event the object describing the event.
- */
- void disconnected(VmEvent event);
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/VmStatusChangeEvent.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.monitor.event;
-
-import java.util.Set;
-import sun.jvmstat.monitor.MonitoredHost;
-
-/**
- * Provides a description of a change in status of the Java Virtual Machines
- * associated with a MonitoredHost.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class VmStatusChangeEvent extends HostEvent {
-
- /**
- * The set of currently active Java Virtual Machines for the MonitoredHost.
- * The set contains an Integer object holding the <em>lvmid</em> for each
- * active Java Virtual Machine on the MonitoredHost. This Set will only
- * contain Integer objects.
- */
- protected Set<Integer> active;
-
- /**
- * The set of Java Virtual Machines started on MonitoredHost since the
- * previous event. The set contains an Integer object holding the
- * <em>lvmid</em> for each Java Virtual Machine started on the
- * MonitoredHost. This Set will only contain Integer objects.
- */
- protected Set<Integer> started;
-
- /**
- * The set of Java Virtual Machines terminated on MonitoredHost since the
- * previous event. The set contains an Integer object holding the
- * <em>lvmid</em> for each Java Virtual Machine started on the
- * MonitoredHost. This Set will only contain Integer objects.
- */
- protected Set<Integer> terminated;
-
- /**
- * Construct a new VmStatusChangeEvent instance.
- *
- * @param host the MonitoredHost that is the source of the event.
- * @param active the set of currently active Java Virtual Machines
- * @param started the set of Java Virtual Machines started since the
- * last event.
- * @param terminated the set of Java Virtual Machines terminated since
- * the last event.
- */
- public VmStatusChangeEvent(MonitoredHost host, Set<Integer> active,
- Set<Integer> started, Set<Integer> terminated) {
- super(host);
- this.active = active;
- this.started = started;
- this.terminated = terminated;
- }
-
- /**
- * Return the set of currently active Java Virtual Machines.
- * The set contains an Integer object holding the <em>lvmid</em> for each
- * active Java Virtual Machine on the MonitoredHost.
- *
- * @return Set - a set of Integer objects containing the <em>lvmid</em>
- * of each active Java Virtual Machine on the host. If
- * there are no active Java Virtual Machines on the host,
- * an empty Set is returned.
- */
- public Set<Integer> getActive() {
- return active;
- }
-
- /**
- * Return the set of Java Virtual Machines started since the last
- * event notification. The set contains an Integer object holding
- * the <em>lvmid</em> for each Java Virtual Machine started on the
- * MonitoredHost since the last event notification.
- *
- * @return Set - a set of Integer objects containing the <em>lvmid</em>
- * of each Java Virtual Machine started on the host. If
- * no Java Virtual Machines were recently started on the
- * host, an empty Set is returned.
- */
- public Set<Integer> getStarted() {
- return started;
- }
-
- /**
- * Return the set of Java Virtual Machines terminated since the last
- * event notification. The set contains an Integer object holding
- * the <em>lvmid</em> for each Java Virtual Machine terminated on the
- * MonitoredHost since the last event notification.
- *
- * @return Set - a set of Integer objects containing the <em>lvmid</em>
- * of each Java Virtual Machine terminated on the host. If
- * no Java Virtual Machines were recently terminated on the
- * host, an empty Set is returned.
- */
- public Set<Integer> getTerminated() {
- return terminated;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/event/package.html Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-<!doctype html public "-//IETF//DTD HTML/EN">
-<html>
-<head>
-<!--
-
-
- Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
-
-
--->
-</head>
-<body bgcolor="white">
-<p>
-Provides classes for event types and event listeners for MonitoredHost
-and MonitoredVm events..
-</p>
-</body>
-</html>
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/package.html Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-<!doctype html public "-//IETF//DTD HTML/EN">
-<html>
-<head>
-<!--
-
-
- Copyright (c) 2004, 2007, Oracle and/or its affiliates. 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. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
-
-
--->
-</head>
-<body bgcolor="white">
-<p>
-Provides classes for monitoring instrumented HotSpot Java Virtual Machines.
-</p>
-<p>
-The classes in this package provide abstractions for:
-</p>
-<p>
-<ul>
- <li><p>Identifying monitorable hosts and Java Virtual Machines.</p></li>
- <li><p>Monitoring the creation and destruction of instrumented
- Java Virtual Machines on local and remote hosts.</p></li>
- <li><p>Discovering and Monitoring instrumentation exported by an
- instrumented Java Virtual Machine.</p></li>
-</ul>
-</p>
-<p>
-The {@link sun.jvmstat.monitor.MonitoredHost} class provides the
-interface to acquire concrete implementations for discovering instrumented
-Java Virtual Machines on a specific host. It serves a factory for creating
-MonitoredHost instances for specific hosts and for creating
-{@link sun.jvmstat.monitor.MonitoredVm} instances for specific
-instrumented Java Virtual Machines on those hosts.
-</p>
-<p>
-The {@link sun.jvmstat.monitor.MonitoredVm} instances provide an
-interface for discovery of instrumentation objects and the
-{@link sun.jvmstat.monitor.Monitor} interfaces provide a mechanism
-for monitoring the instrumentation exported by a JVM.
-</p>
-</body>
-</html>
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractMonitoredVm.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import java.util.List;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.monitor.event.VmListener;
-
-/**
- * Base class for all MonitoredVm implementations that utilize the
- * HotSpot PerfData instrumentation buffer as the communications
- * mechanism to the target Java Virtual Machine.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public abstract class AbstractMonitoredVm implements BufferedMonitoredVm {
-
- /**
- * The VmIdentifier for the target.
- */
- protected VmIdentifier vmid;
-
- /**
- * The shared memory instrumentation buffer for the target.
- */
- protected AbstractPerfDataBuffer pdb;
-
- /**
- * The sampling interval, if the instrumentation buffer is acquired
- * by sampling instead of shared memory mechanisms.
- */
- protected int interval;
-
- /**
- * Create an AbstractMonitoredVm instance.
- *
- * @param vmid the VmIdentifier for the target
- * @param interval the initial sampling interval
- */
- public AbstractMonitoredVm(VmIdentifier vmid, int interval)
- throws MonitorException {
- this.vmid = vmid;
- this.interval = interval;
- }
-
- /**
- * {@inheritDoc}
- */
- public VmIdentifier getVmIdentifier() {
- return vmid;
- }
-
- /**
- * {@inheritDoc}
- */
- public Monitor findByName(String name) throws MonitorException {
- return pdb.findByName(name);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<Monitor> findByPattern(String patternString) throws MonitorException {
- return pdb.findByPattern(patternString);
- }
-
- /**
- * {@inheritDoc}
- */
- public void detach() {
- /*
- * no default action required because the detach operation for the
- * native byte buffer is managed by the Perf class.
- */
- }
-
-
- /* ---- Methods to support polled MonitoredVm Implementations ----- */
-
- /**
- * {@inheritDoc}
- */
- public void setInterval(int interval) {
- this.interval = interval;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getInterval() {
- return interval;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLastException(Exception e) {
- // XXX: implement
- }
-
- /**
- * {@inheritDoc}
- */
- public Exception getLastException() {
- // XXX: implement
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void clearLastException() {
- // XXX: implement
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isErrored() {
- // XXX: implement
- return false;
- }
-
- /**
- * Get a list of the inserted and removed monitors since last called.
- *
- * @return MonitorStatus - the status of available Monitors for the
- * target Java Virtual Machine.
- * @throws MonitorException Thrown if communications errors occur
- * while communicating with the target.
- */
- public MonitorStatus getMonitorStatus() throws MonitorException {
- return pdb.getMonitorStatus();
- }
-
-
- /* --------------- Methods to support VmListeners ----------------- */
-
- /**
- * {@inheritDoc}
- */
- public abstract void addVmListener(VmListener l);
-
- /**
- * {@inheritDoc}
- */
- public abstract void removeVmListener(VmListener l);
-
-
- /* ---- Methods to support BufferedMonitoredVm Implementations ---- */
-
- /**
- * {@inheritDoc}
- */
- public byte[] getBytes() {
- return pdb.getBytes();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getCapacity() {
- return pdb.getCapacity();
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.util.*;
-import java.io.*;
-import java.lang.reflect.*;
-import java.nio.ByteBuffer;
-
-/**
- * Abstraction for the HotSpot PerfData instrumentation buffer. This class
- * is responsible for acquiring access to the instrumentation buffer for
- * a target HotSpot Java Virtual Machine and providing method level access
- * to its contents.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public abstract class AbstractPerfDataBuffer {
-
- /**
- * Reference to the concrete instance created by the
- * {@link #createPerfDataBuffer} method.
- */
- protected PerfDataBufferImpl impl;
-
- /**
- * Get the Local Java Virtual Machine Identifier, or <em>lvmid</em>
- * for the target JVM associated with this instrumentation buffer.
- *
- * @return int - the lvmid
- */
- public int getLocalVmId() {
- return impl.getLocalVmId();
- }
-
- /**
- * Get a copy of the raw instrumentation data.
- * This method is used to get a copy of the current bytes in the
- * instrumentation buffer. It is generally used for transporting
- * those bytes over the network.
- *
- * @return byte[] - a copy of the bytes in the instrumentation buffer.
- */
- public byte[] getBytes() {
- return impl.getBytes();
- }
-
- /**
- * Get the capacity of the instrumentation buffer.
- *
- * @return int - the capacity, or size, of the instrumentation buffer.
- */
- public int getCapacity() {
- return impl.getCapacity();
- }
-
- /**
- * Find a named Instrumentation object.
- *
- * This method will look for the named instrumentation object in the
- * instrumentation exported by this Java Virtual Machine. If an
- * instrumentation object with the given name exists, a Monitor interface
- * to that object will be return. Otherwise, the method returns
- * {@code null}.
- *
- * @param name the name of the Instrumentation object to find.
- * @return Monitor - the {@link Monitor} object that can be used to
- * monitor the named instrumentation object, or
- * {@code null} if the named object doesn't exist.
- * @throws MonitorException Thrown if an error occurs while communicating
- * with the target Java Virtual Machine.
- */
- public Monitor findByName(String name) throws MonitorException {
- return impl.findByName(name);
- }
-
- /**
- * Find all Instrumentation objects with names matching the given pattern.
- *
- * This method returns a {@link List} of Monitor objects such that
- * the name of each object matches the given pattern.
- *
- * @param patternString a string containing a pattern as described in
- * {@link java.util.regex.Pattern}.
- * @return {@code List<Monitor>} - a List of {@link Monitor}
- * objects that can be used to
- * monitor the instrumentation objects whose names match
- * the given pattern. If no instrumentation objects have`
- * names matching the given pattern, then an empty List
- * is returned.
- * @throws MonitorException Thrown if an error occurs while communicating
- * with the target Java Virtual Machine.
- * @see java.util.regex.Pattern
- */
- public List<Monitor> findByPattern(String patternString) throws MonitorException {
- return impl.findByPattern(patternString);
- }
-
- /**
- * Get a list of the inserted and removed monitors since last called.
- *
- * @return MonitorStatus - the status of available Monitors for the
- * target Java Virtual Machine.
- * @throws MonitorException Thrown if communications errors occur
- * while communicating with the target.
- */
- public MonitorStatus getMonitorStatus() throws MonitorException {
- return impl.getMonitorStatus();
- }
-
- /**
- * Get the ByteBuffer containing the instrumentation data.
- *
- * @return ByteBuffer - a ByteBuffer object that refers to the
- * instrumentation data.
- */
- public ByteBuffer getByteBuffer() {
- return impl.getByteBuffer();
- }
-
- /**
- * Create the perfdata instrumentation buffer for the given lvmid
- * using the given ByteBuffer object as the source of the instrumentation
- * data. This method parses the instrumentation buffer header to determine
- * key characteristics of the instrumentation buffer and then dynamically
- * loads the appropriate class to handle the particular instrumentation
- * version.
- *
- * @param bb the ByteBuffer that references the instrumentation data.
- * @param lvmid the Local Java Virtual Machine identifier for this
- * instrumentation buffer.
- *
- * @throws MonitorException
- */
- protected void createPerfDataBuffer(ByteBuffer bb, int lvmid)
- throws MonitorException {
- int majorVersion = AbstractPerfDataBufferPrologue.getMajorVersion(bb);
- int minorVersion = AbstractPerfDataBufferPrologue.getMinorVersion(bb);
-
- // instantiate the version specific class
- String classname = "sun.jvmstat.perfdata.monitor.v"
- + majorVersion + "_" + minorVersion
- + ".PerfDataBuffer";
-
- try {
- Class<?> implClass = Class.forName(classname);
- Constructor<?> cons = implClass.getConstructor(new Class<?>[] {
- Class.forName("java.nio.ByteBuffer"),
- Integer.TYPE
- });
-
- impl = (PerfDataBufferImpl)cons.newInstance(new Object[] {
- bb, lvmid
- });
-
- } catch (ClassNotFoundException e) {
- // from Class.forName();
- throw new IllegalArgumentException(
- "Could not find " + classname + ": " + e.getMessage(), e);
-
- } catch (NoSuchMethodException e) {
- // from Class.getConstructor();
- throw new IllegalArgumentException(
- "Expected constructor missing in " + classname + ": "
- + e.getMessage(), e);
-
- } catch (IllegalAccessException e) {
- // from Constructor.newInstance()
- throw new IllegalArgumentException(
- "Unexpected constructor access in " + classname + ": "
- + e.getMessage(), e);
-
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(
- classname + "is abstract: " + e.getMessage(), e);
-
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- if (cause instanceof MonitorException) {
- throw (MonitorException)cause;
- }
- throw new RuntimeException("Unexpected exception: "
- + e.getMessage() , e);
- }
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBufferPrologue.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,300 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.ByteOrder;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-
-/**
- * Abstraction representing the HotSpot PerfData instrumentation buffer
- * header. This class represents only the fixed portion of the header.
- * Version specific classes represent the portion of the header that
- * may change from release to release.
- * <p>
- * The PerfDataBufferProlog class supports parsing of the following
- * C structure:
- * <pre>
- * typedef struct {
- * jint magic; // magic number - 0xcafec0c0
- * jbyte byte_order; // byte order of the buffer
- * jbyte major_version; // major and minor version numbers
- * jbyte minor_version;
- * jbyte reserved_byte1; // reserved - see concrete implementations for
- * // possible definition.
- * ... // remainder is handled by the subclasses.
- * } PerfDataPrologue
- * </pre>
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public abstract class AbstractPerfDataBufferPrologue {
-
- protected ByteBuffer byteBuffer;
-
- /*
- * the following constants must match the field offsets and sizes
- * in the PerfDataPrologue structure in perfMemory.hpp
- */
- final static int PERFDATA_PROLOG_OFFSET=0;
- final static int PERFDATA_PROLOG_MAGIC_OFFSET=0;
- final static int PERFDATA_PROLOG_BYTEORDER_OFFSET=4;
- final static int PERFDATA_PROLOG_BYTEORDER_SIZE=1; // sizeof(byte)
- final static int PERFDATA_PROLOG_MAJOR_OFFSET=5;
- final static int PERFDATA_PROLOG_MAJOR_SIZE=1; // sizeof(byte)
- final static int PERFDATA_PROLOG_MINOR_OFFSET=6;
- final static int PERFDATA_PROLOG_MINOR_SIZE=1; // sizeof(byte)
- final static int PERFDATA_PROLOG_RESERVEDB1_OFFSET=7;
- final static int PERFDATA_PROLOG_RESERVEDB1_SIZE=1; // sizeof(byte)
-
- final static int PERFDATA_PROLOG_SIZE=8; // sizeof(struct PerfDataProlog)
-
- // these constants should match their #define counterparts in perfMemory.hpp
- final static byte PERFDATA_BIG_ENDIAN=0;
- final static byte PERFDATA_LITTLE_ENDIAN=1;
- final static int PERFDATA_MAGIC = 0xcafec0c0;
-
- // names for counters that expose the prolog fields
- public final static String PERFDATA_MAJOR_NAME =
- "sun.perfdata.majorVersion";
- public final static String PERFDATA_MINOR_NAME =
- "sun.perfdata.minorVersion";
-
- /**
- * Construct a PerfDataBufferPrologue instance.
- *
- * @param byteBuffer buffer containing the instrumentation data
- */
- public AbstractPerfDataBufferPrologue(ByteBuffer byteBuffer)
- throws MonitorException {
- this.byteBuffer = byteBuffer.duplicate();
-
- // the magic number is always stored in big-endian format
- if (getMagic() != PERFDATA_MAGIC) {
- throw new MonitorVersionException(
- "Bad Magic: " + Integer.toHexString(getMagic()));
- }
-
- // set the byte order
- this.byteBuffer.order(getByteOrder());
- }
-
- /**
- * Get the magic number.
- *
- * @return int - the magic number
- */
- public int getMagic() {
- // the magic number is always stored in big-endian format
- ByteOrder order = byteBuffer.order();
- byteBuffer.order(ByteOrder.BIG_ENDIAN);
-
- // get the magic number
- byteBuffer.position(PERFDATA_PROLOG_MAGIC_OFFSET);
- int magic = byteBuffer.getInt();
-
- // restore the byte order
- byteBuffer.order(order);
- return magic;
- }
-
- /**
- * Get the byte order.
- *
- * @return int - the byte order of the instrumentation buffer
- */
- public ByteOrder getByteOrder() {
- // byte order field is byte order independent
- byteBuffer.position(PERFDATA_PROLOG_BYTEORDER_OFFSET);
-
- byte byte_order = byteBuffer.get();
-
- if (byte_order == PERFDATA_BIG_ENDIAN) {
- return ByteOrder.BIG_ENDIAN;
- } else {
- return ByteOrder.LITTLE_ENDIAN;
- }
- }
-
- /**
- * Get the major version.
- *
- * @return int - the major version
- */
- public int getMajorVersion() {
- // major version field is byte order independent
- byteBuffer.position(PERFDATA_PROLOG_MAJOR_OFFSET);
- return (int)byteBuffer.get();
- }
-
- /**
- * Get the minor version.
- *
- * @return int - the minor version
- */
- public int getMinorVersion() {
- // minor version field is byte order independent
- byteBuffer.position(PERFDATA_PROLOG_MINOR_OFFSET);
- return (int)byteBuffer.get();
- }
-
- /**
- * Get the accessible flag. If supported, it indicates that the shared
- * memory region is sufficiently initialized for client acccess.
- *
- * @return boolean - the initialized status
- * @see #supportsAccessible()
- */
- public abstract boolean isAccessible();
-
- /**
- * Test if the accessible flag is supported by this version of
- * the PerfDataBufferPrologue. Although not an abstract method, this
- * method should be overridden by version specific subclasses.
- *
- * @return boolean - the initialized flag support status.
- * @see #isAccessible()
- */
- public abstract boolean supportsAccessible();
-
- /**
- * Get the size of the header portion of the instrumentation buffer.
- *
- * @return int - the size of the header
- */
- public int getSize() {
- return PERFDATA_PROLOG_SIZE; // sizeof(struct PerfDataProlog)
- }
-
- /**
- * Return an IntBuffer that accesses the major version number.
- * This is used to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the major version number
- * in the instrumentation buffer header.
- */
- public IntBuffer majorVersionBuffer() {
- int[] holder = new int[1];
- holder[0] = getMajorVersion();
- IntBuffer ib = IntBuffer.wrap(holder);
- ib.limit(1);
- return ib;
- }
-
- /**
- * Return an IntBuffer that accesses the minor version number.
- * This is used to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the minor version number
- * in the instrumentation buffer header.
- */
- public IntBuffer minorVersionBuffer() {
- int[] holder = new int[1];
- holder[0] = getMinorVersion();
- IntBuffer ib = IntBuffer.wrap(holder);
- ib.limit(1);
- return ib;
- }
-
- /**
- * Get the magic number from the given byteBuffer.
- *
- * @return int - the magic number
- */
- public static int getMagic(ByteBuffer bb) {
- // save buffer state
- int position = bb.position();
- ByteOrder order = bb.order();
-
- // the magic number is always stored in big-endian format
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.position(PERFDATA_PROLOG_MAGIC_OFFSET);
- int magic = bb.getInt();
-
- // restore buffer state.
- bb.order(order);
- bb.position(position);
-
- return magic;
- }
-
- /**
- * Get the major version number from the given ByteBuffer.
- *
- * @return int - the major version
- */
- public static int getMajorVersion(ByteBuffer bb) {
- // save buffer state
- int position = bb.position();
-
- bb.position(PERFDATA_PROLOG_MAJOR_OFFSET);
- int major = (int) bb.get();
-
- // restore buffer state.
- bb.position(position);
-
- return major;
- }
-
- /**
- * Get the minor version number from the given ByteBuffer.
- *
- * @return int - the minor version
- */
- public static int getMinorVersion(ByteBuffer bb) {
- // save buffer state
- int position = bb.position();
-
- bb.position(PERFDATA_PROLOG_MINOR_OFFSET);
- int minor = (int)bb.get();
-
- // restore buffer state.
- bb.position(position);
-
- return minor;
- }
-
- /**
- * Get the byte order for the given ByteBuffer.
- *
- * @return int - the byte order of the instrumentation buffer
- */
- public static ByteOrder getByteOrder(ByteBuffer bb) {
- // save buffer state
- int position = bb.position();
-
- bb.position(PERFDATA_PROLOG_BYTEORDER_OFFSET);
- ByteOrder order = (bb.get() == PERFDATA_BIG_ENDIAN)
- ? ByteOrder.BIG_ENDIAN
- : ByteOrder.LITTLE_ENDIAN;
-
- // restore buffer state.
- bb.position(position);
- return order;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import java.util.regex.*;
-
-/**
- * Class for parsing alias files. File format is expected to follow
- * the following syntax:
- *
- * alias name [alias]*
- *
- * Java style comments can occur anywhere within the file.
- * @author Brian Doherty
- * @since 1.5
- */
-public class AliasFileParser {
- private static final String ALIAS = "alias";
- // 8028357 removed old, inefficient debug logging
-
- // other variables
- private URL inputfile;
- private StreamTokenizer st;
- private Token currentToken;
-
- AliasFileParser(URL inputfile) {
- this.inputfile = inputfile;
- }
-
- // value class to hold StreamTokenizer token values
- private class Token {
- public String sval;
- public int ttype;
-
- public Token(int ttype, String sval) {
- this.ttype = ttype;
- this.sval = sval;
- }
- }
-
- /**
- * method to get the next token as a Token type
- */
- private void nextToken() throws IOException {
- st.nextToken();
- currentToken = new Token(st.ttype, st.sval);
- }
-
- /**
- * method to match the current Token to a specified token type and
- * value Throws a SyntaxException if token doesn't match.
- */
- private void match(int ttype, String token)
- throws IOException, SyntaxException {
-
- if ((currentToken.ttype == ttype)
- && (currentToken.sval.compareTo(token) == 0)) {
- nextToken();
- } else {
- throw new SyntaxException(st.lineno());
- }
- }
-
-
- /*
- * method to match the current Token to a specified token type.
- * Throws a SyntaxException if token doesn't match.
- */
- private void match(int ttype) throws IOException, SyntaxException {
- if (currentToken.ttype == ttype) {
- nextToken();
- } else {
- throw new SyntaxException(st.lineno());
- }
- }
-
- private void match(String token) throws IOException, SyntaxException {
- match(StreamTokenizer.TT_WORD, token);
- }
-
- /**
- * method to parse the given input file.
- */
- public void parse(Map<String, ArrayList<String>> map) throws SyntaxException, IOException {
-
- if (inputfile == null) {
- return;
- }
-
- BufferedReader r = new BufferedReader(
- new InputStreamReader(inputfile.openStream()));
- st = new StreamTokenizer(r);
-
- // allow both forms of commenting styles
- st.slashSlashComments(true);
- st.slashStarComments(true);
- st.wordChars('_','_');
-
- nextToken();
-
- while (currentToken.ttype != StreamTokenizer.TT_EOF) {
- // look for the start symbol
- if ((currentToken.ttype != StreamTokenizer.TT_WORD)
- || (currentToken.sval.compareTo(ALIAS) != 0)) {
- nextToken();
- continue;
- }
-
- match(ALIAS);
- String name = currentToken.sval;
- match(StreamTokenizer.TT_WORD);
-
- ArrayList<String> aliases = new ArrayList<String>();
-
- do {
- aliases.add(currentToken.sval);
- match(StreamTokenizer.TT_WORD);
-
- } while ((currentToken.ttype != StreamTokenizer.TT_EOF)
- && (currentToken.sval.compareTo(ALIAS) != 0));
-
- map.put(name, aliases);
- }
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTask.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import java.util.*;
-
-/**
- * A TimerTask subclass that keeps a count of the number of executions
- * of the task.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class CountedTimerTask extends TimerTask {
-
- volatile long executionCount;
-
- public long executionCount() {
- return executionCount;
- }
-
- public void run() {
- executionCount++;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import java.util.*;
-
-/**
- * Utility methods for use with {@link CountedTimerTask} instances.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class CountedTimerTaskUtils {
-
- // 8028357 removed old, inefficient debug logging
-
- /**
- * Reschedule a CountedTimeTask at a different interval. Probably not
- * named correctly. This method cancels the old task and computes the
- * delay for starting the new task based on the new interval and the
- * time at which the old task was last executed.
- *
- * @param timer the Timer for the task
- * @param oldTask the old Task
- * @param newTask the new Task
- * @param oldInterval the old interval; use for debugging output
- * purposes only.
- * @param newInterval scheduling interval in milliseconds
- */
- public static void reschedule(Timer timer, CountedTimerTask oldTask,
- CountedTimerTask newTask, int oldInterval,
- int newInterval) {
-
- long now = System.currentTimeMillis();
- long lastRun = oldTask.scheduledExecutionTime();
- long expired = now - lastRun;
-
- /*
- * check if original task ever ran - if not, then lastRun is
- * undefined and we simply set the delay to 0.
- */
- long delay = 0;
- if (oldTask.executionCount() > 0) {
- long remainder = newInterval - expired;
- delay = remainder >= 0 ? remainder : 0;
- }
-
- timer.schedule(newTask, delay, newInterval);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorDataException.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.MonitorException;
-
-/**
- * Exception indicating that improperly formatted data was encountered
- * while parsing a HotSpot PerfData buffer.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class MonitorDataException extends MonitorException {
-
- /**
- * Constructs a <code>MonitorDataException</code> with <code>
- * null</code> as its error detail message.
- */
- public MonitorDataException() {
- super();
- }
-
- /**
- * Constructs an <code>MonitorDataException</code> with the specified
- * detail message. The error message string <code>s</code> can later be
- * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
- * method of class <code>java.lang.Throwable</code>.
- *
- * @param s the detail message.
- */
- public MonitorDataException(String s) {
- super(s);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorStatus.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import java.util.List;
-import sun.jvmstat.monitor.Monitor;
-
-/**
- * Immutable class containing the list of inserted and deleted
- * monitors over an arbitrary time period.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class MonitorStatus {
-
- /**
- * The list of Monitors inserted since the last query.
- */
- protected List<Monitor> inserted;
-
- /**
- * The list of Monitors removed since the last query.
- */
- protected List<Monitor> removed;
-
- /**
- * Create a MonitorStatus instance.
- *
- * @param inserted the list of Monitors inserted
- * @param removed the list of Monitors removed
- */
- public MonitorStatus(List<Monitor> inserted, List<Monitor> removed) {
- this.inserted = inserted;
- this.removed = removed;
- }
-
- /**
- * Get the list of Monitors inserted since the last query.
- *
- * @return List - the List of Monitor objects inserted or an empty List.
- */
- public List<Monitor> getInserted() {
- return inserted;
- }
-
- /**
- * Get the list of Monitors removed since the last query.
- *
- * @return List - the List of Monitor objects removed or an empty List.
- */
- public List<Monitor> getRemoved() {
- return removed;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorStructureException.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.MonitorException;
-
-/**
- * Exception indicating that improperly formatted data was encountered
- * while parsing a HotSpot PerfData buffer.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class MonitorStructureException extends MonitorException {
-
- /**
- * Constructs a <code>MonitorStructureException</code> with <code>
- * null</code> as its error detail message.
- */
- public MonitorStructureException() {
- super();
- }
-
- /**
- * Constructs an <code>MonitorStructureException</code> with the specified
- * detail message. The error message string <code>s</code> can later be
- * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
- * method of class <code>java.lang.Throwable</code>.
- *
- * @param s the detail message.
- */
- public MonitorStructureException(String s) {
- super(s);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorTypeException.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.MonitorException;
-
-/**
- * Exception indicating that an unexpected type was encountered for
- * the type field of a PerfData entry in a HotSpot PerfData buffer.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class MonitorTypeException extends MonitorException {
-
- /**
- * Constructs a <code>MonitorTypeException</code> with <code>
- * null </code> as its error detail message.
- */
- public MonitorTypeException() {
- super();
- }
-
- /**
- * Constructs an <code>MonitorTypeException</code> with the specified
- * detail message. The error message string <code>s</code> can later be
- * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
- * method of class <code>java.lang.Throwable</code>.
- *
- * @param s the detail message.
- */
- public MonitorTypeException(String s) {
- super(s);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/MonitorVersionException.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.MonitorException;
-
-/**
- * Exception thrown when version of the implementation does not
- * match the version of the instrumentation exported by a target
- * Java Virtual Machine.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class MonitorVersionException extends MonitorException {
-
- /**
- * Create a MonitorVersionException
- */
- public MonitorVersionException() {
- super();
- }
-
- /**
- * Create a MonitorVersionException with the given message.
- *
- * @param message the message to associate with the exception.
- */
- public MonitorVersionException(String message) {
- super(message);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfByteArrayMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.ByteBuffer;
-
-/**
- * Class for monitoring a PerfData Byte Array instrumentation object.
- *
- * This class is provided to support the PerfStringMonitor classes.
- * Instrumentation objects of this direct type currently cannot be
- * created or monitored.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see sun.jvmstat.instrument.ByteArrayInstrument
- */
-public class PerfByteArrayMonitor extends AbstractMonitor
- implements ByteArrayMonitor {
-
- /**
- * The buffer containing the data for the byte array instrument.
- */
- ByteBuffer bb;
-
- /**
- * Constructor to create a ByteArrayMonitor for the byte array instrument
- * represented by the data in the given buffer.
- *
- * @param name the name of the instrumentation object
- * @param u the units of measure attribute
- * @param v the variability attribute
- * @param supported support level indicator
- * @param bb the buffer containing the byte array instrument data
- * @param vectorLength the length of the vector.
- */
- public PerfByteArrayMonitor(String name, Units u, Variability v,
- boolean supported, ByteBuffer bb,
- int vectorLength) {
- super(name, u, v, supported, vectorLength);
- this.bb = bb;
- }
-
- /**
- * {@inheritDoc}
- * The object returned contains a byte[] with a copy of the current
- * elements of the ByteArrayInstrument.
- *
- * @return Object - a copy of the current value of the elements of the
- * byte array instrument. The return type is guaranteed
- * to be of type byte[].
- */
- public Object getValue() {
- return byteArrayValue();
- }
-
- /**
- * Get a copy of the elements of the byte array instrument.
- *
- * @return byte[] - a copy of the current value of the elements of the
- * byte array instrument.
- */
- public byte[] byteArrayValue() {
- bb.position(0);
- byte[] b = new byte[bb.limit()];
-
- // copy the bytes
- bb.get(b);
-
- return b;
- }
-
- /**
- * Get the current value of an element of the byte array instrument.
- *
- * @return byte - a copy of the current value of the element at index
- * {@code index} of the byte array instrument.
- */
- public byte byteAt(int index) {
- bb.position(index);
- return bb.get();
- }
-
- /**
- * Get the maximum length of the byte array for this byte array instrument.
- *
- * @return int - the maximum length of the byte array.
- */
- public int getMaximumLength() {
- return bb.limit();
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,358 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.util.*;
-import java.nio.*;
-import java.io.*;
-import java.net.*;
-import java.util.regex.*;
-
-/**
- * The base classes for the concrete implementations of the HotSpot
- * PerfData instrumentation buffer.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see AbstractPerfDataBuffer
- */
-public abstract class PerfDataBufferImpl {
-
- /**
- * The buffer containing the instrumentation data.
- */
- protected ByteBuffer buffer;
-
- /**
- * A Map of monitor objects found in the instrumentation buffer.
- */
- protected Map<String, Monitor> monitors;
-
- /**
- * The Local Java Virtual Machine Identifier for this buffer.
- */
- protected int lvmid;
-
- /**
- * A Map of monitor object names to aliases as read in from the alias map
- * file.
- */
- protected Map<String, ArrayList<String>> aliasMap;
-
- /**
- * A cache of resolved monitor aliases.
- */
- protected Map<String, Monitor> aliasCache;
-
-
- /**
- * Constructor.
- *
- * @param buffer the ByteBuffer containing the instrumentation data.
- * @param lvmid the Local Java Virtual Machine Identifier for this
- * instrumentation buffer.
- */
- protected PerfDataBufferImpl(ByteBuffer buffer, int lvmid) {
- this.buffer = buffer;
- this.lvmid = lvmid;
- this.monitors = new TreeMap<>();
- this.aliasMap = new HashMap<>();
- this.aliasCache = new HashMap<>();
- }
-
- /**
- * Get the Local Java Virtual Machine Identifier, or <em>lvmid</em>
- * for the target JVM associated with this instrumentation buffer.
- *
- * @return int - the lvmid
- */
- public int getLocalVmId() {
- return lvmid;
- }
-
- /**
- * Get a copy of the raw instrumentation data.
- * This method is used to get a copy of the current bytes in the
- * instrumentation buffer. It is generally used for transporting
- * those bytes over the network.
- *
- * @return byte[] - a copy of the bytes in the instrumentation buffer.
- */
- public byte[] getBytes() {
- ByteBuffer bb = null;
- synchronized (this) {
- /*
- * this operation is potentially time consuming, and the result
- * is unused when the getBytes() interface is used. However, the
- * call is necessary in order to synchronize this monitoring
- * client with the target jvm, which assures that the receiver
- * of the byte[] gets an image that is initialized to a usable
- * state. Otherwise, they might only get a snapshot of an
- * empty instrumentation buffer immediately after it was created.
- */
- try {
- if (monitors.isEmpty()) {
- buildMonitorMap(monitors);
- }
- } catch (MonitorException e) {
- /*
- * just ignore this here and let the receiver of the
- * byte[] detect and handle the problem.
- */
- }
- bb = buffer.duplicate();
- }
- bb.rewind();
- byte[] bytes = new byte[bb.limit()];
- bb.get(bytes);
- return bytes;
- }
-
- /**
- * Get the capacity of the instrumentation buffer.
- *
- * @return int - the capacity, or size, of the instrumentation buffer.
- */
- public int getCapacity() {
- return buffer.capacity();
- }
-
- /**
- * Get the ByteBuffer containing the instrumentation data.
- *
- * @return ByteBuffer - a ByteBuffer object that refers to the
- * instrumentation data.
- */
- ByteBuffer getByteBuffer() {
- // receiver is responsible for assuring that the buffer's state
- // is that of an initialized target.
- return buffer;
- }
-
- /**
- * Build the alias mapping. Uses the default alias map file unless
- * the sun.jvmstat.perfdata.aliasmap file indicates some other
- * file as the source.
- */
- @SuppressWarnings("deprecation")
- private void buildAliasMap() {
- assert Thread.holdsLock(this);
-
- URL aliasURL = null;
- String filename = System.getProperty("sun.jvmstat.perfdata.aliasmap");
-
- if (filename != null) {
- File f = new File(filename);
- try {
- aliasURL = f.toURL();
-
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException(e);
- }
- } else {
- aliasURL = getClass().getResource(
- "/sun/jvmstat/perfdata/resources/aliasmap");
- }
-
- assert aliasURL != null;
-
- AliasFileParser aliasParser = new AliasFileParser(aliasURL);
-
- try {
- aliasParser.parse(aliasMap);
-
- } catch (IOException e) {
- System.err.println("Error processing " + filename + ": "
- + e.getMessage());
- } catch (SyntaxException e) {
- System.err.println("Syntax error parsing " + filename + ": "
- + e.getMessage());
- }
- }
-
- /**
- * Find the Monitor object for the named counter by using one of its
- * aliases.
- */
- protected Monitor findByAlias(String name) {
- assert Thread.holdsLock(this);
-
- Monitor m = aliasCache.get(name);
- if (m == null) {
- ArrayList<String> al = aliasMap.get(name);
- if (al != null) {
- for (Iterator<String> i = al.iterator(); i.hasNext() && m == null; ) {
- String alias = i.next();
- m = monitors.get(alias);
- }
- }
- }
- return m;
- }
-
-
- /**
- * Find a named Instrumentation object.
- *
- * This method will look for the named instrumentation object in the
- * instrumentation exported by this Java Virtual Machine. If an
- * instrumentation object with the given name exists, a Monitor interface
- * to that object will be return. Otherwise, the method returns
- * {@code null}. The method will map requests for instrumention objects
- * using old names to their current names, if applicable.
- *
- *
- *
- * @param name the name of the Instrumentation object to find.
- * @return Monitor - the {@link Monitor} object that can be used to
- * monitor the named instrumentation object, or
- * {@code null} if the named object doesn't exist.
- * @throws MonitorException Thrown if an error occurs while communicating
- * with the target Java Virtual Machine.
- */
- public Monitor findByName(String name) throws MonitorException {
- Monitor m = null;
-
- synchronized (this) {
- if (monitors.isEmpty()) {
- buildMonitorMap(monitors);
- buildAliasMap();
- }
-
- // look for the requested monitor
- m = monitors.get(name);
- if (m == null) {
- // not found - load any new monitors, and try again.
- getNewMonitors(monitors);
- m = monitors.get(name);
- }
- if (m == null) {
- // still not found, look for aliases
- m = findByAlias(name);
- }
- }
- return m;
- }
-
- /**
- * Find all Instrumentation objects with names matching the given pattern.
- *
- * This method returns a {@link List} of Monitor objects such that
- * the name of each object matches the given pattern.
- *
- * @param patternString a string containing a pattern as described in
- * {@link java.util.regex.Pattern}.
- * @return {@code List<Monitor>} - a List of {@link Monitor}
- * objects that can be used to
- * monitor the instrumentation objects whose names match
- * the given pattern. If no instrumentation objects have`
- * names matching the given pattern, then an empty List
- * is returned.
- * @throws MonitorException Thrown if an error occurs while communicating
- * with the target Java Virtual Machine.
- * @see java.util.regex.Pattern
- */
- public List<Monitor> findByPattern(String patternString)
- throws MonitorException, PatternSyntaxException {
-
- synchronized(this) {
- if (monitors.isEmpty()) {
- buildMonitorMap(monitors);
- } else {
- getNewMonitors(monitors);
- }
- }
-
- Pattern pattern = Pattern.compile(patternString);
- Matcher matcher = pattern.matcher("");
- List<Monitor> matches = new ArrayList<>();
-
- Set<Map.Entry<String,Monitor>> monitorSet = monitors.entrySet();
-
- for (Iterator<Map.Entry<String, Monitor>> i = monitorSet.iterator(); i.hasNext(); /* empty */) {
- Map.Entry<String, Monitor> me = i.next();
- String name = me.getKey();
- Monitor m = me.getValue();
-
- // apply pattern to monitor item name
- matcher.reset(name);
-
- // if the pattern matches, then add monitor to list
- if (matcher.lookingAt()) {
- matches.add(me.getValue());
- }
- }
- return matches;
- }
-
- /**
- * Get a list of the inserted and removed monitors since last called.
- *
- * @return MonitorStatus - the status of available Monitors for the
- * target Java Virtual Machine.
- * @throws MonitorException Thrown if communications errors occur
- * while communicating with the target.
- */
- public MonitorStatus getMonitorStatus() throws MonitorException {
- synchronized(this) {
- if (monitors.isEmpty()) {
- buildMonitorMap(monitors);
- }
- return getMonitorStatus(monitors);
- }
- }
-
- // PerfDataBuffer implementation specific classes
-
- /**
- * get the list of inserted and removed monitors since last called.
- *
- * @param m the map of Monitors.
- * @throws MonitorException Thrown if communications errors occur
- * while communicating with the target.
- */
- protected abstract MonitorStatus getMonitorStatus(Map<String, Monitor> m)
- throws MonitorException;
-
- /**
- * build the map of Monitor objects.
- *
- * @param m the map of Monitors.
- * @throws MonitorException Thrown if communications errors occur
- * while communicating with the target.
- */
- protected abstract void buildMonitorMap(Map<String, Monitor> m) throws MonitorException;
-
- /**
- * get the new Monitor objects from the Map of Monitor objects.
- *
- * @param m the map of Monitors.
- * @throws MonitorException Thrown if communications errors occur
- * while communicating with the target.
- */
- protected abstract void getNewMonitors(Map<String, Monitor> m) throws MonitorException;
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.IntBuffer;
-
-/**
- * Class for monitoring a PerfData Integer instrument.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfIntegerMonitor extends AbstractMonitor
- implements IntegerMonitor {
-
- /**
- * The buffer containing the data for the integer instrument.
- */
- IntBuffer ib;
-
- /**
- * Constructor to create an IntegerMonitor object for the integer
- * instrument represented by the data in the given buffer.
- *
- * @param name the name of the integer instrument
- * @param u the units of measure attribute
- * @param v the variability attribute
- * @param supported support level indicator
- * @param ib the buffer containing the integer instrument data.
- */
- public PerfIntegerMonitor(String name, Units u, Variability v,
- boolean supported, IntBuffer ib) {
- super(name, u, v, supported);
- this.ib = ib;
- }
-
- /**
- * {@inheritDoc}
- * The object returned contains an Integer object containing the
- * current value of the IntegerInstrument.
- *
- * @return Object - the current value of the IntegerInstrument. The
- * return type is guaranteed to be of type Integer.
- */
- public Object getValue() {
- return ib.get(0);
- }
-
- /**
- * Return the current value of the IntegerInstrument as an int.
- *
- * @return int - a the current value of the IntegerInstrument.
- */
- public int intValue() {
- return ib.get(0);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.LongBuffer;
-
-/**
- * Class for monitoring a PerfData Long instrument.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfLongMonitor extends AbstractMonitor implements LongMonitor {
-
- /**
- * The buffer containing the data for the long instrument.
- */
- LongBuffer lb;
-
- /**
- * Constructor to create a LongMonitor object for the long instrument
- * represented by the data in the given buffer.
- *
- * @param name the name of the long instrument
- * @param u the units of measure attribute
- * @param v the variability attribute
- * @param supported support level indicator
- * @param lb the buffer containing the long instrument data.
- */
- public PerfLongMonitor(String name, Units u, Variability v,
- boolean supported, LongBuffer lb) {
- super(name, u, v, supported);
- this.lb = lb;
- }
-
- /**
- * {@inheritDoc}
- * The object returned contains a Long object containing the
- * current value of the LongInstrument.
- *
- * @return Object - the current value of the LongInstrument. The
- * return type is guaranteed to be of type Long.
- */
- public Object getValue() {
- return Long.valueOf(lb.get(0));
- }
-
- /**
- * Return the current value of the LongInstrument as an long.
- *
- * @return long - the current value of the LongInstrument
- */
- public long longValue() {
- return lb.get(0);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfStringConstantMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.ByteBuffer;
-
-/**
- * Class for monitoring a constant PerfData String instrument. The
- * value associated with a constant string instrument is fixed at
- * the string instrument's creation time. Its value and length never
- * change.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfStringConstantMonitor extends PerfStringMonitor {
-
- /**
- * The cached value of the string instrument.
- */
- String data;
-
- /**
- * Constructor to create a StringMonitor object for the constant string
- * instrument object represented by the data in the given buffer.
- *
- * @param name the name of the instrumentation object
- * @param supported support level indicator
- * @param bb the buffer containing the string instrument data
- */
- public PerfStringConstantMonitor(String name, boolean supported,
- ByteBuffer bb) {
- super(name, Variability.CONSTANT, supported, bb);
- this.data = super.stringValue();
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getValue() {
- return data; // return the cached string
- }
-
- /**
- * {@inheritDoc}
- */
- public String stringValue() {
- return data; // return the cached string
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfStringMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-
-/**
- * Class for monitoring a PerfData String instrument.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfStringMonitor extends PerfByteArrayMonitor
- implements StringMonitor {
-
- private static Charset defaultCharset = Charset.defaultCharset();
-
- /**
- * Constructor to create a StringMonitor object for the string instrument
- * represented by the data in the given buffer.
- *
- * @param name the name of the string instrument
- * @param v the variability attribute
- * @param supported support level indicator
- * @param bb the buffer containing the string instrument data.
- */
- public PerfStringMonitor(String name, Variability v, boolean supported,
- ByteBuffer bb) {
- this(name, v, supported, bb, bb.limit());
- }
-
- /**
- * Constructor to create a StringMonitor object for the string instrument
- * represented by the data in the given buffer.
- *
- * @param name the name of the string instrument
- * @param v the variability attribute
- * @param supported support level indicator
- * @param bb the buffer containing the string instrument data.
- * @param maxLength the maximum length of the string data.
- */
- public PerfStringMonitor(String name, Variability v, boolean supported,
- ByteBuffer bb, int maxLength) {
- super(name, Units.STRING, v, supported, bb, maxLength);
- }
-
- /**
- * {@inheritDoc}
- * The object returned contains a String with a copy of the current
- * value of the StringInstrument.
- *
- * @return Object - a copy of the current value of the StringInstrument.
- * The return value is guaranteed to be of type String.
- */
- public Object getValue() {
- return stringValue();
- }
-
- /**
- * Return the current value of the StringInstrument as a String.
- *
- * @return String - a copy of the current value of the StringInstrument.
- */
- public String stringValue() {
- String str = "";
- byte[] b = byteArrayValue();
-
- // catch null strings
- if ((b == null) || (b.length <= 1) || (b[0] == (byte)0)) {
- return str;
- }
-
- int i;
- for (i = 0; i < b.length && b[i] != (byte)0; i++);
-
- return new String(b, 0, i, defaultCharset);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfStringVariableMonitor.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import sun.jvmstat.monitor.*;
-import java.nio.ByteBuffer;
-
-/**
- *
- * Class for monitoring a variable PerfData String instrument.
- * The current value of a variable string instrument changes over time.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfStringVariableMonitor extends PerfStringMonitor {
-
- /**
- * Constructor to create a StringMonitor object for the variable string
- * instrument represented by the data in the given buffer.
- *
- * @param name the name of the string instrument
- * @param supported support level indicator
- * @param bb the buffer containing the string instrument data.
- */
- public PerfStringVariableMonitor(String name, boolean supported,
- ByteBuffer bb) {
- this(name, supported, bb, bb.limit());
- }
-
- /**
- * Constructor to create a StringMonitor object for the variable
- * string instrument represented by the data in the given buffer.
- *
- * @param name the name of the string instrument
- * @param bb the buffer containing the string instrument data.
- * @param supported support level indicator
- * @param maxLength the maximum length of the string data.
- */
- public PerfStringVariableMonitor(String name, boolean supported,
- ByteBuffer bb, int maxLength) {
- // account for the null terminator by adding 1 to maxLength
- super(name, Variability.VARIABLE, supported, bb, maxLength+1);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/SyntaxException.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import java.util.regex.*;
-
-/**
- * Class for encapsulating syntax exceptions generated by AliasFileParser.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-@SuppressWarnings("serial") // JDK implementation class
-public class SyntaxException extends Exception {
- int lineno;
-
- public SyntaxException(int lineno) {
- this.lineno = lineno;
- }
-
- public String getMessage() {
- return "syntax error at line " + lineno;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/package.html Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-<!doctype html public "-//IETF//DTD HTML/EN">
-<html>
-<head>
-<!--
-
-
- Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
-
--->
-</head>
-<body bgcolor="white">
-<p>
-Provides the monitoring implementation classes that utilize the HotSpot
-PerfData shared memory instrumentation buffer for discovery and monitoring
-of instrumentation exported by a HotSpot Java Virtual Machine.
-</p>
-</body>
-</html>
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/FileMonitoredVm.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.file;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.monitor.event.VmListener;
-import sun.jvmstat.perfdata.monitor.*;
-import java.util.List;
-import java.lang.reflect.*;
-import java.io.*;
-
-/**
- * Concrete implementation of the AbstractMonitoredVm class for the
- * <em>file:</em> protocol for the HotSpot PerfData monitoring implementation.
- * <p>
- * This class provides the ability to attach to the instrumentation buffer
- * (saved or live) of a target Java Virtual Machine by providing a
- * <em>file</em> URI to a file containing the instrmentation buffer data.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class FileMonitoredVm extends AbstractMonitoredVm {
-
- /**
- * Create a FileMonitoredVm instance.
- *
- * @param vmid the vm identifier referring to the file
- * @param interval sampling interval (unused in this protocol).
- */
- public FileMonitoredVm(VmIdentifier vmid, int interval)
- throws MonitorException {
- super(vmid, interval);
- this.pdb = new PerfDataBuffer(vmid);
- }
-
- /**
- * {@inheritDoc}.
- *<p>
- * Note - the <em>file:</em> protocol currently does not support
- * the registration or notification of listeners.
- */
- public void addVmListener(VmListener l) { }
-
- /**
- * {@inheritDoc}.
- *<p>
- * Note - the <em>file:</em> protocol currently does not support
- * the registration or notification of listeners.
- */
- public void removeVmListener(VmListener l) { }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/MonitoredHostFileService.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.file;
-
-import sun.jvmstat.monitor.HostIdentifier;
-import sun.jvmstat.monitor.MonitorException;
-import sun.jvmstat.monitor.MonitoredHost;
-import sun.jvmstat.monitor.MonitoredHostService;
-
-public final class MonitoredHostFileService implements MonitoredHostService {
-
- @Override
- public MonitoredHost getMonitoredHost(HostIdentifier hostId)
- throws MonitorException {
- return new MonitoredHostProvider(hostId);
- }
-
- @Override
- public String getScheme() {
- return "file";
- }
-
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/MonitoredHostProvider.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.file;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.monitor.event.HostListener;
-import sun.jvmstat.perfdata.monitor.*;
-import java.util.*;
-import java.net.*;
-
-/**
- * Concrete implementation of the MonitoredHost interface for the
- * <em>file:</em> protocol of the HotSpot PerfData monitoring implementation.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class MonitoredHostProvider extends MonitoredHost {
-
- /**
- * The default polling interval. Not used by the <em>file:</em> protocol.
- */
- public static final int DEFAULT_POLLING_INTERVAL = 0;
-
- /**
- * Create a MonitoredHostProvider instance using the given HostIdentifier.
- *
- * @param hostId the host identifier for this MonitoredHost
- */
- public MonitoredHostProvider(HostIdentifier hostId) {
- this.hostId = hostId;
- }
-
- /**
- * {@inheritDoc}
- */
- public MonitoredVm getMonitoredVm(VmIdentifier vmid)
- throws MonitorException {
- return getMonitoredVm(vmid, DEFAULT_POLLING_INTERVAL);
- }
-
- /**
- * {@inheritDoc}.
- * <p>
- * Note - the <em>file:</em> protocol silently ignores the
- * {@code interval} parameter.
- */
- public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval)
- throws MonitorException {
- // don't attempt to resolve 'file:' based vmid
- return new FileMonitoredVm(vmid, interval);
- }
-
- /**
- * {@inheritDoc}
- */
- public void detach(MonitoredVm vm) {
- vm.detach();
- }
-
- /**
- * {@inheritDoc}.
- * <p>
- * Note - the <em>file:</em> protocol currenly does not support
- * registration or notification of event listeners. This method
- * silently ignores the add request.
- */
- public void addHostListener(HostListener listener) {
- // no HostListener support for 'file:' based VmIdentifiers
- }
-
- /**
- * {@inheritDoc}.
- * <p>
- * Note - the <em>file:</em> protocol currenly does not support
- * registration or notification of event listeners. This method
- * silently ignores the remove request.
- */
- public void removeHostListener(HostListener listener) {
- // no HostListener support for 'file:' based VmIdentifiers
- }
-
- /**
- * {@inheritDoc}.
- * <p>
- * Note - the <em>file:</em> protocol currently does not support the
- * notion of tracking active or inactive Java Virtual Machines. This
- * method currently returns an empty set.
- */
- public Set<Integer> activeVms() {
- return new HashSet<Integer>(0);
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/PerfDataBuffer.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.file;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.io.*;
-import java.net.URI;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-
-/**
- * The concrete PerfDataBuffer implementation for the <em>file:</em>
- * protocol for the HotSpot PerfData monitoring implemetation.
- * <p>
- * This class is responsible for acquiring access to the instrumentation
- * buffer stored in a file referenced by a file URI.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfDataBuffer extends AbstractPerfDataBuffer {
-
- /**
- * Create a PerfDataBuffer instance for accessing the specified
- * instrumentation buffer.
- *
- * @param vmid the <em>file:</em> URI to the instrumentation buffer file
- *
- * @throws MonitorException
- */
- public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
- File f = new File(vmid.getURI());
- String mode = vmid.getMode();
-
- try {
- FileChannel fc = new RandomAccessFile(f, mode).getChannel();
- ByteBuffer bb = null;
-
- if (mode.compareTo("r") == 0) {
- bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L, (int)fc.size());
- } else if (mode.compareTo("rw") == 0) {
- bb = fc.map(FileChannel.MapMode.READ_WRITE, 0L, (int)fc.size());
- } else {
- throw new IllegalArgumentException("Invalid mode: " + mode);
- }
-
- fc.close(); // doesn't need to remain open
-
- createPerfDataBuffer(bb, 0);
- } catch (FileNotFoundException e) {
- throw new MonitorException("Could not find " + vmid.toString());
- } catch (IOException e) {
- throw new MonitorException("Could not read " + vmid.toString());
- }
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/package.html Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-<!doctype html public "-//IETF//DTD HTML/EN">
-<html>
-<head>
-<!--
-
-
- Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
-
--->
-</head>
-<body bgcolor="white">
-<p>
-Provides the implementation classes for the <em>file:</em> protocol for
-the HotSpot PerfData instrumentation buffer monitoring implementation.
-</p>
-</body>
-</html>
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalEventTimer.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.MonitorStatus;
-import java.util.*;
-import java.util.regex.*;
-import java.io.*;
-
-/**
- * Singleton Timer subclass to run polling tasks that generate events
- * for local Java Virtual Machines..
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class LocalEventTimer extends Timer {
- private static LocalEventTimer instance; // singleton instance
-
- /**
- * Creates the singleton LocalEventTimer instance.
- */
- private LocalEventTimer() {
- super(true);
- }
-
- /**
- * Get the singleton LocalEventTimer instance
- *
- * @return LocalEventTimer - the singleton LocalEventTimer instance
- */
- public static synchronized LocalEventTimer getInstance() {
- if (instance == null) {
- instance = new LocalEventTimer();
- }
- return instance;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import java.util.*;
-import java.lang.reflect.*;
-import java.io.*;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.monitor.event.*;
-import sun.jvmstat.perfdata.monitor.*;
-
-/**
- * Concrete implementation of the AbstractMonitoredVm class for the
- * <em>local:</em> protocol for the HotSpot PerfData monitoring implementation.
- * <p>
- * This class provides the ability to attach to the instrumentation buffer
- * of a live target Java Virtual Machine through a HotSpot specific attach
- * mechanism.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class LocalMonitoredVm extends AbstractMonitoredVm {
-
- /**
- * List of registered listeners.
- */
- private ArrayList<VmListener> listeners;
-
- /**
- * Task performing listener notification.
- */
- private NotifierTask task;
-
- /**
- * Create a LocalMonitoredVm instance.
- *
- * @param vmid the vm identifier specifying the target JVM
- * @param interval the sampling interval
- */
- public LocalMonitoredVm(VmIdentifier vmid, int interval)
- throws MonitorException {
- super(vmid, interval);
- this.pdb = new PerfDataBuffer(vmid);
- listeners = new ArrayList<VmListener>();
- }
-
- /**
- * {@inheritDoc}.
- */
- public void detach() {
- if (interval > 0) {
- /*
- * if the notifier task is running, stop it, otherwise it can
- * access non-existent memory once we've detached from the
- * underlying buffer.
- */
- if (task != null) {
- task.cancel();
- task = null;
- }
- }
- super.detach();
- }
-
- /**
- * {@inheritDoc}.
- */
- public void addVmListener(VmListener l) {
- synchronized(listeners) {
- listeners.add(l);
- if (task == null) {
- task = new NotifierTask();
- LocalEventTimer timer = LocalEventTimer.getInstance();
- timer.schedule(task, interval, interval);
- }
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- public void removeVmListener(VmListener l) {
- synchronized(listeners) {
- listeners.remove(l);
- if (listeners.isEmpty() && task != null) {
- task.cancel();
- task = null;
- }
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- public void setInterval(int newInterval) {
- synchronized(listeners) {
- if (newInterval == interval) {
- return;
- }
-
- int oldInterval = interval;
- super.setInterval(newInterval);
-
- if (task != null) {
- task.cancel();
- NotifierTask oldTask = task;
- task = new NotifierTask();
- LocalEventTimer timer = LocalEventTimer.getInstance();
- CountedTimerTaskUtils.reschedule(timer, oldTask, task,
- oldInterval, newInterval);
- }
- }
- }
-
- /**
- * Fire MonitoredVmStructureChanged events.
- *
- * @param inserted List of Monitor objects inserted.
- * @param removed List of Monitor objects removed.
- */
- @SuppressWarnings("unchecked") // Cast of result of clone
- void fireMonitorStatusChangedEvents(List<Monitor> inserted, List<Monitor> removed) {
- MonitorStatusChangeEvent ev = null;
- ArrayList<VmListener> registered = null;
-
- synchronized (listeners) {
- registered = (ArrayList)listeners.clone();
- }
-
- for (Iterator<VmListener> i = registered.iterator(); i.hasNext(); /* empty */) {
- VmListener l = i.next();
- // lazily create the event object;
- if (ev == null) {
- ev = new MonitorStatusChangeEvent(this, inserted, removed);
- }
- l.monitorStatusChanged(ev);
- }
- }
-
- /**
- * Fire MonitoredUpdated events.
- */
- void fireMonitorsUpdatedEvents() {
- VmEvent ev = null;
- ArrayList<VmListener> registered = null;
-
- synchronized (listeners) {
- registered = cast(listeners.clone());
- }
-
- for (VmListener l : registered) {
- // lazily create the event object;
- if (ev == null) {
- ev = new VmEvent(this);
- }
- l.monitorsUpdated(ev);
- }
- }
-
- /**
- * Class to notify listeners of Monitor related events for
- * the target JVM.
- */
- private class NotifierTask extends CountedTimerTask {
- public void run() {
- super.run();
- try {
- MonitorStatus status = getMonitorStatus();
- List<Monitor> inserted = status.getInserted();
- List<Monitor> removed = status.getRemoved();
-
- if (!inserted.isEmpty() || !removed.isEmpty()) {
- fireMonitorStatusChangedEvents(inserted, removed);
- }
- fireMonitorsUpdatedEvents();
- } catch (MonitorException e) {
- // XXX: use logging api
- System.err.println("Exception updating monitors for "
- + getVmIdentifier());
- e.printStackTrace();
- }
- }
- }
- // Suppress unchecked cast warning msg.
- @SuppressWarnings("unchecked")
- static <T> T cast(Object x) {
- return (T) x;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.monitor.event.*;
-import java.util.*;
-import java.util.regex.*;
-import java.io.*;
-
-/**
- * Class for managing the LocalMonitoredVm instances on the local system.
- * <p>
- * This class is responsible for the mechanism that detects the active
- * HotSpot Java Virtual Machines on the local host and possibly for a
- * specific user. The ability to detect all possible HotSpot Java Virtual
- * Machines on the local host may be limited by the permissions of the
- * principal running this JVM.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class LocalVmManager {
- private String userName; // user name for monitored jvm
- private File tmpdir;
- private Pattern userPattern;
- private Matcher userMatcher;
- private FilenameFilter userFilter;
- private Pattern filePattern;
- private Matcher fileMatcher;
- private FilenameFilter fileFilter;
- private Pattern tmpFilePattern;
- private Matcher tmpFileMatcher;
- private FilenameFilter tmpFileFilter;
-
- /**
- * Creates a LocalVmManager instance for the local system.
- * <p>
- * Manages LocalMonitoredVm instances for which the principal
- * has appropriate permissions.
- */
- public LocalVmManager() {
- this(null);
- }
-
- /**
- * Creates a LocalVmManager instance for the given user.
- * <p>
- * Manages LocalMonitoredVm instances for all JVMs owned by the specified
- * user.
- *
- * @param user the name of the user
- */
- public LocalVmManager(String user) {
- this.userName = user;
-
- if (userName == null) {
- tmpdir = new File(PerfDataFile.getTempDirectory());
- userPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
- userMatcher = userPattern.matcher("");
-
- userFilter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- userMatcher.reset(name);
- return userMatcher.lookingAt();
- }
- };
- } else {
- tmpdir = new File(PerfDataFile.getTempDirectory(userName));
- }
-
- filePattern = Pattern.compile(PerfDataFile.fileNamePattern);
- fileMatcher = filePattern.matcher("");
-
- fileFilter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- fileMatcher.reset(name);
- return fileMatcher.matches();
- }
- };
-
- tmpFilePattern = Pattern.compile(PerfDataFile.tmpFileNamePattern);
- tmpFileMatcher = tmpFilePattern.matcher("");
-
- tmpFileFilter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- tmpFileMatcher.reset(name);
- return tmpFileMatcher.matches();
- }
- };
- }
-
- /**
- * Return the current set of monitorable Java Virtual Machines.
- * <p>
- * The set returned by this method depends on the user name passed
- * to the constructor. If no user name was specified, then this
- * method will return all candidate JVMs on the system. Otherwise,
- * only the JVMs for the given user will be returned. This assumes
- * that principal associated with this JVM has the appropriate
- * permissions to access the target set of JVMs.
- *
- * @return Set - the Set of monitorable Java Virtual Machines
- */
- public synchronized Set<Integer> activeVms() {
- /*
- * This method is synchronized because the Matcher object used by
- * fileFilter is not safe for concurrent use, and this method is
- * called by multiple threads. Before this method was synchronized,
- * we'd see strange file names being matched by the matcher.
- */
- Set<Integer> jvmSet = new HashSet<Integer>();
-
- if (! tmpdir.isDirectory()) {
- return jvmSet;
- }
-
- if (userName == null) {
- /*
- * get a list of all of the user temporary directories and
- * iterate over the list to find any files within those directories.
- */
- File[] dirs = tmpdir.listFiles(userFilter);
-
- for (int i = 0 ; i < dirs.length; i ++) {
- if (!dirs[i].isDirectory()) {
- continue;
- }
-
- // get a list of files from the directory
- File[] files = dirs[i].listFiles(fileFilter);
-
- if (files != null) {
- for (int j = 0; j < files.length; j++) {
- if (files[j].isFile() && files[j].canRead()) {
- jvmSet.add(
- PerfDataFile.getLocalVmId(files[j]));
- }
- }
- }
- }
- } else {
- /*
- * Check if the user directory can be accessed. Any of these
- * conditions may have asynchronously changed between subsequent
- * calls to this method.
- */
-
- // get the list of files from the specified user directory
- File[] files = tmpdir.listFiles(fileFilter);
-
- if (files != null) {
- for (int j = 0; j < files.length; j++) {
- if (files[j].isFile() && files[j].canRead()) {
- jvmSet.add(
- PerfDataFile.getLocalVmId(files[j]));
- }
- }
- }
- }
-
- // look for any 1.4.1 files
- File[] files = tmpdir.listFiles(tmpFileFilter);
- if (files != null) {
- for (int j = 0; j < files.length; j++) {
- if (files[j].isFile() && files[j].canRead()) {
- jvmSet.add(
- PerfDataFile.getLocalVmId(files[j]));
- }
- }
- }
-
- return jvmSet;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostLocalService.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import sun.jvmstat.monitor.HostIdentifier;
-import sun.jvmstat.monitor.MonitorException;
-import sun.jvmstat.monitor.MonitoredHost;
-import sun.jvmstat.monitor.MonitoredHostService;
-
-public final class MonitoredHostLocalService implements MonitoredHostService {
-
- @Override
- public MonitoredHost getMonitoredHost(HostIdentifier hostId)
- throws MonitorException {
- return new MonitoredHostProvider(hostId);
- }
-
- @Override
- public String getScheme() {
- return "local";
- }
-
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostProvider.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.monitor.event.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.util.*;
-import java.net.*;
-
-/**
- * Concrete implementation of the MonitoredHost interface for the
- * <em>local</em> protocol of the HotSpot PerfData monitoring implementation.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class MonitoredHostProvider extends MonitoredHost {
- private static final int DEFAULT_POLLING_INTERVAL = 1000;
-
- private ArrayList<HostListener> listeners;
- private NotifierTask task;
- private HashSet<Integer> activeVms;
- private LocalVmManager vmManager;
-
- /**
- * Create a MonitoredHostProvider instance using the given HostIdentifier.
- *
- * @param hostId the host identifier for this MonitoredHost
- */
- public MonitoredHostProvider(HostIdentifier hostId) {
- this.hostId = hostId;
- this.listeners = new ArrayList<HostListener>();
- this.interval = DEFAULT_POLLING_INTERVAL;
- this.activeVms = new HashSet<Integer>();
- this.vmManager = new LocalVmManager();
- }
-
- /**
- * {@inheritDoc}
- */
- public MonitoredVm getMonitoredVm(VmIdentifier vmid)
- throws MonitorException {
- return getMonitoredVm(vmid, DEFAULT_POLLING_INTERVAL);
- }
-
- /**
- * {@inheritDoc}
- */
- public MonitoredVm getMonitoredVm(VmIdentifier vmid, int interval)
- throws MonitorException {
- try {
- VmIdentifier nvmid = hostId.resolve(vmid);
- return new LocalMonitoredVm(nvmid, interval);
- } catch (URISyntaxException e) {
- /*
- * the VmIdentifier is expected to be a valid and it should
- * resolve reasonably against the host identifier. A
- * URISyntaxException here is most likely a programming error.
- */
- throw new IllegalArgumentException("Malformed URI: "
- + vmid.toString(), e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void detach(MonitoredVm vm) {
- vm.detach();
- }
-
- /**
- * {@inheritDoc}
- */
- public void addHostListener(HostListener listener) {
- synchronized(listeners) {
- listeners.add(listener);
- if (task == null) {
- task = new NotifierTask();
- LocalEventTimer timer = LocalEventTimer.getInstance();
- timer.schedule(task, interval, interval);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeHostListener(HostListener listener) {
- synchronized(listeners) {
- listeners.remove(listener);
- if (listeners.isEmpty() && (task != null)) {
- task.cancel();
- task = null;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void setInterval(int newInterval) {
- synchronized(listeners) {
- if (newInterval == interval) {
- return;
- }
-
- int oldInterval = interval;
- super.setInterval(newInterval);
-
- if (task != null) {
- task.cancel();
- NotifierTask oldTask = task;
- task = new NotifierTask();
- LocalEventTimer timer = LocalEventTimer.getInstance();
- CountedTimerTaskUtils.reschedule(timer, oldTask, task,
- oldInterval, newInterval);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<Integer> activeVms() {
- return vmManager.activeVms();
- }
-
- /**
- * Fire VmEvent events.
- *
- * @param active a set of Integer objects containing the vmid of
- * the active Vms
- * @param started a set of Integer objects containing the vmid of
- * new Vms started since last interval.
- * @param terminated a set of Integer objects containing the vmid of
- * terminated Vms since last interval.
- */
- @SuppressWarnings("unchecked") // Cast of result of clone
- private void fireVmStatusChangedEvents(Set<Integer> active, Set<Integer> started,
- Set<Integer> terminated) {
- ArrayList<HostListener> registered = null;
- VmStatusChangeEvent ev = null;
-
- synchronized(listeners) {
- registered = (ArrayList)listeners.clone();
- }
-
- for (Iterator<HostListener> i = registered.iterator(); i.hasNext(); /* empty */) {
- HostListener l = i.next();
- if (ev == null) {
- ev = new VmStatusChangeEvent(this, active, started, terminated);
- }
- l.vmStatusChanged(ev);
- }
- }
-
- /**
- * Class to poll the local system and generate event notifications.
- */
- private class NotifierTask extends CountedTimerTask {
- public void run() {
- super.run();
-
- // save the last set of active JVMs
- Set<Integer> lastActiveVms = activeVms;
-
- // get the current set of active JVMs
- activeVms = (HashSet<Integer>)vmManager.activeVms();
-
- if (activeVms.isEmpty()) {
- return;
- }
- Set<Integer> startedVms = new HashSet<>();
- Set<Integer> terminatedVms = new HashSet<>();
-
- for (Iterator<Integer> i = activeVms.iterator(); i.hasNext(); /* empty */) {
- Integer vmid = i.next();
- if (!lastActiveVms.contains(vmid)) {
- // a new file has been detected, add to set
- startedVms.add(vmid);
- }
- }
-
- for (Iterator<Integer> i = lastActiveVms.iterator(); i.hasNext();
- /* empty */) {
- Integer o = i.next();
- if (!activeVms.contains(o)) {
- // JVM has terminated, remove it from the active list
- terminatedVms.add(o);
- }
- }
-
- if (!startedVms.isEmpty() || !terminatedVms.isEmpty()) {
- fireVmStatusChangedEvents(activeVms, startedVms,
- terminatedVms);
- }
- }
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import jdk.internal.perf.Perf;
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.util.*;
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.lang.reflect.Constructor;
-import java.security.AccessController;
-
-/**
- * The concrete PerfDataBuffer implementation for the <em>local:</em>
- * protocol for the HotSpot PerfData monitoring implementation.
- * <p>
- * This class is responsible for acquiring access to the shared memory
- * instrumentation buffer for the target HotSpot Java Virtual Machine.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-// Suppreess unchecked conversion warning at line 34.
-//@SuppressWarnings("unchecked")
-public class PerfDataBuffer extends AbstractPerfDataBuffer {
- private static final Perf perf = AccessController.doPrivileged(new Perf.GetPerfAction());
-
- /**
- * Create a PerfDataBuffer instance for accessing the specified
- * instrumentation buffer.
- *
- * @param vmid the <em>local:</em> URI specifying the target JVM.
- *
- * @throws MonitorException
- */
- public PerfDataBuffer(VmIdentifier vmid) throws MonitorException {
- try {
- // Try 1.4.2 and later first
- ByteBuffer bb = perf.attach(vmid.getLocalVmId(), vmid.getMode());
- createPerfDataBuffer(bb, vmid.getLocalVmId());
-
- } catch (IllegalArgumentException e) {
- // now try 1.4.1 by attempting to directly map the files.
- try {
- String filename = PerfDataFile.getTempDirectory()
- + PerfDataFile.dirNamePrefix
- + Integer.toString(vmid.getLocalVmId());
-
- File f = new File(filename);
-
- FileChannel fc = new RandomAccessFile(f, "r").getChannel();
- ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0L,
- (int)fc.size());
- fc.close();
- createPerfDataBuffer(bb, vmid.getLocalVmId());
-
- } catch (FileNotFoundException e2) {
- // re-throw the exception from the 1.4.2 attach method
- throw new MonitorException(vmid.getLocalVmId() + " not found",
- e);
- } catch (IOException e2) {
- throw new MonitorException("Could not map 1.4.1 file for "
- + vmid.getLocalVmId(), e2);
- }
- } catch (IOException e) {
- throw new MonitorException("Could not attach to "
- + vmid.getLocalVmId(), e);
- }
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.protocol.local;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import jdk.internal.vm.VMSupport;
-
-/**
- * Class to provide translations from the local Vm Identifier
- * name space into the file system name space and vice-versa.
- * <p>
- * Provides a factory for creating a File object to the backing
- * store file for instrumentation shared memory region for a JVM
- * identified by its Local Java Virtual Machine Identifier, or
- * <em>lvmid</em>.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see java.io.File
- */
-public class PerfDataFile {
- private PerfDataFile() { };
-
- /**
- * The name of the of the system dependent temporary directory
- */
- public static final String tmpDirName;
-
- /**
- * The file name prefix for PerfData shared memory files.
- * <p>
- * This prefix must be kept in sync with the prefix used by the JVM.
- */
- public static final String dirNamePrefix = "hsperfdata_";
-
- /**
- * The directory name pattern for the user directories.
- */
- public static final String userDirNamePattern = "hsperfdata_\\S*";
-
- /**
- * The file name pattern for PerfData shared memory files.
- * <p>
- * This pattern must be kept in synch with the file name pattern
- * used by the 1.4.2 and later HotSpot JVM.
- */
- public static final String fileNamePattern = "^[0-9]+$";
-
- /**
- * The file name pattern for 1.4.1 PerfData shared memory files.
- * <p>
- * This pattern must be kept in synch with the file name pattern
- * used by the 1.4.1 HotSpot JVM.
- */
- public static final String tmpFileNamePattern =
- "^hsperfdata_[0-9]+(_[1-2]+)?$";
-
-
- /**
- * Get a File object for the instrumentation backing store file
- * for the JVM identified by the given local Vm Identifier.
- * <p>
- * This method looks for the most up to date backing store file for
- * the given {@code lvmid}. It will search all the user specific
- * directories in the temporary directory for the host operating
- * system, which may be influenced by platform specific environment
- * variables.
- *
- * @param lvmid the local Java Virtual Machine Identifier for the target
- * @return File - a File object to the backing store file for the named
- * shared memory region of the target JVM.
- * @see java.io.File
- * @see #getTempDirectory()
- */
- public static File getFile(int lvmid) {
- if (lvmid == 0) {
- /*
- * lvmid == 0 is used to indicate the current Java Virtual Machine.
- * If the SDK provided an API to get a unique Java Virtual Machine
- * identifier, then a filename could be constructed with that
- * identifier. In absence of such an api, return null.
- */
- return null;
- }
-
- /*
- * iterate over all files in all directories in tmpDirName that
- * match the file name patterns.
- */
- File tmpDir = new File(tmpDirName);
- String[] files = tmpDir.list(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- if (!name.startsWith(dirNamePrefix)) {
- return false;
- }
- File candidate = new File(dir, name);
- return ((candidate.isDirectory() || candidate.isFile())
- && candidate.canRead());
- }
- });
-
- long newestTime = 0;
- File newest = null;
-
- for (int i = 0; i < files.length; i++) {
- File f = new File(tmpDirName + files[i]);
- File candidate = null;
-
- if (f.exists() && f.isDirectory()) {
- /*
- * found a directory matching the name patterns. This
- * is a 1.4.2 hsperfdata_<user> directory. Check for
- * file named <lvmid> in that directory
- */
- String name = Integer.toString(lvmid);
- candidate = new File(f.getName(), name);
-
- } else if (f.exists() && f.isFile()) {
- /*
- * found a file matching the name patterns. This
- * is a 1.4.1 hsperfdata_<lvmid> file.
- */
- candidate = f;
-
- } else {
- // unexpected - let conditional below filter this one out
- candidate = f;
- }
-
- if (candidate.exists() && candidate.isFile()
- && candidate.canRead()) {
- long modTime = candidate.lastModified();
- if (modTime >= newestTime) {
- newestTime = modTime;
- newest = candidate;
- }
- }
- }
- return newest;
- }
-
- /**
- * Return the File object for the backing store file for the specified Java
- * Virtual Machine.
- * <p>
- * This method looks for the most up to date backing store file for
- * the JVM identified by the given user name and lvmid. The directory
- * searched is the temporary directory for the host operating system,
- * which may be influenced by environment variables.
- *
- * @param user the user name
- * @param lvmid the local Java Virtual Machine Identifier for the target
- * @return File - a File object to the backing store file for the named
- * shared memory region of the target JVM.
- * @see java.io.File
- * @see #getTempDirectory()
- */
- public static File getFile(String user, int lvmid) {
- if (lvmid == 0) {
- /*
- * lvmid == 0 is used to indicate the current Java Virtual Machine.
- * If the SDK provided an API to get a unique Java Virtual Machine
- * identifier, then a filename could be constructed with that
- * identifier. In absence of such an api, return null.
- */
- return null;
- }
-
- // first try for 1.4.2 and later JVMs
- String basename = getTempDirectory(user) + Integer.toString(lvmid);
- File f = new File(basename);
-
- if (f.exists() && f.isFile() && f.canRead()) {
- return f;
- }
-
- // No hit on 1.4.2 JVMs, try 1.4.1 files
- long newestTime = 0;
- File newest = null;
- for (int i = 0; i < 2; i++) {
- if (i == 0) {
- basename = getTempDirectory() + Integer.toString(lvmid);
- } else {
- basename = getTempDirectory() + Integer.toString(lvmid)
- + Integer.toString(i);
- }
-
- f = new File(basename);
-
- if (f.exists() && f.isFile() && f.canRead()) {
- long modTime = f.lastModified();
- if (modTime >= newestTime) {
- newestTime = modTime;
- newest = f;
- }
- }
- }
- return newest;
- }
-
- /**
- * Method to extract a local Java Virtual Machine Identifier from the
- * file name of the given File object.
- *
- * @param file A File object representing the name of a
- * shared memory region for a target JVM
- * @return int - the local Java Virtual Machine Identifier for the target
- * associated with the file
- * @throws java.lang.IllegalArgumentException Thrown if the file name
- * does not conform to the expected pattern
- */
- public static int getLocalVmId(File file) {
- try {
- // try 1.4.2 and later format first
- return Integer.parseInt(file.getName());
- } catch (NumberFormatException e) { }
-
- // now try the 1.4.1 format
- String name = file.getName();
- if (name.startsWith(dirNamePrefix)) {
- int first = name.indexOf('_');
- int last = name.lastIndexOf('_');
- try {
- if (first == last) {
- return Integer.parseInt(name.substring(first + 1));
- } else {
- return Integer.parseInt(name.substring(first + 1, last));
- }
- } catch (NumberFormatException e) { }
- }
- throw new IllegalArgumentException("file name does not match pattern");
- }
-
- /**
- * Return the name of the temporary directory being searched for
- * HotSpot PerfData backing store files.
- * <p>
- * This method generally returns the value of the java.io.tmpdir
- * property. However, on some platforms it may return a different
- * directory, as the JVM implementation may store the PerfData backing
- * store files in a different directory for performance reasons.
- *
- * @return String - the name of the temporary directory.
- */
- public static String getTempDirectory() {
- return tmpDirName;
- }
-
- /**
- * Return the name of the temporary directory to be searched
- * for HotSpot PerfData backing store files for a given user.
- * <p>
- * This method generally returns the name of a subdirectory of
- * the directory indicated in the java.io.tmpdir property. However,
- * on some platforms it may return a different directory, as the
- * JVM implementation may store the PerfData backing store files
- * in a different directory for performance reasons.
- *
- * @return String - the name of the temporary directory.
- */
- public static String getTempDirectory(String user) {
- return tmpDirName + dirNamePrefix + user + File.separator;
- }
-
- static {
- /*
- * For this to work, the target VM and this code need to use
- * the same directory. Instead of guessing which directory the
- * VM is using, we will ask.
- */
- String tmpdir = VMSupport.getVMTemporaryDirectory();
-
- /*
- * Assure that the string returned has a trailing File.separator
- * character. This check was added because the Linux implementation
- * changed such that the java.io.tmpdir string no longer terminates
- * with a File.separator character.
- */
- if (tmpdir.lastIndexOf(File.separator) != (tmpdir.length()-1)) {
- tmpdir = tmpdir + File.separator;
- }
- tmpDirName = tmpdir;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/package.html Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-<!doctype html public "-//IETF//DTD HTML/EN">
-<html>
-<head>
-<!--
-
-
- Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- particular file as subject to the "Classpath" exception as provided
- by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions.
-
-
--->
-</head>
-<body bgcolor="white">
-<p>
-Provides the implementation classes for the <em>local:</em> protocol for
-the HotSpot PerfData instrumentation buffer monitoring implementation.
-</p>
-<p>
-The <em>local:</em> protocol is the default protocol for the PerfData
-implementation. It utilizes a name shared memory mechanism, identified
-by a backing store file in the file system name space. The location of
-the backing store file is platform specific and is dictated primarily by
-the JVM implementation. However, the <code>java.io.tmpdir</code> system
-property generally contains the location of the files, with the exception
-of the Solaris implementation, as the SDK and HotSpot JVM use different
-locations for their temporary file storage. The HotSpot JVM uses the
-<em>/tmp</em> directory and the SDK uses <em>/var/tmp</em>. The classes
-in this specifically use <em>/tmp</em> when running on Solaris.
-</body>
-</html>
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/BasicType.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.v1_0;
-
-/**
- * A typesafe enumeration for describing Java basic types.
- *
- * <p> The enumeration values for this typesafe enumeration must be
- * kept in synchronization with the BasicType enum in the
- * globalsDefinitions.hpp file in the HotSpot source base.</p>
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class BasicType {
-
- private final String name;
- private final int value;
-
- public static final BasicType BOOLEAN = new BasicType("boolean", 4);
- public static final BasicType CHAR = new BasicType("char", 5);
- public static final BasicType FLOAT = new BasicType("float", 6);
- public static final BasicType DOUBLE = new BasicType("double", 7);
- public static final BasicType BYTE = new BasicType("byte", 8);
- public static final BasicType SHORT = new BasicType("short", 9);
- public static final BasicType INT = new BasicType("int", 10);
- public static final BasicType LONG = new BasicType("long", 11);
- public static final BasicType OBJECT = new BasicType("object", 12);
- public static final BasicType ARRAY = new BasicType("array", 13);
- public static final BasicType VOID = new BasicType("void", 14);
- public static final BasicType ADDRESS = new BasicType("address", 15);
- public static final BasicType ILLEGAL = new BasicType("illegal", 99);
-
- private static BasicType basicTypes[] = {
- BOOLEAN, CHAR, FLOAT, DOUBLE, BYTE, SHORT, INT, LONG, OBJECT,
- ARRAY, VOID, ADDRESS, ILLEGAL
- };
-
- /**
- * Convert enumeration value to a String.
- *
- * @return String - the string representation for the enumeration.
- */
- public String toString() {
- return name;
- }
-
- /**
- * Convert enumeration to an integer value.
- *
- * @return int - the integer representation for the enumeration.
- */
- public int intValue() {
- return value;
- }
-
- /**
- * Map an integer value to its corresponding BasicType object.
- *
- * @param i an integer representation of a BasicType
- * @return BasicType - The BasicType enumeration object matching
- * the value of <code>i</code>
- */
- public static BasicType toBasicType(int i) {
- for (int j = 0; j < basicTypes.length; j++) {
- if (basicTypes[j].intValue() == j) {
- return (basicTypes[j]);
- }
- }
- return ILLEGAL;
- }
-
- private BasicType(String name, int value) {
- this.name = name;
- this.value = value;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,605 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.v1_0;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.util.*;
-import java.util.regex.*;
-import java.nio.*;
-
-/**
- * The concrete implementation of version 1.0 of the HotSpot PerfData
- * Instrumentation buffer. This class is responsible for parsing the
- * instrumentation memory and constructing the necessary objects to
- * represent and access the instrumentation objects contained in the
- * memory buffer.
- *
- * @author Brian Doherty
- * @since 1.5
- * @see AbstractPerfDataBuffer
- */
-public class PerfDataBuffer extends PerfDataBufferImpl {
-
- // 8028357 removed old, inefficient debug logging
-
- private static final int syncWaitMs =
- Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
- private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<Monitor>(0);
-
- /*
- * the following constants must be kept in sync with struct
- * PerfDataEntry in perfMemory.hpp
- */
- private final static int PERFDATA_ENTRYLENGTH_OFFSET=0;
- private final static int PERFDATA_ENTRYLENGTH_SIZE=4; // sizeof(int)
- private final static int PERFDATA_NAMELENGTH_OFFSET=4;
- private final static int PERFDATA_NAMELENGTH_SIZE=4; // sizeof(int)
- private final static int PERFDATA_VECTORLENGTH_OFFSET=8;
- private final static int PERFDATA_VECTORLENGTH_SIZE=4; // sizeof(int)
- private final static int PERFDATA_DATATYPE_OFFSET=12;
- private final static int PERFDATA_DATATYPE_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_FLAGS_OFFSET=13;
- private final static int PERFDATA_FLAGS_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_DATAUNITS_OFFSET=14;
- private final static int PERFDATA_DATAUNITS_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_DATAATTR_OFFSET=15;
- private final static int PERFDATA_DATAATTR_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_NAME_OFFSET=16;
-
- PerfDataBufferPrologue prologue;
- int nextEntry;
- int pollForEntry;
- int perfDataItem;
- long lastModificationTime;
- int lastUsed;
- IntegerMonitor overflow;
- ArrayList<Monitor> insertedMonitors;
-
- /**
- * Construct a PerfDataBufferImpl instance.
- * <p>
- * This class is dynamically loaded by
- * {@link AbstractPerfDataBuffer#createPerfDataBuffer}, and this
- * constructor is called to instantiate the instance.
- *
- * @param buffer the buffer containing the instrumentation data
- * @param lvmid the Local Java Virtual Machine Identifier for this
- * instrumentation buffer.
- */
- public PerfDataBuffer(ByteBuffer buffer, int lvmid)
- throws MonitorException {
- super(buffer, lvmid);
- prologue = new PerfDataBufferPrologue(buffer);
- this.buffer.order(prologue.getByteOrder());
- }
-
- /**
- * {@inheritDoc}
- */
- protected void buildMonitorMap(Map<String, Monitor> map) throws MonitorException {
- assert Thread.holdsLock(this);
-
- // start at the beginning of the buffer
- buffer.rewind();
-
- // create pseudo monitors
- buildPseudoMonitors(map);
-
- // position buffer to start of the data section
- buffer.position(prologue.getSize());
- nextEntry = buffer.position();
- perfDataItem = 0;
-
- int used = prologue.getUsed();
- long modificationTime = prologue.getModificationTimeStamp();
-
- Monitor m = getNextMonitorEntry();
- while (m != null) {
- map.put(m.getName(), m);
- m = getNextMonitorEntry();
- }
-
- /*
- * set the last modification data. These are set to the values
- * recorded before parsing the data structure. This allows the
- * the data structure to be modified while the Map is being built.
- * The Map may contain more entries than indicated based on the
- * time stamp, but this is handled by ignoring duplicate entries
- * when the Map is updated in getNewMonitors().
- */
- lastUsed = used;
- lastModificationTime = modificationTime;
-
- // synchronize with the target jvm
- synchWithTarget(map);
-
- // work around 1.4.2 counter inititization bugs
- kludge(map);
-
- insertedMonitors = new ArrayList<Monitor>(map.values());
- }
-
- /**
- * {@inheritDoc}
- */
- protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
- assert Thread.holdsLock(this);
-
- int used = prologue.getUsed();
- long modificationTime = prologue.getModificationTimeStamp();
-
- if ((used > lastUsed) || (lastModificationTime > modificationTime)) {
-
- lastUsed = used;
- lastModificationTime = modificationTime;
-
- Monitor monitor = getNextMonitorEntry();
- while (monitor != null) {
- String name = monitor.getName();
-
- // guard against duplicate entries
- if (!map.containsKey(name)) {
- map.put(name, monitor);
-
- /*
- * insertedMonitors is null when called from pollFor()
- * via buildMonitorMap(). Since we update insertedMonitors
- * at the end of buildMonitorMap(), it's ok to skip the
- * add here.
- */
- if (insertedMonitors != null) {
- insertedMonitors.add(monitor);
- }
- }
- monitor = getNextMonitorEntry();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected MonitorStatus getMonitorStatus(Map<String, Monitor> map) throws MonitorException {
- assert Thread.holdsLock(this);
- assert insertedMonitors != null;
-
- // load any new monitors
- getNewMonitors(map);
-
- // current implementation doesn't support deletion or reuse of entries
- ArrayList<Monitor> removed = EMPTY_LIST;
- ArrayList<Monitor> inserted = insertedMonitors;
-
- insertedMonitors = new ArrayList<Monitor>();
- return new MonitorStatus(inserted, removed);
- }
-
- /**
- * Build the pseudo monitors used to map the prolog data into counters.
- */
- protected void buildPseudoMonitors(Map<String, Monitor> map) {
- Monitor monitor = null;
- String name = null;
- IntBuffer ib = null;
-
- name = PerfDataBufferPrologue.PERFDATA_MAJOR_NAME;
- ib = prologue.majorVersionBuffer();
- monitor = new PerfIntegerMonitor(name, Units.NONE,
- Variability.CONSTANT, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_MINOR_NAME;
- ib = prologue.minorVersionBuffer();
- monitor = new PerfIntegerMonitor(name, Units.NONE,
- Variability.CONSTANT, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_BUFFER_SIZE_NAME;
- ib = prologue.sizeBuffer();
- monitor = new PerfIntegerMonitor(name, Units.BYTES,
- Variability.MONOTONIC, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_BUFFER_USED_NAME;
- ib = prologue.usedBuffer();
- monitor = new PerfIntegerMonitor(name, Units.BYTES,
- Variability.MONOTONIC, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_OVERFLOW_NAME;
- ib = prologue.overflowBuffer();
- monitor = new PerfIntegerMonitor(name, Units.BYTES,
- Variability.MONOTONIC, false, ib);
- map.put(name, monitor);
- this.overflow = (IntegerMonitor)monitor;
-
- name = PerfDataBufferPrologue.PERFDATA_MODTIMESTAMP_NAME;
- LongBuffer lb = prologue.modificationTimeStampBuffer();
- monitor = new PerfLongMonitor(name, Units.TICKS,
- Variability.MONOTONIC, false, lb);
- map.put(name, monitor);
- }
-
- /**
- * Method to provide a gross level of synchronization with the
- * target monitored jvm.
- *
- * gross synchronization works by polling for the hotspot.rt.hrt.ticks
- * counter, which is the last counter created by the StatSampler
- * initialization code. The counter is updated when the watcher thread
- * starts scheduling tasks, which is the last thing done in vm
- * initialization.
- */
- protected void synchWithTarget(Map<String, Monitor> map) throws MonitorException {
- /*
- * synch must happen with syncWaitMs from now. Default is 5 seconds,
- * which is reasonabally generous and should provide for extreme
- * situations like startup delays due to allocation of large ISM heaps.
- */
- long timeLimit = System.currentTimeMillis() + syncWaitMs;
-
- String name = "hotspot.rt.hrt.ticks";
- LongMonitor ticks = (LongMonitor)pollFor(map, name, timeLimit);
-
- /*
- * loop waiting for the ticks counter to be non zero. This is
- * an indication that the jvm is initialized.
- */
- while (ticks.longValue() == 0) {
- try { Thread.sleep(20); } catch (InterruptedException e) { }
-
- if (System.currentTimeMillis() > timeLimit) {
- throw new MonitorException("Could Not Synchronize with target");
- }
- }
- }
-
- /**
- * Method to poll the instrumentation memory for a counter with
- * the given name. The polling period is bounded by the timeLimit
- * argument.
- */
- protected Monitor pollFor(Map<String, Monitor> map, String name, long timeLimit)
- throws MonitorException {
- Monitor monitor = null;
-
- pollForEntry = nextEntry;
- while ((monitor = map.get(name)) == null) {
-
- try { Thread.sleep(20); } catch (InterruptedException e) { }
-
- long t = System.currentTimeMillis();
- if ((t > timeLimit) || (overflow.intValue() > 0)) {
- throw new MonitorException("Could not find expected counter");
- }
-
- getNewMonitors(map);
- }
- return monitor;
- }
-
- /**
- * method to make adjustments for known counter problems. This
- * method depends on the availability of certain counters, which
- * is generally guaranteed by the synchWithTarget() method.
- */
- protected void kludge(Map<String, Monitor> map) {
- if (Boolean.getBoolean("sun.jvmstat.perfdata.disableKludge")) {
- // bypass all kludges
- return;
- }
-
- String name = "java.vm.version";
- StringMonitor jvm_version = (StringMonitor)map.get(name);
- if (jvm_version == null) {
- jvm_version = (StringMonitor)findByAlias(name);
- }
-
- name = "java.vm.name";
- StringMonitor jvm_name = (StringMonitor)map.get(name);
- if (jvm_name == null) {
- jvm_name = (StringMonitor)findByAlias(name);
- }
-
- name = "hotspot.vm.args";
- StringMonitor args = (StringMonitor)map.get(name);
- if (args == null) {
- args = (StringMonitor)findByAlias(name);
- }
-
- assert ((jvm_name != null) && (jvm_version != null) && (args != null));
-
- if (jvm_name.stringValue().indexOf("HotSpot") >= 0) {
- if (jvm_version.stringValue().startsWith("1.4.2")) {
- kludgeMantis(map, args);
- }
- }
- }
-
- /**
- * method to repair the 1.4.2 parallel scavenge counters that are
- * incorrectly initialized by the JVM when UseAdaptiveSizePolicy
- * is set. This bug couldn't be fixed for 1.4.2 FCS due to putback
- * restrictions.
- */
- private void kludgeMantis(Map<String, Monitor> map, StringMonitor args) {
- /*
- * the HotSpot 1.4.2 JVM with the +UseParallelGC option along
- * with its default +UseAdaptiveSizePolicy option has a bug with
- * the initialization of the sizes of the eden and survivor spaces.
- * See bugid 4890736.
- *
- * note - use explicit 1.4.2 counter names here - don't update
- * to latest counter names or attempt to find aliases.
- */
-
- String cname = "hotspot.gc.collector.0.name";
- StringMonitor collector = (StringMonitor)map.get(cname);
-
- if (collector.stringValue().compareTo("PSScavenge") == 0) {
- boolean adaptiveSizePolicy = true;
-
- /*
- * HotSpot processes the -XX:Flags/.hotspotrc arguments prior to
- * processing the command line arguments. This allows the command
- * line arguments to override any defaults set in .hotspotrc
- */
- cname = "hotspot.vm.flags";
- StringMonitor flags = (StringMonitor)map.get(cname);
- String allArgs = flags.stringValue() + " " + args.stringValue();
-
- /*
- * ignore the -XX: prefix as it only applies to the arguments
- * passed from the command line (i.e. the invocation api).
- * arguments passed through .hotspotrc omit the -XX: prefix.
- */
- int ahi = allArgs.lastIndexOf("+AggressiveHeap");
- int aspi = allArgs.lastIndexOf("-UseAdaptiveSizePolicy");
-
- if (ahi != -1) {
- /*
- * +AggressiveHeap was set, check if -UseAdaptiveSizePolicy
- * is set after +AggressiveHeap.
- */
- //
- if ((aspi != -1) && (aspi > ahi)) {
- adaptiveSizePolicy = false;
- }
- } else {
- /*
- * +AggressiveHeap not set, must be +UseParallelGC. The
- * relative position of -UseAdaptiveSizePolicy is not
- * important in this case, as it will override the
- * UseParallelGC default (+UseAdaptiveSizePolicy) if it
- * appears anywhere in the JVM arguments.
- */
- if (aspi != -1) {
- adaptiveSizePolicy = false;
- }
- }
-
- if (adaptiveSizePolicy) {
- // adjust the buggy AdaptiveSizePolicy size counters.
-
- // first remove the real counters.
- String eden_size = "hotspot.gc.generation.0.space.0.size";
- String s0_size = "hotspot.gc.generation.0.space.1.size";
- String s1_size = "hotspot.gc.generation.0.space.2.size";
- map.remove(eden_size);
- map.remove(s0_size);
- map.remove(s1_size);
-
- // get the maximum new generation size
- String new_max_name = "hotspot.gc.generation.0.capacity.max";
- LongMonitor new_max = (LongMonitor)map.get(new_max_name);
-
- /*
- * replace the real counters with pseudo counters that are
- * initialized to the correct values. The maximum size of
- * the eden and survivor spaces are supposed to be:
- * max_eden_size = new_size - (2*alignment).
- * max_survivor_size = new_size - (2*alignment).
- * since we don't know the alignment value used, and because
- * of other parallel scavenge bugs that result in oversized
- * spaces, we just set the maximum size of each space to the
- * full new gen size.
- */
- Monitor monitor = null;
-
- LongBuffer lb = LongBuffer.allocate(1);
- lb.put(new_max.longValue());
- monitor = new PerfLongMonitor(eden_size, Units.BYTES,
- Variability.CONSTANT, false, lb);
- map.put(eden_size, monitor);
-
- monitor = new PerfLongMonitor(s0_size, Units.BYTES,
- Variability.CONSTANT, false, lb);
- map.put(s0_size, monitor);
-
- monitor = new PerfLongMonitor(s1_size, Units.BYTES,
- Variability.CONSTANT, false, lb);
- map.put(s1_size, monitor);
- }
- }
- }
-
- /**
- * method to extract the next monitor entry from the instrumentation memory.
- * assumes that nextEntry is the offset into the byte array
- * at which to start the search for the next entry. method leaves
- * next entry pointing to the next entry or to the end of data.
- */
- protected Monitor getNextMonitorEntry() throws MonitorException {
- Monitor monitor = null;
-
- // entries are always 4 byte aligned.
- if ((nextEntry % 4) != 0) {
- throw new MonitorStructureException(
- "Entry index not properly aligned: " + nextEntry);
- }
-
- // protect against a corrupted shared memory region.
- if ((nextEntry < 0) || (nextEntry > buffer.limit())) {
- throw new MonitorStructureException(
- "Entry index out of bounds: nextEntry = " + nextEntry
- + ", limit = " + buffer.limit());
- }
-
- // check for the end of the buffer
- if (nextEntry == buffer.limit()) {
- return null;
- }
-
- buffer.position(nextEntry);
-
- int entryStart = buffer.position();
- int entryLength = buffer.getInt();
-
- // check for valid entry length
- if ((entryLength < 0) || (entryLength > buffer.limit())) {
- throw new MonitorStructureException(
- "Invalid entry length: entryLength = " + entryLength);
- }
-
- // check if last entry occurs before the eof.
- if ((entryStart + entryLength) > buffer.limit()) {
- throw new MonitorStructureException(
- "Entry extends beyond end of buffer: "
- + " entryStart = " + entryStart
- + " entryLength = " + entryLength
- + " buffer limit = " + buffer.limit());
- }
-
- if (entryLength == 0) {
- // end of data
- return null;
- }
-
- int nameLength = buffer.getInt();
- int vectorLength = buffer.getInt();
- byte dataType = buffer.get();
- byte flags = buffer.get();
- Units u = Units.toUnits(buffer.get());
- Variability v = Variability.toVariability(buffer.get());
- boolean supported = (flags & 0x01) != 0;
-
- // defend against corrupt entries
- if ((nameLength <= 0) || (nameLength > entryLength)) {
- throw new MonitorStructureException(
- "Invalid Monitor name length: " + nameLength);
- }
-
- if ((vectorLength < 0) || (vectorLength > entryLength)) {
- throw new MonitorStructureException(
- "Invalid Monitor vector length: " + vectorLength);
- }
-
- // read in the perfData item name, casting bytes to chars. skip the
- // null terminator
- //
- byte[] nameBytes = new byte[nameLength-1];
- for (int i = 0; i < nameLength-1; i++) {
- nameBytes[i] = buffer.get();
- }
-
- // convert name into a String
- String name = new String(nameBytes, 0, nameLength-1);
-
- if (v == Variability.INVALID) {
- throw new MonitorDataException("Invalid variability attribute:"
- + " entry index = " + perfDataItem
- + " name = " + name);
- }
- if (u == Units.INVALID) {
- throw new MonitorDataException("Invalid units attribute: "
- + " entry index = " + perfDataItem
- + " name = " + name);
- }
-
- int offset;
- if (vectorLength == 0) {
- // scalar Types
- if (dataType == BasicType.LONG.intValue()) {
- offset = entryStart + entryLength - 8; /* 8 = sizeof(long) */
- buffer.position(offset);
- LongBuffer lb = buffer.asLongBuffer();
- lb.limit(1);
- monitor = new PerfLongMonitor(name, u, v, supported, lb);
- perfDataItem++;
- } else {
- // bad data types.
- throw new MonitorTypeException("Invalid Monitor type:"
- + " entry index = " + perfDataItem
- + " name = " + name
- + " type = " + dataType);
- }
- } else {
- // vector types
- if (dataType == BasicType.BYTE.intValue()) {
- if (u != Units.STRING) {
- // only byte arrays of type STRING are currently supported
- throw new MonitorTypeException("Invalid Monitor type:"
- + " entry index = " + perfDataItem
- + " name = " + name
- + " type = " + dataType);
- }
-
- offset = entryStart + PERFDATA_NAME_OFFSET + nameLength;
- buffer.position(offset);
- ByteBuffer bb = buffer.slice();
- bb.limit(vectorLength);
- bb.position(0);
-
- if (v == Variability.CONSTANT) {
- monitor = new PerfStringConstantMonitor(name, supported,
- bb);
- } else if (v == Variability.VARIABLE) {
- monitor = new PerfStringVariableMonitor(name, supported,
- bb, vectorLength-1);
- } else {
- // Monotonically increasing byte arrays are not supported
- throw new MonitorDataException(
- "Invalid variability attribute:"
- + " entry index = " + perfDataItem
- + " name = " + name
- + " variability = " + v);
- }
- perfDataItem++;
- } else {
- // bad data types.
- throw new MonitorTypeException(
- "Invalid Monitor type:" + " entry index = "
- + perfDataItem + " name = " + name
- + " type = " + dataType);
- }
- }
-
- // setup index to next entry for next iteration of the loop.
- nextEntry = entryStart + entryLength;
- return monitor;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBufferPrologue.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.v1_0;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.nio.*;
-
-/**
- * Class representing the 1.0 version of the HotSpot PerfData instrumentation
- * buffer header.
- * <p>
- * The PerfDataBufferPrologue2_0 class supports parsing of the version
- * specific portions of the PerfDataPrologue C structure:
- * <pre>
- * typedef struct {
- * ... // handled by superclass
- * jint used; // number of PerfData memory bytes used
- * jint overflow; // number of bytes of overflow
- * jlong mod_time_stamp; // time stamp of the last structural modification
- * } PerfDataPrologue
- * </pre>
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfDataBufferPrologue extends AbstractPerfDataBufferPrologue {
-
- private static final int SUPPORTED_MAJOR_VERSION = 1;
- private static final int SUPPORTED_MINOR_VERSION = 0;
-
- /*
- * the following constants must match the field offsets and sizes
- * in the PerfDataPrologue structure in perfMemory.hpp
- */
- final static int PERFDATA_PROLOG_USED_OFFSET=8;
- final static int PERFDATA_PROLOG_USED_SIZE=4; // sizeof(int)
- final static int PERFDATA_PROLOG_OVERFLOW_OFFSET=12;
- final static int PERFDATA_PROLOG_OVERFLOW_SIZE=4; // sizeof(int)
- final static int PERFDATA_PROLOG_MODTIMESTAMP_OFFSET=16;
- final static int PERFDATA_PROLOG_MODTIMESTAMP_SIZE=8; // sizeof(long)
- final static int PERFDATA_PROLOG_SIZE=24; // sizeof(struct PerfDataProlog)
-
- // counter names for prologue psuedo counters
- final static String PERFDATA_BUFFER_SIZE_NAME = "sun.perfdata.size";
- final static String PERFDATA_BUFFER_USED_NAME = "sun.perfdata.used";
- final static String PERFDATA_OVERFLOW_NAME = "sun.perfdata.overflow";
- final static String PERFDATA_MODTIMESTAMP_NAME = "sun.perfdata.timestamp";
-
- /**
- * Create an instance of PerfDataBufferPrologue from the given
- * ByteBuffer object.
- *
- * @param byteBuffer the buffer containing the binary header data
- */
- public PerfDataBufferPrologue(ByteBuffer byteBuffer)
- throws MonitorException {
- super(byteBuffer);
- assert ((getMajorVersion() == 1) && (getMinorVersion() == 0));
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean supportsAccessible() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isAccessible() {
- return true;
- }
-
- /**
- * Get the utilization of the instrumentation memory buffer.
- *
- * @return int - the utilization of the buffer
- */
- public int getUsed() {
- byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
- return byteBuffer.getInt();
- }
-
- /**
- * Get the size of the instrumentation memory buffer.
- *
- * @return int - the size of the buffer
- */
- public int getBufferSize() {
- return byteBuffer.capacity();
- }
-
- /**
- * Get the buffer overflow amount. This value is non-zero if the
- * HotSpot JVM has overflowed the instrumentation memory buffer.
- * The target JVM can be restarted with -XX:PerfDataMemSize=X to
- * create a larger memory buffer.
- *
- * @return int - the size of the buffer
- */
- public int getOverflow() {
- byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
- return byteBuffer.getInt();
- }
-
- /**
- * Get the time of last modification for the instrumentation
- * memory buffer. This method returns the time, as ticks since the
- * start of the target JVM, of the last structural modification to
- * the instrumentation buffer. Structural modifications correspond to
- * the addition or deletion of instrumentation objects. Updates to
- * counter values are not structural modifications.
- */
- public long getModificationTimeStamp() {
- byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
- return byteBuffer.getLong();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getSize() {
- return PERFDATA_PROLOG_SIZE; // sizeof(struct PerfDataProlog)
- }
-
- /**
- * Return an IntBuffer that accesses the used value. This is used
- * to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the used value
- * in the instrumentation buffer header.
- * @see #getUsed()
- */
- public IntBuffer usedBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
- IntBuffer ib = byteBuffer.asIntBuffer();
- ib.limit(1);
- return ib;
- }
-
- /**
- * Return an IntBuffer that accesses the size value. This is used
- * to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the size value
- * in the instrumentation buffer header.
- * @see #getBufferSize()
- */
- public IntBuffer sizeBuffer() {
- IntBuffer ib = IntBuffer.allocate(1);
- ib.put(byteBuffer.capacity());
- return ib;
- }
-
- /**
- * Return an IntBuffer that accesses the overflow value. This is used
- * to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the overflow value
- * in the instrumentation buffer header.
- * @see #getOverflow()
- */
- public IntBuffer overflowBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
- IntBuffer ib = byteBuffer.asIntBuffer();
- ib.limit(1);
- return ib;
- }
-
- /**
- * Return an LongBuffer that accesses the modification timestamp value.
- * This is used* to create a Monitor object for this value.
- *
- * @return LongBuffer - a ByteBuffer that accesses the modification time
- * stamp value in the instrumentation buffer header.
- * @see #getModificationTimeStamp()
- */
- public LongBuffer modificationTimeStampBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
- LongBuffer lb = byteBuffer.asLongBuffer();
- lb.limit(1);
- return lb;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,506 +0,0 @@
-/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.v2_0;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.util.*;
-import java.util.regex.*;
-import java.nio.*;
-
-/**
- * The concrete implementation of version 2.0 of the HotSpot PerfData
- * Instrumentation buffer. This class is responsible for parsing the
- * instrumentation memory and constructing the necessary objects to
- * represent and access the instrumentation objects contained in the
- * memory buffer.
- * <p>
- * The structure of the 2.0 entry is defined in struct PerfDataEnry
- * as decsribed in perfMemory.hpp. This structure looks like:
- * <pre>
- * typedef struct {
- * jint entry_length; // entry length in bytes
- * jint name_offset; // offset to entry name, relative to start
- * // of entry
- * jint vector_length; // length of the vector. If 0, then scalar.
- * jbyte data_type; // JNI field descriptor type
- * jbyte flags; // miscellaneous attribute flags
- * // 0x01 - supported
- * jbyte data_units; // unit of measure attribute
- * jbyte data_variability; // variability attribute
- * jbyte data_offset; // offset to data item, relative to start
- * // of entry.
- * } PerfDataEntry;
- * </pre>
- *
- * @author Brian Doherty
- * @since 1.5
- * @see AbstractPerfDataBuffer
- */
-public class PerfDataBuffer extends PerfDataBufferImpl {
-
- // 8028357 removed old, inefficient debug logging
-
- private static final int syncWaitMs =
- Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
- private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<>(0);
-
- /*
- * These are primarily for documentary purposes and the match up
- * with the PerfDataEntry structure in perfMemory.hpp. They are
- * generally unused in this code, but they are kept consistent with
- * the data structure just in case some unforseen need arrises.
- */
- private final static int PERFDATA_ENTRYLENGTH_OFFSET=0;
- private final static int PERFDATA_ENTRYLENGTH_SIZE=4; // sizeof(int)
- private final static int PERFDATA_NAMEOFFSET_OFFSET=4;
- private final static int PERFDATA_NAMEOFFSET_SIZE=4; // sizeof(int)
- private final static int PERFDATA_VECTORLENGTH_OFFSET=8;
- private final static int PERFDATA_VECTORLENGTH_SIZE=4; // sizeof(int)
- private final static int PERFDATA_DATATYPE_OFFSET=12;
- private final static int PERFDATA_DATATYPE_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_FLAGS_OFFSET=13;
- private final static int PERFDATA_FLAGS_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_DATAUNITS_OFFSET=14;
- private final static int PERFDATA_DATAUNITS_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_DATAVAR_OFFSET=15;
- private final static int PERFDATA_DATAVAR_SIZE=1; // sizeof(byte)
- private final static int PERFDATA_DATAOFFSET_OFFSET=16;
- private final static int PERFDATA_DATAOFFSET_SIZE=4; // sizeof(int)
-
- PerfDataBufferPrologue prologue;
- int nextEntry;
- long lastNumEntries;
- IntegerMonitor overflow;
- ArrayList<Monitor> insertedMonitors;
-
- /**
- * Construct a PerfDataBuffer instance.
- * <p>
- * This class is dynamically loaded by
- * {@link AbstractPerfDataBuffer#createPerfDataBuffer}, and this
- * constructor is called to instantiate the instance.
- *
- * @param buffer the buffer containing the instrumentation data
- * @param lvmid the Local Java Virtual Machine Identifier for this
- * instrumentation buffer.
- */
- public PerfDataBuffer(ByteBuffer buffer, int lvmid)
- throws MonitorException {
- super(buffer, lvmid);
- prologue = new PerfDataBufferPrologue(buffer);
- this.buffer.order(prologue.getByteOrder());
- }
-
- /**
- * {@inheritDoc}
- */
- protected void buildMonitorMap(Map<String, Monitor> map) throws MonitorException {
- assert Thread.holdsLock(this);
-
- // start at the beginning of the buffer
- buffer.rewind();
-
- // create pseudo monitors
- buildPseudoMonitors(map);
-
- // wait for the target JVM to indicate that it's intrumentation
- // buffer is safely accessible
- synchWithTarget();
-
- // parse the currently defined entries starting at the first entry.
- nextEntry = prologue.getEntryOffset();
-
- // record the number of entries before parsing the structure
- int numEntries = prologue.getNumEntries();
-
- // start parsing
- Monitor monitor = getNextMonitorEntry();
- while (monitor != null) {
- map.put(monitor.getName(), monitor);
- monitor = getNextMonitorEntry();
- }
-
- /*
- * keep track of the current number of entries in the shared
- * memory for new entry detection purposes. It's possible for
- * the data structure to be modified while the Map is being
- * built and the entry count in the header might change while
- * we are parsing it. The map will contain all the counters
- * found, but the number recorded in numEntries might be small
- * than what than the number we actually parsed (due to asynchronous
- * updates). This discrepency is handled by ignoring any re-parsed
- * entries when updating the Map in getNewMonitors().
- */
- lastNumEntries = numEntries;
-
- // keep track of the monitors just added.
- insertedMonitors = new ArrayList<Monitor>(map.values());
- }
-
- /**
- * {@inheritDoc}
- */
- protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
- assert Thread.holdsLock(this);
-
- int numEntries = prologue.getNumEntries();
-
- if (numEntries > lastNumEntries) {
- lastNumEntries = numEntries;
- Monitor monitor = getNextMonitorEntry();
-
- while (monitor != null) {
- String name = monitor.getName();
-
- // guard against re-parsed entries
- if (!map.containsKey(name)) {
- map.put(name, monitor);
- if (insertedMonitors != null) {
- insertedMonitors.add(monitor);
- }
- }
- monitor = getNextMonitorEntry();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected MonitorStatus getMonitorStatus(Map<String, Monitor> map) throws MonitorException {
- assert Thread.holdsLock(this);
- assert insertedMonitors != null;
-
- // load any new monitors
- getNewMonitors(map);
-
- // current implementation doesn't support deletion of reuse of entries
- ArrayList<Monitor> removed = EMPTY_LIST;
- ArrayList<Monitor> inserted = insertedMonitors;
-
- insertedMonitors = new ArrayList<>();
- return new MonitorStatus(inserted, removed);
- }
-
- /**
- * Build the pseudo monitors used to map the prolog data into counters.
- */
- protected void buildPseudoMonitors(Map<String, Monitor> map) {
- Monitor monitor = null;
- String name = null;
- IntBuffer ib = null;
-
- name = PerfDataBufferPrologue.PERFDATA_MAJOR_NAME;
- ib = prologue.majorVersionBuffer();
- monitor = new PerfIntegerMonitor(name, Units.NONE,
- Variability.CONSTANT, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_MINOR_NAME;
- ib = prologue.minorVersionBuffer();
- monitor = new PerfIntegerMonitor(name, Units.NONE,
- Variability.CONSTANT, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_BUFFER_SIZE_NAME;
- ib = prologue.sizeBuffer();
- monitor = new PerfIntegerMonitor(name, Units.BYTES,
- Variability.MONOTONIC, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_BUFFER_USED_NAME;
- ib = prologue.usedBuffer();
- monitor = new PerfIntegerMonitor(name, Units.BYTES,
- Variability.MONOTONIC, false, ib);
- map.put(name, monitor);
-
- name = PerfDataBufferPrologue.PERFDATA_OVERFLOW_NAME;
- ib = prologue.overflowBuffer();
- monitor = new PerfIntegerMonitor(name, Units.BYTES,
- Variability.MONOTONIC, false, ib);
- map.put(name, monitor);
- this.overflow = (IntegerMonitor)monitor;
-
- name = PerfDataBufferPrologue.PERFDATA_MODTIMESTAMP_NAME;
- LongBuffer lb = prologue.modificationTimeStampBuffer();
- monitor = new PerfLongMonitor(name, Units.TICKS,
- Variability.MONOTONIC, false, lb);
- map.put(name, monitor);
- }
-
- /**
- * Method that waits until the target jvm indicates that
- * its shared memory is safe to access.
- */
- protected void synchWithTarget() throws MonitorException {
- /*
- * synch must happen with syncWaitMs from now. Default is 5 seconds,
- * which is reasonabally generous and should provide for extreme
- * situations like startup delays due to allocation of large ISM heaps.
- */
- long timeLimit = System.currentTimeMillis() + syncWaitMs;
-
- // loop waiting for the accessible indicater to be non-zero
- while (!prologue.isAccessible()) {
-
- // give the target jvm a chance to complete initializatoin
- try { Thread.sleep(20); } catch (InterruptedException e) { }
-
- if (System.currentTimeMillis() > timeLimit) {
- throw new MonitorException("Could not synchronize with target");
- }
- }
- }
-
- /**
- * method to extract the next monitor entry from the instrumentation memory.
- * assumes that nextEntry is the offset into the byte array
- * at which to start the search for the next entry. method leaves
- * next entry pointing to the next entry or to the end of data.
- */
- protected Monitor getNextMonitorEntry() throws MonitorException {
- Monitor monitor = null;
-
- // entries are always 4 byte aligned.
- if ((nextEntry % 4) != 0) {
- throw new MonitorStructureException(
- "Misaligned entry index: "
- + Integer.toHexString(nextEntry));
- }
-
- // protect againt a corrupted shard memory region.
- if ((nextEntry < 0) || (nextEntry > buffer.limit())) {
- throw new MonitorStructureException(
- "Entry index out of bounds: "
- + Integer.toHexString(nextEntry)
- + ", limit = " + Integer.toHexString(buffer.limit()));
- }
-
- // check for end of the buffer
- if (nextEntry == buffer.limit()) {
- return null;
- }
-
- buffer.position(nextEntry);
-
- int entryStart = buffer.position();
- int entryLength = buffer.getInt();
-
- // check for valid entry length
- if ((entryLength < 0) || (entryLength > buffer.limit())) {
- throw new MonitorStructureException(
- "Invalid entry length: entryLength = " + entryLength
- + " (0x" + Integer.toHexString(entryLength) + ")");
- }
-
- // check if last entry occurs before the eof.
- if ((entryStart + entryLength) > buffer.limit()) {
- throw new MonitorStructureException(
- "Entry extends beyond end of buffer: "
- + " entryStart = 0x" + Integer.toHexString(entryStart)
- + " entryLength = 0x" + Integer.toHexString(entryLength)
- + " buffer limit = 0x" + Integer.toHexString(buffer.limit()));
- }
-
- if (entryLength == 0) {
- // end of data
- return null;
- }
-
- // we can safely read this entry
- int nameOffset = buffer.getInt();
- int vectorLength = buffer.getInt();
- byte typeCodeByte = buffer.get();
- byte flags = buffer.get();
- byte unitsByte = buffer.get();
- byte varByte = buffer.get();
- int dataOffset = buffer.getInt();
-
- // convert common attributes to their object types
- Units units = Units.toUnits(unitsByte);
- Variability variability = Variability.toVariability(varByte);
- TypeCode typeCode = null;
- boolean supported = (flags & 0x01) != 0;
-
- try {
- typeCode = TypeCode.toTypeCode(typeCodeByte);
-
- } catch (IllegalArgumentException e) {
- throw new MonitorStructureException(
- "Illegal type code encountered:"
- + " entry_offset = 0x" + Integer.toHexString(nextEntry)
- + ", type_code = " + Integer.toHexString(typeCodeByte));
- }
-
- // verify that the name_offset is contained within the entry bounds
- if (nameOffset > entryLength) {
- throw new MonitorStructureException(
- "Field extends beyond entry bounds"
- + " entry_offset = 0x" + Integer.toHexString(nextEntry)
- + ", name_offset = 0x" + Integer.toHexString(nameOffset));
- }
-
- // verify that the data_offset is contained within the entry bounds
- if (dataOffset > entryLength) {
- throw new MonitorStructureException(
- "Field extends beyond entry bounds:"
- + " entry_offset = 0x" + Integer.toHexString(nextEntry)
- + ", data_offset = 0x" + Integer.toHexString(dataOffset));
- }
-
- // validate the variability and units fields
- if (variability == Variability.INVALID) {
- throw new MonitorDataException(
- "Invalid variability attribute:"
- + " entry_offset = 0x" + Integer.toHexString(nextEntry)
- + ", variability = 0x" + Integer.toHexString(varByte));
- }
-
- if (units == Units.INVALID) {
- throw new MonitorDataException(
- "Invalid units attribute: entry_offset = 0x"
- + Integer.toHexString(nextEntry)
- + ", units = 0x" + Integer.toHexString(unitsByte));
- }
-
- // the entry looks good - parse the variable length components
-
- /*
- * The name starts at nameOffset and continues up to the first null
- * byte. however, we don't know the length, but we can approximate it
- * without searching for the null by using the offset for the data
- * field, which follows the name field.
- */
- assert (buffer.position() == (entryStart + nameOffset));
- assert (dataOffset > nameOffset);
-
- // include possible pad space
- int maxNameLength = dataOffset-nameOffset;
-
- // maxNameLength better be less than the total entry length
- assert (maxNameLength < entryLength);
-
- // collect the characters, but do not collect the null byte,
- // as the String(byte[]) constructor does not ignore it!
- byte[] nameBytes = new byte[maxNameLength];
- int nameLength = 0;
- byte b;
- while (((b = buffer.get()) != 0) && (nameLength < maxNameLength)) {
- nameBytes[nameLength++] = b;
- }
-
- assert (nameLength < maxNameLength);
-
- // we should before or at the start of the data field
- assert (buffer.position() <= (entryStart + dataOffset));
-
- // convert the name bytes into a String
- String name = new String(nameBytes, 0, nameLength);
-
- /*
- * compute the size of the data item - this includes pad
- * characters used to align the next entry.
- */
- int dataSize = entryLength - dataOffset;
-
- // set the position to the start of the data item
- buffer.position(entryStart + dataOffset);
-
- if (vectorLength == 0) {
- // create a scalar Monitor object
- if (typeCode == TypeCode.LONG) {
- LongBuffer lb = buffer.asLongBuffer();
- lb.limit(1); // limit buffer size to one long value.
- monitor = new PerfLongMonitor(name, units, variability,
- supported, lb);
- } else {
- /*
- * unexpected type code - coding error or uncoordinated
- * JVM change
- */
- throw new MonitorTypeException(
- "Unexpected type code encountered:"
- + " entry_offset = 0x" + Integer.toHexString(nextEntry)
- + ", name = " + name
- + ", type_code = " + typeCode
- + " (0x" + Integer.toHexString(typeCodeByte) + ")");
- }
- } else {
- // create a vector Monitor object
- if (typeCode == TypeCode.BYTE) {
- if (units != Units.STRING) {
- // only byte arrays of type STRING are currently supported
- throw new MonitorTypeException(
- "Unexpected vector type encounterd:"
- + " entry_offset = "
- + Integer.toHexString(nextEntry)
- + ", name = " + name
- + ", type_code = " + typeCode + " (0x"
- + Integer.toHexString(typeCodeByte) + ")"
- + ", units = " + units + " (0x"
- + Integer.toHexString(unitsByte) + ")");
- }
-
- ByteBuffer bb = buffer.slice();
- bb.limit(vectorLength); // limit buffer length to # of chars
-
- if (variability == Variability.CONSTANT) {
- monitor = new PerfStringConstantMonitor(name, supported,
- bb);
- } else if (variability == Variability.VARIABLE) {
- monitor = new PerfStringVariableMonitor(name, supported,
- bb, vectorLength-1);
- } else if (variability == Variability.MONOTONIC) {
- // Monotonically increasing byte arrays are not supported
- throw new MonitorDataException(
- "Unexpected variability attribute:"
- + " entry_offset = 0x"
- + Integer.toHexString(nextEntry)
- + " name = " + name
- + ", variability = " + variability + " (0x"
- + Integer.toHexString(varByte) + ")");
- } else {
- // variability was validated above, so this unexpected
- assert false;
- }
- } else {
- // coding error or uncoordinated JVM change
- throw new MonitorTypeException(
- "Unexpected type code encountered:"
- + " entry_offset = 0x"
- + Integer.toHexString(nextEntry)
- + ", name = " + name
- + ", type_code = " + typeCode + " (0x"
- + Integer.toHexString(typeCodeByte) + ")");
- }
- }
-
- // setup index to next entry for next iteration of the loop.
- nextEntry = entryStart + entryLength;
- return monitor;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBufferPrologue.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.v2_0;
-
-import sun.jvmstat.monitor.*;
-import sun.jvmstat.perfdata.monitor.*;
-import java.nio.*;
-
-/**
- * Class representing the 2.0 version of the HotSpot PerfData instrumentation
- * buffer header.
- * <p>
- * The PerfDataBufferPrologue class supports parsing of the version
- * specific portions of the PerfDataPrologue C structure:
- * <pre>
- * typedef struct {
- * ... // handled by superclass
- * jint used; // number of PerfData memory bytes used
- * jint overflow; // number of bytes of overflow
- * jlong mod_time_stamp; // time stamp of the last structural modification
- * jint entry_offset; // offset of the first PerfDataEntry
- * jint num_entries; // number of allocated PerfData entries
- * } PerfDataPrologue
- * </pre>
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class PerfDataBufferPrologue extends AbstractPerfDataBufferPrologue {
-
- private final static int SUPPORTED_MAJOR_VERSION = 2;
- private final static int SUPPORTED_MINOR_VERSION = 0;
-
- /*
- * the following constants must match the field offsets and sizes
- * in the PerfDataPrologue structure in perfMemory.hpp. offsets are
- * relative to the start of the PerfDataPrologue structure.
- *
- * note that PERFDATA_PROLOG_ACCESSIBLE_OFFSET redefines
- * PERFDATA_PROLOG_RESERVEDB1_OFFSET from AbstractPerfDataBufferPrologue.
- */
- final static int PERFDATA_PROLOG_ACCESSIBLE_OFFSET=7;
- final static int PERFDATA_PROLOG_ACCESSIBLE_SIZE=1; // sizeof(byte)
- final static int PERFDATA_PROLOG_USED_OFFSET=8;
- final static int PERFDATA_PROLOG_USED_SIZE=4; // sizeof(int)
- final static int PERFDATA_PROLOG_OVERFLOW_OFFSET=12;
- final static int PERFDATA_PROLOG_OVERFLOW_SIZE=4; // sizeof(int)
- final static int PERFDATA_PROLOG_MODTIMESTAMP_OFFSET=16;
- final static int PERFDATA_PROLOG_MODTIMESTAMP_SIZE=8; // sizeof(long)
- final static int PERFDATA_PROLOG_ENTRYOFFSET_OFFSET=24;
- final static int PERFDATA_PROLOG_ENTRYOFFSET_SIZE=4; // sizeof(int)
- final static int PERFDATA_PROLOG_NUMENTRIES_OFFSET=28;
- final static int PERFDATA_PROLOG_NUMENTRIES_SIZE=4; // sizeof(int)
-
- final static int PERFDATA_PROLOG_SIZE=32; // sizeof(struct PerfDataProlog)
-
- // names for counters that expose prologue fields
- final static String PERFDATA_BUFFER_SIZE_NAME = "sun.perfdata.size";
- final static String PERFDATA_BUFFER_USED_NAME = "sun.perfdata.used";
- final static String PERFDATA_OVERFLOW_NAME = "sun.perfdata.overflow";
- final static String PERFDATA_MODTIMESTAMP_NAME = "sun.perfdata.timestamp";
- final static String PERFDATA_NUMENTRIES_NAME = "sun.perfdata.entries";
-
- /**
- * Create an instance of PerfDataBufferPrologue from the given
- * ByteBuffer object.
- *
- * @param byteBuffer the buffer containing the binary header data
- */
- public PerfDataBufferPrologue(ByteBuffer byteBuffer)
- throws MonitorException {
- super(byteBuffer);
- assert ((getMajorVersion() == 2) && (getMinorVersion() == 0));
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean supportsAccessible() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isAccessible() {
- assert supportsAccessible();
- byteBuffer.position(PERFDATA_PROLOG_ACCESSIBLE_OFFSET);
- byte value = byteBuffer.get();
- return value != 0;
- }
-
- /**
- * Get the utilization of the instrumentation memory buffer.
- *
- * @return int - the utilization of the buffer
- */
- public int getUsed() {
- byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
- return byteBuffer.getInt();
- }
-
- /**
- * Get the size of the instrumentation memory buffer.
- *
- * @return int - the size of the buffer
- */
- public int getBufferSize() {
- return byteBuffer.capacity();
- }
-
- /**
- * Get the buffer overflow amount. This value is non-zero if the
- * HotSpot JVM has overflowed the instrumentation memory buffer.
- * The target JVM can be restarted with -XX:PerfDataMemSize=X to
- * create a larger memory buffer.
- *
- * @return int - the size of the buffer
- */
- public int getOverflow() {
- byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
- return byteBuffer.getInt();
- }
-
- /**
- * Get the time of last modification for the instrumentation
- * memory buffer. This method returns the time, as ticks since the
- * start of the target JVM, of the last structural modification to
- * the instrumentation buffer. Structural modifications correspond to
- * the addition or deletion of instrumentation objects. Updates to
- * counter values are not structural modifications.
- */
- public long getModificationTimeStamp() {
- byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
- return byteBuffer.getLong();
- }
-
- /**
- * Get the offset of the first PerfDataEntry.
- */
- public int getEntryOffset() {
- byteBuffer.position(PERFDATA_PROLOG_ENTRYOFFSET_OFFSET);
- return byteBuffer.getInt();
- }
-
- /**
- * Get the offset of the first PerfDataEntry.
- */
- public int getNumEntries() {
- byteBuffer.position(PERFDATA_PROLOG_NUMENTRIES_OFFSET);
- return byteBuffer.getInt();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getSize() {
- return PERFDATA_PROLOG_SIZE; // sizeof(struct PerfDataProlog)
- }
-
- /**
- * Return an IntBuffer that accesses the used value. This is used
- * to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the used value
- * in the instrumentation buffer header.
- * @see #getUsed()
- */
- IntBuffer usedBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_USED_OFFSET);
- IntBuffer ib = byteBuffer.asIntBuffer();
- ib.limit(1);
- return ib;
- }
-
- /**
- * Return an IntBuffer that accesses the size value. This is used
- * to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the size value
- * in the instrumentation buffer header.
- * @see #getBufferSize()
- */
- IntBuffer sizeBuffer() {
- IntBuffer ib = IntBuffer.allocate(1);
- ib.put(byteBuffer.capacity());
- return ib;
- }
-
- /**
- * Return an IntBuffer that accesses the overflow value. This is used
- * to create a Monitor object for this value.
- *
- * @return IntBuffer - a ByteBuffer that accesses the overflow value
- * in the instrumentation buffer header.
- * @see #getOverflow()
- */
- IntBuffer overflowBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_OVERFLOW_OFFSET);
- IntBuffer ib = byteBuffer.asIntBuffer();
- ib.limit(1);
- return ib;
- }
-
- /**
- * Return a LongBuffer that accesses the modification timestamp value.
- * This is used to create a Monitor object for this value.
- *
- * @return LongBuffer - a ByteBuffer that accesses the modification time
- * stamp value in the instrumentation buffer header.
- * @see #getModificationTimeStamp()
- */
- LongBuffer modificationTimeStampBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_MODTIMESTAMP_OFFSET);
- LongBuffer lb = byteBuffer.asLongBuffer();
- lb.limit(1);
- return lb;
- }
-
- /**
- * Return an IntBuffer that accesses the number of entries value.
- * This is used to create a Monitor object for this value.
- *
- * @return LongBuffer - a ByteBuffer that accesses the num_entries
- * value in the instrumentation buffer header.
- * @see #getNumEntries()
- */
- IntBuffer numEntriesBuffer() {
- byteBuffer.position(PERFDATA_PROLOG_NUMENTRIES_OFFSET);
- IntBuffer ib = byteBuffer.asIntBuffer();
- ib.limit(1);
- return ib;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/TypeCode.java Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.jvmstat.perfdata.monitor.v2_0;
-
-/**
- * A typesafe enumeration for describing standard Java type codes.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public class TypeCode {
-
- private final String name;
- private final char value;
-
- public static final TypeCode BOOLEAN = new TypeCode("boolean", 'Z');
- public static final TypeCode CHAR = new TypeCode("char", 'C');
- public static final TypeCode FLOAT = new TypeCode("float", 'F');
- public static final TypeCode DOUBLE = new TypeCode("double", 'D');
- public static final TypeCode BYTE = new TypeCode("byte", 'B');
- public static final TypeCode SHORT = new TypeCode("short", 'S');
- public static final TypeCode INT = new TypeCode("int", 'I');
- public static final TypeCode LONG = new TypeCode("long", 'J');
- public static final TypeCode OBJECT = new TypeCode("object", 'L');
- public static final TypeCode ARRAY = new TypeCode("array", '[');
- public static final TypeCode VOID = new TypeCode("void", 'V');
-
- private static TypeCode basicTypes[] = {
- LONG, BYTE, BOOLEAN, CHAR, FLOAT, DOUBLE,
- SHORT, INT, OBJECT, ARRAY, VOID
- };
-
- /**
- * Convert enumeration value to a String.
- *
- * @return String - the string representation for the enumeration.
- */
- public String toString() {
- return name;
- }
-
- /**
- * Convert enumeration to its character representation.
- *
- * @return int - the integer representation for the enumeration.
- */
- public int toChar() {
- return value;
- }
-
- /**
- * Map a character value to its corresponding TypeCode object.
- *
- * @param c an character representing a Java TypeCode
- * @return TypeCode - The TypeCode enumeration object for the given
- * character.
- * @throws IllegalArgumentException Thrown if <code>c</code> is not
- * a valid Java TypeCode.
- */
- public static TypeCode toTypeCode(char c) {
- for (int j = 0; j < basicTypes.length; j++) {
- if (basicTypes[j].value == c) {
- return (basicTypes[j]);
- }
- }
- throw new IllegalArgumentException();
- }
-
- /**
- * Map a character value to its corresponding TypeCode object.
- *
- * @param b a byte representing a Java TypeCode. This value is
- * converted into a char and used to find the corresponding
- * TypeCode.
- * @return TypeCode - The TypeCode enumeration object for the given byte.
- * @throws IllegalArgumentException Thrown if <code>v</code> is not
- * a valid Java TypeCode.
- */
- public static TypeCode toTypeCode(byte b) {
- return toTypeCode((char)b);
- }
-
- private TypeCode(String name, char value) {
- this.name = name;
- this.value = value;
- }
-}
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/resources/aliasmap Mon Jan 30 09:09:34 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,593 +0,0 @@
-/*
-*
-* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
-* particular file as subject to the "Classpath" exception as provided
-* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-* or visit www.oracle.com if you need additional information or have any
-* questions.
-*/
-
-/*
- * This file provides the mappings for renamed counters. The key for the
- * mapping is the counter name of the counter in the latest release, and
- * follows the reserved word 'alias'. Following the key counter name is
- * a white space separated list of counter names from previous releases.
- * The convention is to order these alias names from newest to oldest
- * releases, but this is only a convention.
- *
- * The counter name aliasing mechanism does not provide for aliases that
- * are dynamcially generated based on some JVM configuration parameters.
- * For such cases, the largest possible set of counter names must be
- * explicitly enumerated in this file. It does not provide for aliases
- * that have dependencies on the values of other counters, resulting in
- * one-to-many mappings.
- */
-
-/***************************** java.* counters *****************************/
-// java.ci
-alias java.ci.totalTime // 1.5.0 b39
- hotspot.ci.total.time // 1.4.1
-
-// java.cls
-alias java.cls.loadedClasses // 1.5.0 b39
- hotspot.rt.cl.classes.loaded // 1.4.1
-alias java.cls.unloadedClasses // 1.5.0 b39
- hotspot.rt.cl.classes.unloaded // 1.4.1
-
-// java.property
-alias java.property.java.class.path // 1.5.0 b39
- java.class.path // 1.4.1
-alias java.property.java.endorsed.dirs // 1.5.0 b39
- java.endorsed.dirs // 1.4.1
-alias java.property.java.ext.dirs // 1.5.0 b39
- java.ext.dirs // 1.4.1
-alias java.property.java.home // 1.5.0 b39
- java.home // 1.4.1
-alias java.property.java.library.path // 1.5.0 b39
- java.library.path // 1.4.1
-alias java.property.java.vm.info // 1.5.0 b39
- java.vm.info // 1.4.1
-alias java.property.java.vm.name // 1.5.0 b39
- java.vm.name // 1.4.1
-alias java.property.java.vm.specification.name // 1.5.0 b39
- java.vm.specification.name // 1.4.1
-alias java.property.java.vm.specification.vendor // 1.5.0 b39
- java.vm.specification.vendor // 1.4.1
-alias java.property.java.vm.specification.version // 1.5.0 b39
- java.vm.specification.version // 1.4.1
-alias java.property.java.vm.vendor // 1.5.0 b39
- java.vm.vendor // 1.4.1
-alias java.property.java.vm.version // 1.5.0 b39
- java.vm.version // 1.4.1
-
-// java.rt
-alias java.rt.vmArgs // 1.5.0 b39
- hotspot.vm.args // 1.4.1
-alias java.rt.vmFlags // 1.5.0 b39
- hotspot.vm.flags // 1.4.1
-
-// java.threads
-alias java.threads.daemon // 1.5.0 b39
- hotspot.threads.daemon.count // 1.4.1
-alias java.threads.live // 1.5.0 b39
- hotspot.threads.live.count // 1.4.1
-alias java.threads.livePeak // 1.5.0 b39
- hotspot.threads.live.peak // 1.4.1
-alias java.threads.started // 1.5.0 b39
- hotspot.threads.total.created // 1.4.1
-
-/***************************** com.sun.* counters **************************/
-
-/***************************** sun.* counters ******************************/
-// sun.ci
-alias sun.ci.adapterThread.compiles // 1.5.0 b39
- hotspot.ci.AdapterThread.compiles // 1.4.2
-alias sun.ci.adapterThread.method // 1.5.0 b39
- hotspot.ci.AdapterThread.method // 1.4.2
-alias sun.ci.adapterThread.time // 1.5.0 b39
- hotspot.ci.AdapterThread.time // 1.4.2
-alias sun.ci.adapterThread.type // 1.5.0 b39
- hotspot.ci.AdapterThread.type // 1.4.2
-alias sun.ci.compilerThread.0.compiles // 1.5.0 b39
- hotspot.ci.CompilerThread0.compiles // 1.4.2
-alias sun.ci.compilerThread.0.method // 1.5.0 b39
- hotspot.ci.CompilerThread0.method // 1.4.2
-alias sun.ci.compilerThread.0.time // 1.5.0 b39
- hotspot.ci.CompilerThread0.time // 1.4.2
-alias sun.ci.compilerThread.0.type // 1.5.0 b39
- hotspot.ci.CompilerThread0.type // 1.4.2
-alias sun.ci.compilerThread.1.compiles // 1.5.0 b39
- hotspot.ci.CompilerThread1.compiles // 1.4.2
-alias sun.ci.compilerThread.1.method // 1.5.0 b39
- hotspot.ci.CompilerThread1.method // 1.4.2
-alias sun.ci.compilerThread.1.time // 1.5.0 b39
- hotspot.ci.CompilerThread1.time // 1.4.2
-alias sun.ci.compilerThread.1.type // 1.5.0 b39
- hotspot.ci.CompilerThread1.type // 1.4.2
-alias sun.ci.compilerThread.2.compiles // 1.5.0 b39
- hotspot.ci.CompilerThread2.compiles // 1.4.2
-alias sun.ci.compilerThread.2.method // 1.5.0 b39
- hotspot.ci.CompilerThread2.method // 1.4.2
-alias sun.ci.compilerThread.2.time // 1.5.0 b39
- hotspot.ci.CompilerThread2.time // 1.4.2
-alias sun.ci.compilerThread.2.type // 1.5.0 b39
- hotspot.ci.CompilerThread2.type // 1.4.2
-alias sun.ci.compilerThread.3.compiles // 1.5.0 b39
- hotspot.ci.CompilerThread3.compiles // 1.4.2
-alias sun.ci.compilerThread.3.method // 1.5.0 b39
- hotspot.ci.CompilerThread3.method // 1.4.2
-alias sun.ci.compilerThread.3.time // 1.5.0 b39
- hotspot.ci.CompilerThread3.time // 1.4.2
-alias sun.ci.compilerThread.3.type // 1.5.0 b39
- hotspot.ci.CompilerThread3.type // 1.4.2
-alias sun.ci.lastFailedMethod // 1.5.0 b39
- hotspot.ci.failed.method // 1.4.2
-alias sun.ci.lastFailedType // 1.5.0 b39
- hotspot.ci.failed.type // 1.4.2
-alias sun.ci.lastInvalidatedMethod // 1.5.0 b39
- hotspot.ci.invalidated.method // 1.4.2
-alias sun.ci.lastInvalidatedType // 1.5.0 b39
- hotspot.ci.invalidated.type // 1.4.2
-alias sun.ci.lastMethod // 1.5.0 b39
- hotspot.ci.last.method // 1.4.2
-alias sun.ci.lastSize // 1.5.0 b39
- hotspot.ci.last.size // 1.4.2
-alias sun.ci.lastType // 1.5.0 b39
- hotspot.ci.last.type // 1.4.2
-alias sun.ci.nativeCompiles // 1.5.0 b39
- hotspot.ci.native.compiles // 1.4.2
-alias sun.ci.nativeTime // 1.5.0 b39
- hotspot.ci.native.time // 1.4.2
-alias sun.ci.nmethodCodeSize // 1.5.0 b39
- hotspot.ci.nmethod.codesize // 1.4.2
-alias sun.ci.nmethodSize // 1.5.0 b39
- hotspot.ci.nmethod.size // 1.4.2
-alias sun.ci.osrBytes // 1.5.0 b39
- hotspot.ci.osr.bytes // 1.4.2
-alias sun.ci.osrCompiles // 1.5.0 b39
- hotspot.ci.osr.compiles // 1.4.2
-alias sun.ci.osrTime // 1.5.0 b39
- hotspot.ci.osr.time // 1.4.2
-alias sun.ci.standardBytes // 1.5.0 b39
- hotspot.ci.standard.bytes // 1.4.2
-alias sun.ci.standardCompiles // 1.5.0 b39
- hotspot.ci.standard.compiles // 1.4.2
-alias sun.ci.standardTime // 1.5.0 b39
- hotspot.ci.standard.time // 1.4.2
-alias sun.ci.threads // 1.5.0 b39
- hotspot.ci.threads // 1.4.2
-alias sun.ci.totalBailouts // 1.5.0 b39
- hotspot.ci.total.bailout // 1.4.2
-alias sun.ci.totalCompiles // 1.5.0 b39
- hotspot.ci.total.compiles // 1.4.2
-alias sun.ci.totalInvalidates // 1.5.0 b39
- hotspot.ci.total.invalid // 1.4.2
-
-// sun.cls
-alias sun.cls.classInitTime // 1.5.0 b39
- hotspot.rt.cl.class.init.time // 1.5.0 b21
-alias sun.cls.classVerifyTime // 1.5.0 b39
- hotspot.rt.cl.class.verify.time // 1.5.0 b21
-alias sun.cls.initializedClasses // 1.5.0 b39
- hotspot.rt.cl.classes.initialized // 1.5.0 b21
-alias sun.cls.loadedBytes // 1.5.0 b39
- hotspot.rt.cl.bytes.loaded // 1.4.2
-alias sun.cls.methodBytes // 1.5.0 b39
- hotspot.rt.cl.methods.size // 1.4.2
-alias sun.cls.time // 1.5.0 b39
- hotspot.rt.cl.time // 1.4.2
-alias sun.cls.unloadedBytes // 1.5.0 b39
- hotspot.rt.cl.bytes.unloaded // 1.4.2
-
-// sun.gc
-alias sun.gc.cause // 1.5.0 b39
- hotspot.gc.cause // 1.4.2_02
-
-// sun.gc.collector.0
-alias sun.gc.collector.0.invocations // 1.5.0 b39
- hotspot.gc.collector.0.invocations // 1.4.2
- hotspot.gc.new.eden.invocations // 1.4.1
-alias sun.gc.collector.0.lastEntryTime // 1.5.0 b39
- hotspot.gc.collector.0.last_entry // 1.4.2
-alias sun.gc.collector.0.lastExitTime // 1.5.0 b39
- hotspot.gc.collector.0.last_exit // 1.4.2
-alias sun.gc.collector.0.name // 1.5.0 b39
- hotspot.gc.collector.0.name // 1.4.2
-alias sun.gc.collector.0.time // 1.5.0 b39
- hotspot.gc.collector.0.time // 1.4.2
- hotspot.gc.new.eden.time // 1.4.1
-
-// sun.gc.collector.1
-alias sun.gc.collector.1.invocations // 1.5.0 b39
- hotspot.gc.collector.1.invocations // 1.4.2
- hotspot.gc.new.eden.invocations // 1.4.1
-alias sun.gc.collector.1.lastEntryTime // 1.5.0 b39
- hotspot.gc.collector.1.last_entry // 1.4.2
-alias sun.gc.collector.1.lastExitTime // 1.5.0 b39
- hotspot.gc.collector.1.last_exit // 1.4.2
-alias sun.gc.collector.1.name // 1.5.0 b39
- hotspot.gc.collector.1.name // 1.4.2
-alias sun.gc.collector.1.time // 1.5.0 b39
- hotspot.gc.collector.1.time // 1.4.2
- hotspot.gc.new.eden.time // 1.4.1
-
-// sun.gc.finalizer
-alias sun.gc.finalizer.queue.length // 1.5.0 b39
- hotspot.gc.finalizer.queue.length // 1.4.2
-alias sun.gc.finalizer.queue.maxLength // 1.5.0 b39
- hotspot.gc.finalizer.queue.maxlength // 1.4.2
-alias sun.gc.finalizer.time // 1.5.0 b39
- hotspot.gc.finalizer.ticks // 1.4.2
-alias sun.gc.finalizer.objects // 1.5.0 b39
- hotspot.gc.finalizer.count // 1.4.2
-
-// sun.gc.generation.0.agetable
-alias sun.gc.generation.0.agetable.bytes.00 // 1.5.0 b39
- hotspot.gc.agetable.bytes.00 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.01 // 1.5.0 b39
- hotspot.gc.agetable.bytes.01 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.02 // 1.5.0 b39
- hotspot.gc.agetable.bytes.02 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.03 // 1.5.0 b39
- hotspot.gc.agetable.bytes.03 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.04 // 1.5.0 b39
- hotspot.gc.agetable.bytes.04 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.05 // 1.5.0 b39
- hotspot.gc.agetable.bytes.05 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.06 // 1.5.0 b39
- hotspot.gc.agetable.bytes.06 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.07 // 1.5.0 b39
- hotspot.gc.agetable.bytes.07 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.08 // 1.5.0 b39
- hotspot.gc.agetable.bytes.08 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.09 // 1.5.0 b39
- hotspot.gc.agetable.bytes.09 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.10 // 1.5.0 b39
- hotspot.gc.agetable.bytes.10 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.11 // 1.5.0 b39
- hotspot.gc.agetable.bytes.11 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.12 // 1.5.0 b39
- hotspot.gc.agetable.bytes.12 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.13 // 1.5.0 b39
- hotspot.gc.agetable.bytes.13 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.14 // 1.5.0 b39
- hotspot.gc.agetable.bytes.14 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.15 // 1.5.0 b39
- hotspot.gc.agetable.bytes.15 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.16 // 1.5.0 b39
- hotspot.gc.agetable.bytes.16 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.17 // 1.5.0 b39
- hotspot.gc.agetable.bytes.17 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.18 // 1.5.0 b39
- hotspot.gc.agetable.bytes.18 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.19 // 1.5.0 b39
- hotspot.gc.agetable.bytes.19 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.20 // 1.5.0 b39
- hotspot.gc.agetable.bytes.20 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.21 // 1.5.0 b39
- hotspot.gc.agetable.bytes.21 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.22 // 1.5.0 b39
- hotspot.gc.agetable.bytes.22 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.23 // 1.5.0 b39
- hotspot.gc.agetable.bytes.23 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.24 // 1.5.0 b39
- hotspot.gc.agetable.bytes.24 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.25 // 1.5.0 b39
- hotspot.gc.agetable.bytes.25 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.26 // 1.5.0 b39
- hotspot.gc.agetable.bytes.26 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.27 // 1.5.0 b39
- hotspot.gc.agetable.bytes.27 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.28 // 1.5.0 b39
- hotspot.gc.agetable.bytes.28 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.29 // 1.5.0 b39
- hotspot.gc.agetable.bytes.29 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.30 // 1.5.0 b39
- hotspot.gc.agetable.bytes.30 // 1.4.1
-alias sun.gc.generation.0.agetable.bytes.31 // 1.5.0 b39
- hotspot.gc.agetable.bytes.31 // 1.4.1
-alias sun.gc.generation.0.agetable.size // 1.5.0 b39
- hotspot.gc.agetable.size // 1.4.1
-
-// sun.gc.generation.0
-alias sun.gc.generation.0.capacity // 1.5.0 b39
- hotspot.gc.generation.0.capacity.current // 1.4.2
-alias sun.gc.generation.0.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.0.capacity.max // 1.4.2
-alias sun.gc.generation.0.minCapacity // 1.5.0 b39
- hotspot.gc.generation.0.capacity.min // 1.4.2
-alias sun.gc.generation.0.name // 1.5.0 b39
- hotspot.gc.generation.0.name // 1.4.2
-alias sun.gc.generation.0.space.0.capacity // 1.5.0 b39
- hotspot.gc.generation.0.space.0.capacity // 1.4.2
- hotspot.gc.new.eden.capacity // 1.4.1
-alias sun.gc.generation.0.space.0.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.0.space.0.size // 1.4.2
- hotspot.gc.new.eden.capacity // 1.4.1
-alias sun.gc.generation.0.space.0.name // 1.5.0 b39
- hotspot.gc.generation.0.space.0.name // 1.4.2
-alias sun.gc.generation.0.space.0.used // 1.5.0 b39
- hotspot.gc.generation.0.space.0.used // 1.4.2
- hotspot.gc.new.eden.used // 1.4.1
-alias sun.gc.generation.0.space.1.capacity // 1.5.0 b39
- hotspot.gc.generation.0.space.1.capacity // 1.4.2
- hotspot.gc.new.s0.capacity // 1.4.1
-alias sun.gc.generation.0.space.1.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.0.space.1.size // 1.4.2
- hotspot.gc.new.s0.capacity // 1.4.1
-alias sun.gc.generation.0.space.1.name // 1.5.0 b39
- hotspot.gc.generation.0.space.1.name // 1.4.2
-alias sun.gc.generation.0.space.1.used // 1.5.0 b39
- hotspot.gc.generation.0.space.1.used // 1.4.2
- hotspot.gc.new.s0.used // 1.4.1
-alias sun.gc.generation.0.space.2.capacity // 1.5.0 b39
- hotspot.gc.generation.0.space.2.capacity // 1.4.2
- hotspot.gc.new.s1.capacity // 1.4.1
-alias sun.gc.generation.0.space.2.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.0.space.2.size // 1.4.2
- hotspot.gc.new.s1.capacity // 1.4.1
-alias sun.gc.generation.0.space.2.name // 1.5.0 b39
- hotspot.gc.generation.0.space.2.name // 1.4.2
-alias sun.gc.generation.0.space.2.used // 1.5.0 b39
- hotspot.gc.generation.0.space.2.used // 1.4.2
- hotspot.gc.new.s1.used // 1.4.1
-alias sun.gc.generation.0.spaces // 1.5.0 b39
- hotspot.gc.generation.0.spaces // 1.4.2
-alias sun.gc.generation.0.threads // 1.5.0 b39
- hotspot.gc.generation.0.threads // 1.4.2
-
-// sun.gc.generation.1
-alias sun.gc.generation.1.capacity // 1.5.0 b39
- hotspot.gc.generation.1.capacity.current // 1.4.2
-alias sun.gc.generation.1.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.1.capacity.max // 1.4.2
-alias sun.gc.generation.1.minCapacity // 1.5.0 b39
- hotspot.gc.generation.1.capacity.min // 1.4.2
-alias sun.gc.generation.1.name // 1.5.0 b39
- hotspot.gc.generation.1.name // 1.4.2
-alias sun.gc.generation.1.space.0.capacity // 1.5.0 b39
- hotspot.gc.generation.1.space.0.capacity // 1.4.2
- hotspot.gc.tenured.capacity // 1.4.1
-alias sun.gc.generation.1.space.0.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.1.space.0.size // 1.4.2
- hotspot.gc.tenured.capacity // 1.4.1
-alias sun.gc.generation.1.space.0.name // 1.5.0 b39
- hotspot.gc.generation.1.space.0.name // 1.4.2
-alias sun.gc.generation.1.space.0.used // 1.5.0 b39
- hotspot.gc.generation.1.space.0.used // 1.4.2
- hotspot.gc.tenured.used // 1.4.1
-alias sun.gc.generation.1.spaces // 1.5.0 b39
- hotspot.gc.generation.1.spaces // 1.4.2
-
-// sun.gc.generation.2
-alias sun.gc.generation.2.capacity // 1.5.0 b39
- hotspot.gc.generation.2.capacity.current // 1.4.2
-alias sun.gc.generation.2.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.2.capacity.max // 1.4.2
-alias sun.gc.generation.2.minCapacity // 1.5.0 b39
- hotspot.gc.generation.2.capacity.min // 1.4.2
-alias sun.gc.generation.2.name // 1.5.0 b39
- hotspot.gc.generation.2.name // 1.4.2
-alias sun.gc.generation.2.space.0.capacity // 1.5.0 b39
- hotspot.gc.generation.2.space.0.capacity // 1.4.2
- hotspot.gc.perm.capacity // 1.4.1
-alias sun.gc.generation.2.space.0.maxCapacity // 1.5.0 b39
- hotspot.gc.generation.2.space.0.size // 1.4.2
- hotspot.gc.perm.capacity // 1.4.1
-alias sun.gc.generation.2.space.0.name // 1.5.0 b39
- hotspot.gc.generation.2.space.0.name // 1.4.2
-alias sun.gc.generation.2.space.0.used // 1.5.0 b39
- hotspot.gc.generation.2.space.0.used // 1.4.2
- hotspot.gc.perm.used // 1.4.1
-alias sun.gc.generation.2.spaces // 1.5.0 b39
- hotspot.gc.generation.2.spaces // 1.4.2
-
-// sun.gc
-alias sun.gc.lastCause // 1.5.0 b39
- hotspot.gc.last_cause // 1.4.2_02
-
-// sun.gc.policy
-alias sun.gc.policy.avgBaseFootprint // 1.5.0 b39
- hotspot.gc.policy.avg_base_footprint // 1.5.0 b21
-alias sun.gc.policy.avgMajorIntervalTime // 1.5.0 b39
- hotspot.gc.policy.avg_major_interval // 1.5.0 b21
-alias sun.gc.policy.avgMajorPauseTime // 1.5.0 b39
- hotspot.gc.policy.avg_major_pause // 1.5.0 b21
-alias sun.gc.policy.avgMinorIntervalTime // 1.5.0 b39
- hotspot.gc.policy.avg_minor_interval // 1.5.0 b21
-alias sun.gc.policy.avgMinorPauseTime // 1.5.0 b39
- hotspot.gc.policy.avg_minor_pause // 1.5.0 b21
-alias sun.gc.policy.avgOldLive // 1.5.0 b39
- hotspot.gc.policy.avg_old_live // 1.5.0 b21
-alias sun.gc.policy.avgPretenuredPaddedAvg // 1.5.0 b39
- hotspot.gc.policy.avg_pretenured_padded_avg // 1.5.0 b21
-alias sun.gc.policy.avgPromotedAvg // 1.5.0 b39
- hotspot.gc.policy.avg_promoted_avg // 1.5.0 b21
-alias sun.gc.policy.avgPromotedDev // 1.5.0 b39
- hotspot.gc.policy.avg_promoted_dev // 1.5.0 b21
-alias sun.gc.policy.avgPromotedPaddedAvg // 1.5.0 b39
- hotspot.gc.policy.avg_promoted_padded_avg // 1.5.0 b21
-alias sun.gc.policy.avgSurvivedAvg // 1.5.0 b39
- hotspot.gc.policy.avg_survived_avg // 1.5.0 b21
-alias sun.gc.policy.avgSurvivedDev // 1.5.0 b39
- hotspot.gc.policy.avg_survived_dev // 1.5.0 b21
-alias sun.gc.policy.avgSurvivedPaddedAvg // 1.5.0 b39
- hotspot.gc.policy.avg_survived_padded_avg // 1.5.0 b21
-alias sun.gc.policy.avgYoungLive // 1.5.0 b39
- hotspot.gc.policy.avg_young_live // 1.5.0 b21
-alias sun.gc.policy.boundaryMoved // 1.5.0 b39
- hotspot.gc.policy.boundary_moved // 1.5.0 b21
-alias sun.gc.policy.changeOldGenForMajPauses // 1.5.0 b39
- hotspot.gc.policy.change_old_gen_for_maj_pauses // 1.5.0 b21
-alias sun.gc.policy.changeOldGenForMinPauses // 1.5.0 b39
- hotspot.gc.policy.change_old_gen_for_min_pauses // 1.5.0 b21
-alias sun.gc.policy.changeYoungGenForMajPauses // 1.5.0 b39
- hotspot.gc.policy.change_young_gen_for_maj_pauses // 1.5.0 b21
-alias sun.gc.policy.changeYoungGenForMinPauses // 1.5.0 b39
- hotspot.gc.policy.change_young_gen_for_min_pauses // 1.5.0 b21
-alias sun.gc.policy.collectors // 1.5.0 b39
- hotspot.gc.policy.collectors // 1.4.2
-alias sun.gc.policy.decideAtFullGc // 1.5.0 b39
- hotspot.gc.policy.decide_at_full_gc // 1.5.0 b21
-alias sun.gc.policy.decreaseForFootprint // 1.5.0 b39
- hotspot.gc.policy.decrease_for_footprint // 1.5.0 b21
-alias sun.gc.policy.decrementTenuringThresholdForGcCost // 1.5.0 b39
- hotspot.gc.policy.decrement_tenuring_threshold_for_gc_cost // 1.5.0 b21
-alias sun.gc.policy.decrementTenuringThresholdForSurvivorLimit // 1.5.0 b39
- hotspot.gc.policy.decrement_tenuring_threshold_for_survivor_limit // 1.5.0 b21
-alias sun.gc.policy.desiredSurvivorSize // 1.5.0 b39
- hotspot.gc.policy.desired_survivor_size // 1.5.0 b21
- hotspot.gc.agetable.dss // 1.4.1
-alias sun.gc.policy.edenSize // 1.5.0 b39
- hotspot.gc.policy.eden_size // 1.5.0 b21
-alias sun.gc.policy.freeSpace // 1.5.0 b39
- hotspot.gc.policy.free_space // 1.5.0 b21
-alias sun.gc.policy.fullFollowsScavenge // 1.5.0 b39
- hotspot.gc.policy.full_follows_scavenge // 1.5.0 b21
-alias sun.gc.policy.gcTimeLimitExceeded // 1.5.0 b39
- hotspot.gc.policy.gc_time_limit_exceeded // 1.5.0 b21
-alias sun.gc.policy.generations // 1.5.0 b39
- hotspot.gc.policy.generations // 1.4.2
-alias sun.gc.policy.increaseOldGenForThroughput // 1.5.0 b39
- hotspot.gc.policy.increase_old_gen_for_throughput // 1.5.0 b21
-alias sun.gc.policy.increaseYoungGenForThroughput // 1.5.0 b39
- hotspot.gc.policy.increase_young_gen_for_throughput // 1.5.0 b21
-alias sun.gc.policy.incrementTenuringThresholdForGcCost // 1.5.0 b39
- hotspot.gc.policy.increment_tenuring_threshold_for_gc_cost // 1.5.0 b21
-alias sun.gc.policy.liveAtLastFullGc // 1.5.0 b39
- hotspot.gc.policy.live_at_last_full_gc // 1.5.0 b21
-alias sun.gc.policy.liveSpace // 1.5.0 b39
- hotspot.gc.policy.live_space // 1.5.0 b21
-alias sun.gc.policy.majorCollectionSlope // 1.5.0 b39
- hotspot.gc.policy.major_collection_slope // 1.5.0 b21
-alias sun.gc.policy.majorGcCost // 1.5.0 b39
- hotspot.gc.policy.major_gc_cost // 1.5.0 b21
-alias sun.gc.policy.majorPauseOldSlope // 1.5.0 b39
- hotspot.gc.policy.major_pause_old_slope // 1.5.0 b21
-alias sun.gc.policy.majorPauseYoungSlope // 1.5.0 b39
- hotspot.gc.policy.major_pause_young_slope // 1.5.0 b21
-alias sun.gc.policy.maxTenuringThreshold // 1.5.0 b39
- hotspot.gc.max_tenuring_threshold // 1.5.0 b21
- hotspot.gc.agetable.mtt // 1.4.1
-alias sun.gc.policy.minorCollectionSlope // 1.5.0 b39
- hotspot.gc.policy.minor_collection_slope // 1.5.0 b21
-alias sun.gc.policy.minorGcCost // 1.5.0 b39
- hotspot.gc.policy.minor_gc_cost // 1.5.0 b21
-alias sun.gc.policy.minorPauseOldSlope // 1.5.0 b39
- hotspot.gc.policy.minor_pause_old_slope // 1.5.0 b21
-alias sun.gc.policy.minorPauseYoungSlope // 1.5.0 b39
- hotspot.gc.policy.minor_pause_young_slope // 1.5.0 b21
-alias sun.gc.policy.mutatorCost // 1.5.0 b39
- hotspot.gc.policy.mutator_cost // 1.5.0 b21
-alias sun.gc.policy.name // 1.5.0 b39
- hotspot.gc.policy.name // 1.5.0 b21
-alias sun.gc.policy.oldCapacity // 1.5.0 b39
- hotspot.gc.policy.old_capacity // 1.5.0 b21
-alias sun.gc.policy.oldEdenSize // 1.5.0 b39
- hotspot.gc.policy.old_eden_size // 1.5.0 b21
-alias sun.gc.policy.oldPromoSize // 1.5.0 b39
- hotspot.gc.policy.old_promo_size // 1.5.0 b21
-alias sun.gc.policy.promoSize // 1.5.0 b39
- hotspot.gc.policy.promo_size // 1.5.0 b21
-alias sun.gc.policy.promoted // 1.5.0 b39
- hotspot.gc.policy.promoted // 1.5.0 b21
-alias sun.gc.policy.scavengeSkipped // 1.5.0 b39
- hotspot.gc.policy.scavenge_skipped // 1.5.0 b21
-alias sun.gc.policy.survived // 1.5.0 b39
- hotspot.gc.policy.survived // 1.5.0 b21
-alias sun.gc.policy.survivorOverflowed // 1.5.0 b39
- hotspot.gc.policy.survivor_overflowed // 1.5.0 b21
-alias sun.gc.policy.tenuringThreshold // 1.5.0 b39
- hotspot.gc.policy.tenuring_threshold // 1.5.0 b21
- hotspot.gc.agetable.tt // 1.4.1
-alias sun.gc.policy.youngCapacity // 1.5.0 b39
- hotspot.gc.policy.young_capacity // 1.5.0 b21
-
-// sun.gc.tlab
-alias sun.gc.tlab.alloc // 1.5.0 b39
- hotspot.gc.tlab.alloc // 1.5.0 b21
-alias sun.gc.tlab.allocThreads // 1.5.0 b39
- hotspot.gc.tlab.alloc_thrds // 1.5.0 b21
-alias sun.gc.tlab.fastWaste // 1.5.0 b39
- hotspot.gc.tlab.fastwaste // 1.5.0 b21
-alias sun.gc.tlab.fills // 1.5.0 b39
- hotspot.gc.tlab.fills // 1.5.0 b21
-alias sun.gc.tlab.gcWaste // 1.5.0 b39
- hotspot.gc.tlab.gcwaste // 1.5.0 b21
-alias sun.gc.tlab.maxFastWaste // 1.5.0 b39
- hotspot.gc.tlab.maxfastwaste // 1.5.0 b21
-alias sun.gc.tlab.maxFills // 1.5.0 b39
- hotspot.gc.tlab.maxfills // 1.5.0 b21
-alias sun.gc.tlab.maxGcWaste // 1.5.0 b39
- hotspot.gc.tlab.maxgcwaste // 1.5.0 b21
-alias sun.gc.tlab.maxSlowAlloc // 1.5.0 b39
- hotspot.gc.tlab.maxslowalloc // 1.5.0 b21
-alias sun.gc.tlab.maxSlowWaste // 1.5.0 b39
- hotspot.gc.tlab.maxslowwaste // 1.5.0 b21
-alias sun.gc.tlab.slowAlloc // 1.5.0 b39
- hotspot.gc.tlab.slowalloc // 1.5.0 b21
-alias sun.gc.tlab.slowWaste // 1.5.0 b39
- hotspot.gc.tlab.slowwaste // 1.5.0 b21
-
-// sun.os
-alias sun.os.hrt.frequency // 1.5.0 b39
- hotspot.rt.hrt.frequency // 1.4.1
-alias sun.os.hrt.ticks // 1.5.0 b39
- hotspot.rt.hrt.ticks // 1.4.1
-
-// sun.perfdata
-alias sun.perfdata.overflow // 1.5.0 b39
- hotspot.perfdata.overflow // 1.4.1
-alias sun.perfdata.size // 1.5.0 b39
- hotspot.perfdata.size // 1.4.1
-alias sun.perfdata.timestamp // 1.5.0 b39
- hotspot.perfdata.timestamp // 1.4.1
-alias sun.perfdata.used // 1.5.0 b39
- hotspot.perfdata.used // 1.4.1
-alias sun.perfdata.majorVersion // 1.5.0 b39
- hotspot.perfdata.version.major // 1.4.1
-alias sun.perfdata.minorVersion // 1.5.0 b39
- hotspot.perfdata.version.minor // 1.4.1
-
-// sun.property
-alias sun.property.sun.boot.class.path // 1.5.0 b39
- sun.boot.class.path // 1.4.1
-alias sun.property.sun.boot.library.path // 1.5.0 b39
- sun.boot.library.path // 1.4.1
-
-// sun.rt
-alias sun.rt.applicationTime // 1.5.0 b39
- hotspot.rt.application.time // 1.5.0 b21
-alias sun.rt.createVmBeginTime // 1.5.0 b39
- hotspot.rt.vm.create.begin // 1.5.0 b21
-alias sun.rt.createVmEndTime // 1.5.0 b39
- hotspot.rt.vm.create.end // 1.5.0 b21
-alias sun.rt.internalVersion // 1.5.0 b39
- hotspot.internal.version // 1.5.0 b21
-alias sun.rt.javaCommand // 1.5.0 b39
- sun.java.command // 1.4.1
-alias sun.rt.safepointSyncTime // 1.5.0 b39
- hotspot.rt.safepoint.sync.time // 1.5.0 b21
-alias sun.rt.safepointTime // 1.5.0 b39
- hotspot.rt.safepoint.time // 1.5.0 b21
-alias sun.rt.safepoints // 1.5.0 b39
- hotspot.rt.safepoint.count // 1.5.0 b21
-alias sun.rt.vmInitDoneTime // 1.5.0 b39
- hotspot.rt.vm.init.done // 1.5.0 b21
--- a/jdk/test/ProblemList.txt Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/ProblemList.txt Tue Jan 31 20:54:44 2017 +0100
@@ -148,8 +148,6 @@
com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all
-com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java 8169575 generic-all
-
############################################################################
# jdk_jmx
--- a/jdk/test/com/sun/jdi/ShellScaffold.sh Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/com/sun/jdi/ShellScaffold.sh Tue Jan 31 20:54:44 2017 +0100
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2017, Oracle and/or its affiliates. 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
@@ -276,10 +276,10 @@
# treat them as control chars on mks (eg \t is tab)
# Oops; windows mks really seems to want this cat line
# to start in column 1
- if [ -w "$SystemRoot" ] ; then
- tmpFile=$SystemRoot/tmp.$$
- elif [ -w "$SYSTEMROOT" ] ; then
- tmpFile=$SYSTEMROOT/tmp.$$
+ if [ -w "$Temp" ] ; then
+ tmpFile=$Temp/tmp.$$
+ elif [ -w "$TEMP" ] ; then
+ tmpFile=$TEMP/tmp.$$
else
tmpFile=tmp.$$
fi
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java Tue Jan 31 20:54:44 2017 +0100
@@ -141,16 +141,6 @@
doneIterations++;
return true;
}
-
- void checkPassed() {
- if (!passed) {
- throw new Error(String.format("%d of %d test cases FAILED! %n"
- + "Rerun the test with the same \"-Dseed=\" option as in the log file!",
- failCounter, testCounter));
- } else {
- System.err.printf("All %d test cases PASSED!%n", testCounter);
- }
- }
}
/**
@@ -195,6 +185,12 @@
System.err.println("FAILED");
throw new Error("Unexpected error!", ex);
}
- run.checkPassed();
+ if (!run.passed) {
+ throw new Error(String.format("%d of %d test cases FAILED! %n"
+ + "Rerun the test with the same \"-Dseed=\" option as in the log file!",
+ run.failCounter, run.testCounter));
+ } else {
+ System.err.printf("All %d test cases PASSED!%n", run.testCounter);
+ }
}
}
--- a/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java Tue Jan 31 20:54:44 2017 +0100
@@ -72,7 +72,6 @@
if (t != null) {
System.err.printf("%nNon-critical exception caught becuse of"
+ " code cache size is not enough to run all test cases.%n%n");
- t.printStackTrace();
}
return t;
}
--- a/jdk/test/sun/jvmstat/monitor/HostIdentifier/HostIdentifierCreate.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/sun/jvmstat/monitor/HostIdentifier/HostIdentifierCreate.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. 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
@@ -24,7 +24,7 @@
/*
* @test
* @bug 4990825
- * @modules jdk.jvmstat/sun.jvmstat.monitor
+ * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
* @summary test that HostIdentifier objects get created as expected
*/
--- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. 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
@@ -68,8 +68,8 @@
* @summary attach to external but local JVM processes
* @library /lib/testlibrary
* @modules java.management
- * jdk.jvmstat/sun.jvmstat.monitor
- * jdk.jvmstat/sun.jvmstat.monitor.event
+ * jdk.internal.jvmstat/sun.jvmstat.monitor
+ * jdk.internal.jvmstat/sun.jvmstat.monitor.event
* @build jdk.testlibrary.*
* @run main/othervm MonitorVmStartTerminate
*/
--- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. 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
@@ -40,7 +40,7 @@
* @test
* @bug 6672135
* @summary setInterval() for local MonitoredHost and local MonitoredVm
- * @modules jdk.jvmstat/sun.jvmstat.monitor
+ * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
* @library /lib/testlibrary
* @library /test/lib
* @build jdk.testlibrary.*
--- a/jdk/test/sun/jvmstat/monitor/VmIdentifier/VmIdentifierCreateResolve.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/sun/jvmstat/monitor/VmIdentifier/VmIdentifierCreateResolve.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. 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
@@ -24,7 +24,7 @@
/*
* @test
* @bug 4990825
- * @modules jdk.jvmstat/sun.jvmstat.monitor
+ * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
* @summary test that VmIdentifier objects get created as expected
*/
--- a/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. 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
@@ -24,7 +24,7 @@
/*
* @test
* @bug 4990825
- * @modules jdk.jvmstat/sun.jvmstat.monitor
+ * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
* @run main/othervm -XX:+UsePerfData PrologSizeSanityCheck
* @summary prolog size and overflow sanity checks
*/
--- a/jdk/test/sun/management/jdp/DynamicLauncher.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/sun/management/jdp/DynamicLauncher.java Tue Jan 31 20:54:44 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. 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
@@ -38,19 +38,19 @@
public abstract class DynamicLauncher {
final String jdpName = UUID.randomUUID().toString();
+ OutputAnalyzer output;
int jmxPort;
protected void run() throws Exception {
- OutputAnalyzer out;
int retries = 1;
boolean tryAgain;
do {
tryAgain = false;
jmxPort = Utils.getFreePort();
- out = runVM();
+ output = runVM();
try {
- out.shouldNotContain("Port already in use");
+ output.shouldNotContain("Port already in use");
} catch (RuntimeException e) {
if (retries < 3) {
retries++;
@@ -71,4 +71,7 @@
protected abstract String[] options();
+ protected OutputAnalyzer getProcessOutpoutAnalyzer() {
+ return output;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. 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.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test JdpJmxRemoteDynamicPortTest.java
+ * @bug 8167337
+ * @summary Verify a non-zero value is assigned to jmxremote.port
+ * when VM is started with jmxremote.port=0.
+ * @library /lib/testlibrary
+ * @modules java.management/sun.management.jdp
+ * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpJmxRemoteDynamicPortTestCase DynamicLauncher
+ * @run main JdpJmxRemoteDynamicPortTest
+ */
+
+import java.lang.management.ManagementFactory;
+
+public class JdpJmxRemoteDynamicPortTest extends DynamicLauncher {
+ final String testName = "JdpJmxRemoteDynamicPortTestCase";
+
+ public static void main(String[] args) throws Exception {
+ DynamicLauncher launcher = new JdpJmxRemoteDynamicPortTest();
+ launcher.run();
+ launcher.getProcessOutpoutAnalyzer().stderrShouldNotContain("java.lang.Exception:");
+ }
+
+ protected String[] options() {
+ String[] options = {
+ "-Dcom.sun.management.jmxremote.authenticate=false",
+ "-Dcom.sun.management.jmxremote.ssl=false",
+ "-Dcom.sun.management.jmxremote=true",
+ "-Dcom.sun.management.jmxremote.port=0",
+ "-Dcom.sun.management.jmxremote.autodiscovery=true",
+ "-Dcom.sun.management.jdp.pause=1",
+ "-Dcom.sun.management.jdp.name=" + jdpName,
+ "-Djava.util.logging.SimpleFormatter.format='%1$tF %1$tT %4$-7s %5$s %n'",
+ testName
+ };
+ return options;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jdp/JdpJmxRemoteDynamicPortTestCase.java Tue Jan 31 20:54:44 2017 +0100
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. 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.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.net.SocketTimeoutException;
+import java.util.Map;
+
+public class JdpJmxRemoteDynamicPortTestCase extends JdpTestCase {
+
+ private int receivedJDPpackets = 0;
+
+ public JdpJmxRemoteDynamicPortTestCase(ClientConnection connection) {
+ super(connection);
+ }
+
+ @Override
+ protected String initialLogMessage() {
+ return "Starting test case JdpJmxRemoteDynamicPortTestCase";
+ }
+
+ /**
+ * This method is executed after a correct Jdp packet (coming from this VM) has been received.
+ *
+ * @param payload A dictionary containing the Jdp packet data.
+ */
+ protected void packetFromThisVMReceived(Map<String, String> payload) throws Exception {
+ receivedJDPpackets++;
+ final String jmxServiceurl = payload.get("JMX_SERVICE_URL");
+ int lastcolon = jmxServiceurl.lastIndexOf(':');
+ int nextslash = jmxServiceurl.indexOf('/', lastcolon);
+ int jmxRemotePort = Integer.parseInt(jmxServiceurl, lastcolon + 1, nextslash, 10);
+
+ log.fine("Received #" + String.valueOf(receivedJDPpackets) +
+ ", jmxStringUrl=" + jmxServiceurl + ", jmxRemotePort=" + jmxRemotePort);
+
+ if (0 == jmxRemotePort) {
+ throw new Exception("JmxRemotePort value is zero. Test case failed.");
+ }
+
+ log.fine("Test case passed");
+ }
+
+ /**
+ * The socket should not timeout.
+ * It is set to wait for 10 times the defined pause between Jdp packet. See JdpOnTestCase.TIME_OUT_FACTOR.
+ */
+ @Override
+ protected void onSocketTimeOut(SocketTimeoutException e) throws Exception {
+ String message = "Timed out waiting for JDP packet. Should arrive within " +
+ connection.pauseInSeconds + " seconds, but waited for " +
+ timeOut + " seconds.";
+ log.severe(message);
+ throw new Exception(message, e);
+ }
+
+
+ /**
+ * After receiving one Jdp packets the test should end.
+ */
+ @Override
+ protected boolean shouldContinue() {
+ return receivedJDPpackets < 1;
+ }
+
+ /**
+ * To run this test manually you might need the following VM options:
+ * <p/>
+ * -Dcom.sun.management.jmxremote.authenticate=false
+ * -Dcom.sun.management.jmxremote.ssl=false
+ * -Dcom.sun.management.jmxremote.port=0
+ * -Dcom.sun.management.jmxremote=true
+ * -Dcom.sun.management.jmxremote.autodiscovery=true
+ * -Dcom.sun.management.jdp.pause=1
+ * -Dcom.sun.management.jdp.name=alex (or some other string to identify this VM)
+ * <p/>
+ * Recommended for nice output:
+ * -Djava.util.logging.SimpleFormatter.format="%1$tF %1$tT %4$-7s %5$s %n"
+ *
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) throws Exception {
+ JdpTestCase client = new JdpJmxRemoteDynamicPortTestCase(new ClientConnection());
+ client.run();
+ }
+
+}
--- a/jdk/test/tools/launcher/VersionCheck.java Mon Jan 30 09:09:34 2017 +0100
+++ b/jdk/test/tools/launcher/VersionCheck.java Tue Jan 31 20:54:44 2017 +0100
@@ -36,6 +36,8 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
public class VersionCheck extends TestHelper {
@@ -146,31 +148,44 @@
}
/*
- * this tests if the tool can take a version string and returns
- * a 0 exit code, it is not possible to validate the contents
- * of the -version output as they are inconsistent.
+ * Checks if the tools accept "-version" option (exit code is zero).
+ * The output of the tools run with "-version" is not verified.
*/
- static boolean testToolVersion() {
- TestHelper.testExitValue = 0;
+ static String testToolVersion() {
+ System.out.println("=== testToolVersion === ");
+ Set<String> failed = new HashSet<>();
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_VERSION))) {
String x = f.getAbsolutePath();
- System.out.println("Testing (-version): " + x);
TestResult tr = doExec(x, "-version");
- tr.checkPositive();
+ System.out.println("Testing " + f.getName());
+ System.out.println("#> " + x + " -version");
+ tr.testOutput.forEach(System.out::println);
+ System.out.println("#> echo $?");
+ System.out.println(tr.exitValue);
+ if (!tr.isOK()) {
+ System.out.println("failed");
+ failed.add(f.getName());
+ }
}
- return TestHelper.testExitValue == 0;
+ if (failed.isEmpty()) {
+ System.out.println("testToolVersion passed");
+ return "";
+ } else {
+ System.out.println("testToolVersion failed");
+ return "testToolVersion: " + failed + "; ";
+ }
+
}
- static boolean compareJVersionStrings() {
- int failcount = 0;
+ static String testJVersionStrings() {
+ System.out.println("=== testJVersionStrings === ");
+ Set<String> failed = new HashSet<>();
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_JOPTION))) {
+ System.out.println("Testing " + f.getName());
String x = f.getAbsolutePath();
- System.out.println("Testing (-J-version): " + x);
- String testStr;
-
- testStr = getVersion(x, "-J-version");
+ String testStr = getVersion(x, "-J-version");
if (refVersion.compareTo(testStr) != 0) {
- failcount++;
+ failed.add(f.getName());
System.out.println("Error: " + x +
" fails -J-version comparison");
System.out.println("Expected:");
@@ -181,7 +196,7 @@
testStr = getVersion(x, "-J-fullversion");
if (refFullVersion.compareTo(testStr) != 0) {
- failcount++;
+ failed.add(f.getName());
System.out.println("Error: " + x +
" fails -J-fullversion comparison");
System.out.println("Expected:");
@@ -190,12 +205,17 @@
System.out.print(testStr);
}
}
- System.out.println("Version Test: " + failcount);
- return failcount == 0;
+ if (failed.isEmpty()) {
+ System.out.println("testJVersionStrings passed");
+ return "";
+ } else {
+ System.out.println("testJVersionStrings failed");
+ return "testJVersionStrings: " + failed + "; ";
+ }
}
- static boolean compareInternalStrings() {
- int failcount = 0;
+ static String testInternalStrings() {
+ System.out.println("=== testInternalStrings === ");
String bStr = refVersion.substring(refVersion.indexOf("build") +
"build".length() + 1,
refVersion.lastIndexOf(")"));
@@ -206,20 +226,21 @@
envMap.put(TestHelper.JLDEBUG_KEY, "true");
TestHelper.TestResult tr = doExec(envMap, javaCmd, "-version");
List<String> alist = new ArrayList<>();
- alist.addAll(tr.testOutput);
- for (String x : tr.testOutput) {
- alist.add(x.trim());
- }
+ tr.testOutput.stream().map(String::trim).forEach(alist::add);
- if (!alist.contains(expectedFullVersion)) {
+ if (alist.contains(expectedFullVersion)) {
+ System.out.println("testInternalStrings passed");
+ return "";
+ } else {
System.out.println("Error: could not find " + expectedFullVersion);
- failcount++;
+ tr.testOutput.forEach(System.out::println);
+ System.out.println("testInternalStrings failed");
+ return "testInternalStrings; ";
}
- System.out.println("Internal Strings Test: " + failcount);
- return failcount == 0;
}
- static boolean testDebugVersion() {
+ static String testDebugVersion() {
+ System.out.println("=== testInternalStrings === ");
String jdkType = System.getProperty("jdk.debug", "release");
String versionLines = getAllVersionLines(javaCmd, "-version");
if ("release".equals(jdkType)) {
@@ -227,18 +248,23 @@
} else {
jdkType = jdkType + " ";
}
+
String tofind = "(" + jdkType + "build";
+
int idx = versionLines.indexOf(tofind);
if (idx < 0) {
+ System.out.println("versionLines " + versionLines);
System.out.println("Did not find first instance of " + tofind);
- return false;
+ return "testDebugVersion; ";
}
idx = versionLines.indexOf(tofind, idx + 1);
if (idx < 0) {
- System.out.println("Did not find first instance of " + tofind);
- return false;
+ System.out.println("versionLines " + versionLines);
+ System.out.println("Did not find second instance of " + tofind);
+ return "testDebugVersion; ";
}
- return true;
+ System.out.println("testDebugVersion passed");
+ return "";
}
// Initialize
@@ -249,13 +275,15 @@
public static void main(String[] args) {
init();
- if (compareJVersionStrings() &&
- compareInternalStrings() &&
- testToolVersion() &&
- testDebugVersion()) {
+ String errorMessage = "";
+ errorMessage += testJVersionStrings();
+ errorMessage += testInternalStrings();
+ errorMessage += testToolVersion();
+ errorMessage += testDebugVersion();
+ if (errorMessage.isEmpty()) {
System.out.println("All Version string comparisons: PASS");
} else {
- throw new AssertionError("Some tests failed");
+ throw new AssertionError("VersionCheck failed: " + errorMessage);
}
}