--- a/jdk/src/share/classes/javax/management/remote/TargetedNotification.java Fri Jun 14 15:49:54 2013 +0100
+++ b/jdk/src/share/classes/javax/management/remote/TargetedNotification.java Thu Jun 20 08:51:47 2013 +0200
@@ -26,6 +26,9 @@
package javax.management.remote;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import javax.management.Notification;
@@ -73,12 +76,9 @@
*/
public TargetedNotification(Notification notification,
Integer listenerID) {
+ validate(notification, listenerID);
// If we replace integer with int...
// this(notification,intValue(listenerID));
- if (notification == null) throw new
- IllegalArgumentException("Invalid notification: null");
- if (listenerID == null) throw new
- IllegalArgumentException("Invalid listener ID: null");
this.notif = notification;
this.id = listenerID;
}
@@ -115,13 +115,13 @@
* @serial A notification to transmit to the other side.
* @see #getNotification()
**/
- private final Notification notif;
+ private Notification notif;
/**
* @serial The ID of the listener to which the notification is
* targeted.
* @see #getListenerID()
**/
- private final Integer id;
+ private Integer id;
//private final int id;
// Needed if we use int instead of Integer...
@@ -130,4 +130,26 @@
// IllegalArgumentException("Invalid listener ID: null");
// return id.intValue();
// }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = ois.readFields();
+ Notification notification = (Notification)gf.get("notif", null);
+ Integer listenerId = (Integer)gf.get("id", null);
+ try {
+ validate(notification, listenerId);
+ this.notif = notification;
+ this.id = listenerId;
+ } catch (IllegalArgumentException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
+ }
+
+ private static void validate(Notification notif, Integer id) throws IllegalArgumentException {
+ if (notif == null) {
+ throw new IllegalArgumentException("Invalid notification: null");
+ }
+ if (id == null) {
+ throw new IllegalArgumentException("Invalid listener ID: null");
+ }
+ }
}