--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java Mon Mar 24 06:33:16 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java Thu Mar 27 10:42:36 2008 -0700
@@ -1118,11 +1118,11 @@
final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class;
Class targetClass = getTargetClass();
- Constructor[] constrs = targetClass.getConstructors();
+ Constructor<?>[] constrs = targetClass.getConstructors();
// Applicable if and only if there are any annotated constructors
- List<Constructor> annotatedConstrList = newList();
- for (Constructor constr : constrs) {
+ List<Constructor<?>> annotatedConstrList = newList();
+ for (Constructor<?> constr : constrs) {
if (Modifier.isPublic(constr.getModifiers())
&& constr.getAnnotation(propertyNamesClass) != null)
annotatedConstrList.add(constr);
@@ -1152,7 +1152,7 @@
// Also remember the set of properties in that constructor
// so we can test unambiguity.
Set<BitSet> getterIndexSets = newSet();
- for (Constructor constr : annotatedConstrList) {
+ for (Constructor<?> constr : annotatedConstrList) {
String[] propertyNames =
constr.getAnnotation(propertyNamesClass).value();
@@ -1309,10 +1309,10 @@
}
private static class Constr {
- final Constructor constructor;
+ final Constructor<?> constructor;
final int[] paramIndexes;
final BitSet presentParams;
- Constr(Constructor constructor, int[] paramIndexes,
+ Constr(Constructor<?> constructor, int[] paramIndexes,
BitSet presentParams) {
this.constructor = constructor;
this.paramIndexes = paramIndexes;
--- a/jdk/src/share/classes/com/sun/management/package.html Mon Mar 24 06:33:16 2008 -0700
+++ b/jdk/src/share/classes/com/sun/management/package.html Thu Mar 27 10:42:36 2008 -0700
@@ -1,4 +1,4 @@
-CTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
--- a/jdk/src/share/classes/java/beans/MetaData.java Mon Mar 24 06:33:16 2008 -0700
+++ b/jdk/src/share/classes/java/beans/MetaData.java Thu Mar 27 10:42:36 2008 -0700
@@ -1553,7 +1553,7 @@
private static String[] getConstructorProperties(Class type) {
String[] names = null;
int length = 0;
- for (Constructor constructor : type.getConstructors()) {
+ for (Constructor<?> constructor : type.getConstructors()) {
String[] value = getAnnotationValue(constructor);
if ((value != null) && (length < value.length) && isValid(constructor, value)) {
names = value;
@@ -1563,14 +1563,14 @@
return names;
}
- private static String[] getAnnotationValue(Constructor constructor) {
+ private static String[] getAnnotationValue(Constructor<?> constructor) {
ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class);
return (annotation != null)
? annotation.value()
: null;
}
- private static boolean isValid(Constructor constructor, String[] names) {
+ private static boolean isValid(Constructor<?> constructor, String[] names) {
Class[] parameters = constructor.getParameterTypes();
if (names.length != parameters.length) {
return false;
--- a/jdk/src/share/classes/javax/management/MBeanServer.java Mon Mar 24 06:33:16 2008 -0700
+++ b/jdk/src/share/classes/javax/management/MBeanServer.java Thu Mar 27 10:42:36 2008 -0700
@@ -50,7 +50,7 @@
* server. A Java object cannot be registered in the MBean server
* unless it is a JMX compliant MBean.</p>
*
- * <p>When an MBean is registered or unregistered in the MBean server
+ * <p id="notif">When an MBean is registered or unregistered in the MBean server
* a {@link javax.management.MBeanServerNotification
* MBeanServerNotification} Notification is emitted. To register an
* object as listener to MBeanServerNotifications you should call the
@@ -258,27 +258,43 @@
*/
public interface MBeanServer extends MBeanServerConnection {
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name)
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName)
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name,
Object params[], String signature[])
throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException,
NotCompliantMBeanException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ * <p>If this method successfully creates an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, Object params[],
String signature[])
@@ -287,12 +303,15 @@
NotCompliantMBeanException, InstanceNotFoundException;
/**
- * Registers a pre-existing object as an MBean with the MBean
+ * <p>Registers a pre-existing object as an MBean with the MBean
* server. If the object name given is null, the MBean must
* provide its own name by implementing the {@link
* javax.management.MBeanRegistration MBeanRegistration} interface
* and returning the name from the {@link
- * MBeanRegistration#preRegister preRegister} method.
+ * MBeanRegistration#preRegister preRegister} method.</p>
+ *
+ * <p>If this method successfully registers an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
*
* @param object The MBean to be registered as an MBean.
* @param name The object name of the MBean. May be null.
@@ -319,7 +338,12 @@
throws InstanceAlreadyExistsException, MBeanRegistrationException,
NotCompliantMBeanException;
- // doc comment inherited from MBeanServerConnection
+ /**
+ * {@inheritDoc}
+ *
+ * <p>If this method successfully unregisters an MBean, a notification
+ * is sent as described <a href="#notif">above</a>.</p>
+ */
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException;
--- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Mon Mar 24 06:33:16 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Thu Mar 27 10:42:36 2008 -0700
@@ -48,6 +48,7 @@
import java.util.Map;
import java.util.Set;
+import java.util.Vector;
import javax.management.Attribute;
import javax.management.AttributeChangeNotification;
import javax.management.AttributeChangeNotificationFilter;
@@ -132,8 +133,6 @@
* and operations will be executed */
private Object managedResource = null;
- private static final String currClass = "RequiredModelMBean";
-
/* records the registering in MBeanServer */
private boolean registered = false;
private transient MBeanServer server = null;
@@ -2488,10 +2487,13 @@
}
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
+ Vector<String> enabledAttrs = currFilter.getEnabledAttributes();
+ String s = (enabledAttrs.size() > 1) ?
+ "[" + enabledAttrs.firstElement() + ", ...]" :
+ enabledAttrs.toString();
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth,
- "Set attribute change filter to " +
- currFilter.getEnabledAttributes().firstElement());
+ "Set attribute change filter to " + s);
}
attributeBroadcaster.addNotificationListener(inlistener,currFilter,
--- a/jdk/src/share/classes/sun/management/Flag.java Mon Mar 24 06:33:16 2008 -0700
+++ b/jdk/src/share/classes/sun/management/Flag.java Thu Mar 27 10:42:36 2008 -0700
@@ -64,7 +64,8 @@
}
VMOption getVMOption() {
- return new VMOption(name, value.toString(), writeable, origin);
+ String val = value == null ? "" : value.toString();
+ return new VMOption(name, val, writeable, origin);
}
static Flag getFlag(String name) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java Thu Mar 27 10:42:36 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6658779
+ * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticOptions()
+ * @author Daniel Fuchs
+ *
+ * @run main GetDiagnosticOptions
+ */
+
+import com.sun.management.HotSpotDiagnosticMXBean;
+import com.sun.management.VMOption;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import javax.management.MBeanServer;
+
+public class GetDiagnosticOptions {
+ private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
+ "com.sun.management:type=HotSpotDiagnostic";
+
+ public static void main(String[] args) throws Exception {
+ HotSpotDiagnosticMXBean mbean =
+ sun.management.ManagementFactory.getDiagnosticMXBean();
+ checkDiagnosticOptions(mbean);
+
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
+ HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
+ HotSpotDiagnosticMXBean.class);
+ checkDiagnosticOptions(mbean);
+ }
+
+ private static void checkDiagnosticOptions(HotSpotDiagnosticMXBean mbean) {
+ List<VMOption> options = mbean.getDiagnosticOptions();
+ for (VMOption opt : options) {
+ System.out.println("option: "+opt.getName()+"="+opt.getValue());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/modelmbean/LoggingExceptionTest.java Thu Mar 27 10:42:36 2008 -0700
@@ -0,0 +1,81 @@
+/*
+ * @test
+ * @bug 6471865 6675768
+ * @summary DescriptorSupport constructors throw IAE when traces are enabled;
+ * RequiredModelMBean.addAttributeChangeNotificationListener throws exception
+ * when traces enabled and no attributes.
+ * @author Luis-Miguel Alventosa
+ * @author Paul Cheeseman
+ */
+
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.modelmbean.DescriptorSupport;
+import javax.management.modelmbean.RequiredModelMBean;
+
+public class LoggingExceptionTest {
+ private static final String tests[] = new String[] {
+ "DescriptorSupport()",
+ "DescriptorSupport(int)",
+ "DescriptorSupport(String)",
+ "DescriptorSupport(String...)",
+ "DescriptorSupport(String[], Object[])",
+ "DescriptorSupport(DescriptorSupport)",
+ "RequiredModelMBean.addAttributeChangeNotificationListener",
+ };
+ public static void main(String[] args) {
+ Handler handler = new ConsoleHandler();
+ Logger logger = Logger.getLogger("javax.management.modelmbean");
+ logger.addHandler(handler);
+ logger.setLevel(Level.FINEST);
+ try {
+ for (int i = 0; i < tests.length; i++) {
+ System.out.println(">>> DescriptorSupportLoggingTest: Test Case " + i);
+ DescriptorSupport ds;
+ String msg = "Instantiate " + tests[i];
+ System.out.println(msg);
+ switch (i) {
+ case 0:
+ ds = new DescriptorSupport();
+ break;
+ case 1:
+ ds = new DescriptorSupport(10);
+ break;
+ case 2:
+ ds = new DescriptorSupport(new DescriptorSupport().toXMLString());
+ break;
+ case 3:
+ ds = new DescriptorSupport("name1=value1", "name2=value2");
+ break;
+ case 4:
+ ds = new DescriptorSupport(new String[] {"name"}, new Object[] {"value"});
+ break;
+ case 5:
+ ds = new DescriptorSupport(new DescriptorSupport());
+ break;
+ case 6:
+ RequiredModelMBean mbean = new RequiredModelMBean();
+ NotificationListener nl = new NotificationListener() {
+ public void handleNotification(Notification notification,
+ Object handback) {}
+ };
+ mbean.addAttributeChangeNotificationListener(nl, null, null);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ System.out.println(msg + " OK");
+ }
+ } catch (Exception e) {
+ System.out.println("Got unexpected exception = " + e);
+ String msg = "Test FAILED!";
+ System.out.println(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ System.out.println("Test PASSED!");
+ }
+}