From e936f852bfd903a2024343a3d63390d4fa1c44ad Mon Sep 17 00:00:00 2001 From: Bradford Wetmore Date: Tue, 2 Dec 2008 14:53:52 -0800 Subject: [PATCH 1/4] 6778613: Update javax.crypto.Cipher.getMaxAllowedKeyLength to point to proper Appendix after doc reorg Reviewed-by: mullan --- jdk/src/share/classes/javax/crypto/Cipher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/javax/crypto/Cipher.java b/jdk/src/share/classes/javax/crypto/Cipher.java index f99a43cf511..899b3523312 100644 --- a/jdk/src/share/classes/javax/crypto/Cipher.java +++ b/jdk/src/share/classes/javax/crypto/Cipher.java @@ -2377,7 +2377,7 @@ public class Cipher { * For more information on default key size in JCE jurisdiction * policy files, please see Appendix E in the * + * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppC"> * Java Cryptography Architecture Reference Guide. * * @param transformation the cipher transformation. From 3123299828eb739e5a4d87418d1cd81ef780094f Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Thu, 4 Dec 2008 17:58:10 +0100 Subject: [PATCH 2/4] 6319823: new mbean register/unregister notification for groups of mbeans 6779698: Merge error caused duplicate example code in MBeanServerNotification Reviewed-by: emcmanus --- .../management/MBeanServerNotification.java | 68 +++++++++++++++++-- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/javax/management/MBeanServerNotification.java b/jdk/src/share/classes/javax/management/MBeanServerNotification.java index d19c73a555a..e9fe12ad9d6 100644 --- a/jdk/src/share/classes/javax/management/MBeanServerNotification.java +++ b/jdk/src/share/classes/javax/management/MBeanServerNotification.java @@ -57,15 +57,55 @@ package javax.management; * what = "Unknown type " + n.getType(); * System.out.println("Received MBean Server notification: " + what + ": " + * mbsn.getMBeanName()); + * } * }; * * ... * mbeanServer.addNotificationListener( * MBeanServerDelegate.DELEGATE_NAME, printListener, null, null); * - * - *

The following code prints a message every time an MBean is registered - * or unregistered in the MBean Server {@code mbeanServer}:

+ *

+ * An MBean which is not an {@link MBeanServerDelegate} may also emit + * MBeanServerNotifications. In particular, a custom subclass of the + * {@link javax.management.namespace.JMXDomain JMXDomain} MBean or a custom + * subclass of the {@link javax.management.namespace.JMXNamespace JMXNamespace} + * MBean may emit an MBeanServerNotification for a group of MBeans.
+ * An MBeanServerNotification emitted to denote the registration or + * unregistration of a group of MBeans has the following characteristics: + *

+ *

+ *

+ * MBeans which emit these group registration/unregistration notifications will + * declare them in their {@link MBeanInfo#getNotifications() + * MBeanNotificationInfo}. + *

+ *

+ * To receive a group MBeanServerNotification, you need to register a listener + * with the MBean that emits it. For instance, assuming that the {@link + * javax.management.namespace.JMXNamespace JMXNamespace} MBean handling + * namespace {@code "foo"} has declared that it emits such a notification, + * you will need to register your notification listener with that MBean, which + * will be named {@link + * javax.management.namespace.JMXNamespaces#getNamespaceObjectName(java.lang.String) + * foo//:type=JMXNamespace}. + *

+ *

The following code prints a message every time a group of MBean is + * registered or unregistered in the namespace {@code "foo"}, assumimg its + * {@link javax.management.namespace.JMXNamespace handler} supports + * group MBeanServerNotifications:

* *
  * private static final NotificationListener printListener = new NotificationListener() {
@@ -76,19 +116,33 @@ package javax.management;
  *         }
  *         MBeanServerNotification mbsn = (MBeanServerNotification) n;
  *         String what;
- *         if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION))
+ *         ObjectName[] names = null;
+ *         if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
  *             what = "MBean registered";
- *         else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION))
+ *         } else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
  *             what = "MBean unregistered";
