summaryrefslogtreecommitdiff
path: root/libjava/classpath
diff options
context:
space:
mode:
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-16 13:46:54 +0000
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-16 13:46:54 +0000
commit78d86c5be4c0d75dfe705c62125cfeebf624fdb7 (patch)
tree25fb8793c54fb29772fd31b47d57b85b5d092932 /libjava/classpath
parent11b70d7d77eb7bdaf0b5994e561040f8ee59d4b8 (diff)
downloadgcc-78d86c5be4c0d75dfe705c62125cfeebf624fdb7.tar.gz
2007-04-16 Andrew Haley <aph@redhat.com>
* org/omg/IOP/TaggedComponentHelper.java (read): Use read_octet_array(), not read(). (write): Use write_octet_array(), not write(). * org/omg/PortableServer/Servant.java (_get_delegate): Throw if no delegate has been set. * javax/management/ObjectName.java serialVersionUID: Declare. Make all fields transient. (parse): Break out from constructor. (writeObject, readObject): New methods. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123864 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath')
-rw-r--r--libjava/classpath/ChangeLog14
-rw-r--r--libjava/classpath/javax/management/ObjectName.java70
-rw-r--r--libjava/classpath/org/omg/IOP/TaggedComponentHelper.java28
-rw-r--r--libjava/classpath/org/omg/PortableServer/Servant.java5
4 files changed, 88 insertions, 29 deletions
diff --git a/libjava/classpath/ChangeLog b/libjava/classpath/ChangeLog
index 569c260b188..fabbb977920 100644
--- a/libjava/classpath/ChangeLog
+++ b/libjava/classpath/ChangeLog
@@ -1,3 +1,17 @@
+2007-04-16 Andrew Haley <aph@redhat.com>
+
+ * org/omg/IOP/TaggedComponentHelper.java (read): Use
+ read_octet_array(), not read().
+ (write): Use write_octet_array(), not write().
+
+ * org/omg/PortableServer/Servant.java (_get_delegate): Throw if no
+ delegate has been set.
+
+ * javax/management/ObjectName.java serialVersionUID: Declare.
+ Make all fields transient.
+ (parse): Break out from constructor.
+ (writeObject, readObject): New methods.
+
2007-04-02 Keith Seitz <keiths@redhat.com>
* gnu/classpath/jdwp/event/ThreadStartEvent.java (Event):
diff --git a/libjava/classpath/javax/management/ObjectName.java b/libjava/classpath/javax/management/ObjectName.java
index 604205437f3..0ddfb8ee6ad 100644
--- a/libjava/classpath/javax/management/ObjectName.java
+++ b/libjava/classpath/javax/management/ObjectName.java
@@ -45,6 +45,11 @@ import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
/**
* <p>
* An {@link ObjectName} instance represents the name of a management
@@ -97,30 +102,32 @@ public class ObjectName
implements Serializable, QueryExp
{
+ private static final long serialVersionUID = 1081892073854801359L;
+
/**
* The domain of the name.
*/
- private String domain;
+ private transient String domain;
/**
* The properties, as key-value pairs.
*/
- private TreeMap<String,String> properties = new TreeMap<String,String>();
+ private transient TreeMap<String,String> properties;
/**
* The properties as a string (stored for ordering).
*/
- private String propertyListString;
+ private transient String propertyListString;
/**
* True if this object name is a property pattern.
*/
- private boolean propertyPattern;
+ private transient boolean propertyPattern;
/**
* The management server associated with this object name.
*/
- private MBeanServer server;
+ private transient MBeanServer server;
/**
* Constructs an {@link ObjectName} instance from the given string,
@@ -145,12 +152,23 @@ public class ObjectName
{
if (name.length() == 0)
name = "*:*";
+ parse(name);
+ }
+
+ /**
+ * Parse the name in the same form as the constructor. Used by
+ * readObject().
+ */
+ private void parse(String name)
+ throws MalformedObjectNameException
+ {
int domainSep = name.indexOf(':');
if (domainSep == -1)
throw new MalformedObjectNameException("No domain separator was found.");
domain = name.substring(0, domainSep);
String rest = name.substring(domainSep + 1);
+ properties = new TreeMap<String,String>();
if (rest.equals("*"))
propertyPattern = true;
else
@@ -199,6 +217,7 @@ public class ObjectName
throws MalformedObjectNameException
{
this.domain = domain;
+ properties = new TreeMap<String,String>();
properties.put(key, value);
checkComponents();
}
@@ -221,6 +240,7 @@ public class ObjectName
throws MalformedObjectNameException
{
this.domain = domain;
+ this.properties = new TreeMap<String,String>();
this.properties.putAll(properties);
checkComponents();
}
@@ -741,6 +761,46 @@ public class ObjectName
return getCanonicalName();
}
+
+ /**
+ * Serialization methods. The serialized form is the same as the
+ * string parsed by the constructor.
+ */
+
+ private void writeObject(ObjectOutputStream out)
+ throws IOException
+ {
+ out.defaultWriteObject();
+ StringBuffer buffer = new StringBuffer(getDomain());
+ buffer.append(':');
+ String properties = getKeyPropertyListString();
+ buffer.append(properties);
+ if (isPropertyPattern())
+ {
+ if (properties.length() == 0)
+ buffer.append("*");
+ else
+ buffer.append(",*");
+ }
+ out.writeObject(buffer.toString());
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ String objectName = (String)in.readObject();
+ try
+ {
+ parse(objectName);
+ }
+ catch (MalformedObjectNameException x)
+ {
+ throw new InvalidObjectException(x.toString());
+ }
+ }
+
+
/**
* Unquotes the supplied string. The quotation marks are removed as
* are the backslashes preceding the escaped characters ('"', '?',
diff --git a/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java b/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java
index 633891b9b57..55090c74673 100644
--- a/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java
+++ b/libjava/classpath/org/omg/IOP/TaggedComponentHelper.java
@@ -136,18 +136,9 @@ public abstract class TaggedComponentHelper
{
TaggedComponent value = new TaggedComponent();
value.tag = input.read_long();
- value.component_data = new byte[input.read_long()];
- try
- {
- input.read(value.component_data);
- }
- catch (IOException e)
- {
- MARSHAL m = new MARSHAL();
- m.minor = Minor.Encapsulation;
- m.initCause(e);
- throw m;
- }
+ int length = input.read_long();
+ value.component_data = new byte[length];
+ input.read_octet_array(value.component_data, 0, length);
return value;
}
@@ -163,17 +154,6 @@ public abstract class TaggedComponentHelper
{
output.write_long(value.tag);
output.write_long(value.component_data.length);
-
- try
- {
- output.write(value.component_data);
- }
- catch (IOException e)
- {
- MARSHAL m = new MARSHAL();
- m.minor = Minor.Encapsulation;
- m.initCause(e);
- throw m;
- }
+ output.write_octet_array(value.component_data, 0, value.component_data.length);
}
} \ No newline at end of file
diff --git a/libjava/classpath/org/omg/PortableServer/Servant.java b/libjava/classpath/org/omg/PortableServer/Servant.java
index 24eb715a98d..fcb2cdd6a3c 100644
--- a/libjava/classpath/org/omg/PortableServer/Servant.java
+++ b/libjava/classpath/org/omg/PortableServer/Servant.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.OBJECT_NOT_EXIST;
import org.omg.CORBA.ORB;
@@ -109,6 +110,10 @@ public abstract class Servant
*/
public final Delegate _get_delegate()
{
+ if (delegate == null) {
+ throw new BAD_INV_ORDER
+ ("The Servant has not been associated with an ORBinstance");
+ }
return delegate;
}