- *         else
+ *         } else if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION+".group")) {
+ *             what = "Group of MBeans registered matching";
+ *             if (mbsn.getUserData() instanceof ObjectName[])
+ *                names =  (ObjectName[]) mbsn.getUserData();
+ *         } else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION+".group")) {
+ *             what = "Group of MBeans unregistered matching";
+ *             if (mbsn.getUserData() instanceof ObjectName[])
+ *                names = (ObjectName[]) mbsn.getUserData();
+ *         } else
  *             what = "Unknown type " + n.getType();
  *         System.out.println("Received MBean Server notification: " + what + ": " +
  *                 mbsn.getMBeanName());
+ *         if (names != null) {
+ *              for (ObjectName mb : names)
+ *                  System.out.println("\t"+mb);
+ *         }
+ *     }
  * };
  *
  * ...
  *     mbeanServer.addNotificationListener(
- *             MBeanServerDelegate.DELEGATE_NAME, printListener, null, null);
+ *             JMXNamespaces.getNamespaceObjectName("foo"), printListener, null, null);
  * 
* * @since 1.5 From 745c0e32485e7f71f26a4372e8ca55f3b40789a6 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 5 Dec 2008 10:28:15 -0800 Subject: [PATCH 3/4] 6764062: Revise usage of java.io.*.close Handle closing multiple open I/O streams in case close() throws IOException Reviewed-by: ksrini --- .../classes/com/sun/servicetag/Installer.java | 53 ++++++++++--------- .../com/sun/servicetag/SunConnection.java | 14 +++-- .../classes/com/sun/servicetag/Util.java | 13 +++-- .../servicetag/WindowsSystemEnvironment.java | 16 ++++-- 4 files changed, 58 insertions(+), 38 deletions(-) diff --git a/jdk/src/share/classes/com/sun/servicetag/Installer.java b/jdk/src/share/classes/com/sun/servicetag/Installer.java index 0cda7afe3d6..17555b913e9 100644 --- a/jdk/src/share/classes/com/sun/servicetag/Installer.java +++ b/jdk/src/share/classes/com/sun/servicetag/Installer.java @@ -475,7 +475,7 @@ public class Installer { String filename = "/com/sun/servicetag/resources/javase_" + version + "_swordfish.properties"; - InputStream in = Installer.class.getClass().getResourceAsStream(filename); + InputStream in = Installer.class.getResourceAsStream(filename); if (in == null) { return null; } @@ -813,7 +813,7 @@ public class Installer { locale, String.valueOf(version)).toString(); try { - in = Installer.class.getClass().getResourceAsStream(resource + ".html"); + in = Installer.class.getResourceAsStream(resource + ".html"); if (in == null) { // if the resource file is missing if (isVerbose()) { @@ -825,34 +825,39 @@ public class Installer { System.out.println("Generating " + f + " from " + resource + ".html"); } - br = new BufferedReader(new InputStreamReader(in, "UTF-8")); - pw = new PrintWriter(f, "UTF-8"); - String line = null; - while ((line = br.readLine()) != null) { - String output = line; - if (line.contains(JDK_VERSION_KEY)) { - output = line.replace(JDK_VERSION_KEY, jdkVersion); - } else if (line.contains(JDK_HEADER_PNG_KEY)) { - output = line.replace(JDK_HEADER_PNG_KEY, headerImageSrc); - } else if (line.contains(REGISTRATION_URL_KEY)) { - output = line.replace(REGISTRATION_URL_KEY, registerURL); - } else if (line.contains(REGISTRATION_PAYLOAD_KEY)) { - output = line.replace(REGISTRATION_PAYLOAD_KEY, payload.toString()); + try { + br = new BufferedReader(new InputStreamReader(in, "UTF-8")); + pw = new PrintWriter(f, "UTF-8"); + String line = null; + while ((line = br.readLine()) != null) { + String output = line; + if (line.contains(JDK_VERSION_KEY)) { + output = line.replace(JDK_VERSION_KEY, jdkVersion); + } else if (line.contains(JDK_HEADER_PNG_KEY)) { + output = line.replace(JDK_HEADER_PNG_KEY, headerImageSrc); + } else if (line.contains(REGISTRATION_URL_KEY)) { + output = line.replace(REGISTRATION_URL_KEY, registerURL); + } else if (line.contains(REGISTRATION_PAYLOAD_KEY)) { + output = line.replace(REGISTRATION_PAYLOAD_KEY, payload.toString()); + } + pw.println(output); + } + f.setReadOnly(); + pw.flush(); + } finally { + // It's safe for this finally block to have two close statements + // consecutively as PrintWriter.close doesn't throw IOException. + if (pw != null) { + pw.close(); + } + if (br!= null) { + br.close(); } - pw.println(output); } - f.setReadOnly(); - pw.flush(); } finally { - if (pw != null) { - pw.close(); - } if (in != null) { in.close(); } - if (br!= null) { - br.close(); - } } } } diff --git a/jdk/src/share/classes/com/sun/servicetag/SunConnection.java b/jdk/src/share/classes/com/sun/servicetag/SunConnection.java index 8bcddbe9714..b05657866a5 100644 --- a/jdk/src/share/classes/com/sun/servicetag/SunConnection.java +++ b/jdk/src/share/classes/com/sun/servicetag/SunConnection.java @@ -213,10 +213,16 @@ class SunConnection { con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\""); con.connect(); - OutputStream out = con.getOutputStream(); - registration.storeToXML(out); - out.flush(); - out.close(); + OutputStream out = null; + try { + out = con.getOutputStream(); + registration.storeToXML(out); + out.flush(); + } finally { + if (out != null) { + out.close(); + } + } int returnCode = con.getResponseCode(); if (Util.isVerbose()) { diff --git a/jdk/src/share/classes/com/sun/servicetag/Util.java b/jdk/src/share/classes/com/sun/servicetag/Util.java index 9e32111a2fc..7d58d116e44 100644 --- a/jdk/src/share/classes/com/sun/servicetag/Util.java +++ b/jdk/src/share/classes/com/sun/servicetag/Util.java @@ -140,11 +140,14 @@ class Util { } return e.getMessage(); } finally { - if (r != null) { - r.close(); - } - if (err != null) { - err.close(); + try { + if (r != null) { + r.close(); + } + } finally { + if (err != null) { + err.close(); + } } } } diff --git a/jdk/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java b/jdk/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java index 1fff0ea7df7..aa9b83cdb6c 100644 --- a/jdk/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java +++ b/jdk/src/share/classes/com/sun/servicetag/WindowsSystemEnvironment.java @@ -107,11 +107,17 @@ class WindowsSystemEnvironment extends SystemEnvironment { Process p = pb.start(); // need this for executing windows commands (at least // needed for executing wmic command) - BufferedWriter bw = new BufferedWriter( - new OutputStreamWriter(p.getOutputStream())); - bw.write(13); - bw.flush(); - bw.close(); + BufferedWriter bw = null; + try { + bw = new BufferedWriter( + new OutputStreamWriter(p.getOutputStream())); + bw.write(13); + bw.flush(); + } finally { + if (bw != null) { + bw.close(); + } + } p.waitFor(); if (p.exitValue() == 0) { From ee0229874300d86a03ecfc39da4714b386013455 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 5 Dec 2008 10:30:29 -0800 Subject: [PATCH 4/4] 6750389: The cpuManufactorer does not correctly recognized for Solaris 10 Fix the correct SMBIOS type (4) to obtain CPU manufacturer Reviewed-by: ksrini --- .../classes/com/sun/servicetag/SolarisSystemEnvironment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java b/jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java index f9f10684fdd..877fe039349 100644 --- a/jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java +++ b/jdk/src/share/classes/com/sun/servicetag/SolarisSystemEnvironment.java @@ -62,8 +62,8 @@ class SolarisSystemEnvironment extends SystemEnvironment { return "Sun Microsystems, Inc"; } - // if we're here, then we'll try smbios (type 3) - return getSmbiosData("3", "Manufacturer: "); + // if we're here, then we'll try smbios (type 4) + return getSmbiosData("4", "Manufacturer: "); } /**