diff options
author | Keith Seitz <keiths@redhat.com> | 2005-06-30 18:05:10 +0000 |
---|---|---|
committer | Keith Seitz <kseitz@gcc.gnu.org> | 2005-06-30 18:05:10 +0000 |
commit | afe8d701ba8f5d04e5ac37a00c11a5b7a8976030 (patch) | |
tree | 7f2fd1aa54ab3a56979ca29988cc9656e8cb9cd6 | |
parent | 1b0618bfe6193985baadba89c5eedfbb7730eda3 (diff) | |
download | gcc-afe8d701ba8f5d04e5ac37a00c11a5b7a8976030.zip gcc-afe8d701ba8f5d04e5ac37a00c11a5b7a8976030.tar.gz gcc-afe8d701ba8f5d04e5ac37a00c11a5b7a8976030.tar.bz2 |
JdwpPacket.java (write): New method.
* gnu/classpath/jdwp/transport/JdwpPacket.java (write): New method.
(myWrite): New abstract method.
(toBytes): Remove.
(myToBytes): Remove.
* gnu/classpath/jdwp/transport/JdwpReplyPacket.java (myWrite): New
method.
* gnu/classpath/jdwp/transport/JdwpCommandPacket.java (myWrite): New
method.
* gnu/classpath/jdwp/transport/JdwpConnection.java (sendPacket): Use
JdwpPacket.write instead of JdwpPacket.toBytes.
From-SVN: r101472
-rw-r--r-- | libjava/ChangeLog | 13 | ||||
-rw-r--r-- | libjava/gnu/classpath/jdwp/transport/JdwpCommandPacket.java | 14 | ||||
-rw-r--r-- | libjava/gnu/classpath/jdwp/transport/JdwpConnection.java | 3 | ||||
-rw-r--r-- | libjava/gnu/classpath/jdwp/transport/JdwpPacket.java | 58 | ||||
-rw-r--r-- | libjava/gnu/classpath/jdwp/transport/JdwpReplyPacket.java | 15 |
5 files changed, 53 insertions, 50 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 29dcb15..3fec4a04 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,18 @@ 2005-06-30 Keith Seitz <keiths@redhat.com> + * gnu/classpath/jdwp/transport/JdwpPacket.java (write): New method. + (myWrite): New abstract method. + (toBytes): Remove. + (myToBytes): Remove. + * gnu/classpath/jdwp/transport/JdwpReplyPacket.java (myWrite): New + method. + * gnu/classpath/jdwp/transport/JdwpCommandPacket.java (myWrite): New + method. + * gnu/classpath/jdwp/transport/JdwpConnection.java (sendPacket): Use + JdwpPacket.write instead of JdwpPacket.toBytes. + +2005-06-30 Keith Seitz <keiths@redhat.com> + * gnu/classpath/jdwp/transport/JdwpConnection.java (sendEvent): New method. (_bytes): New member. diff --git a/libjava/gnu/classpath/jdwp/transport/JdwpCommandPacket.java b/libjava/gnu/classpath/jdwp/transport/JdwpCommandPacket.java index dc4b15f..e99159a 100644 --- a/libjava/gnu/classpath/jdwp/transport/JdwpCommandPacket.java +++ b/libjava/gnu/classpath/jdwp/transport/JdwpCommandPacket.java @@ -39,6 +39,9 @@ exception statement from your version. */ package gnu.classpath.jdwp.transport; +import java.io.DataOutputStream; +import java.io.IOException; + /** * A class representing a JDWP command packet. * This class adds command set and command to the packet header @@ -137,13 +140,10 @@ public class JdwpCommandPacket extends JdwpPacket } // Writes the command packet data into the given buffer - protected int myToBytes (byte[] bytes, int index) + protected void myWrite (DataOutputStream dos) + throws IOException { - // Need to add command set & command - int i = 0; - bytes[index + i++] = getCommandSet (); - bytes[index + i++] = getCommand (); - - return i; + dos.writeByte (getCommandSet ()); + dos.writeByte (getCommand ()); } } diff --git a/libjava/gnu/classpath/jdwp/transport/JdwpConnection.java b/libjava/gnu/classpath/jdwp/transport/JdwpConnection.java index ffc8a17..18250d3 100644 --- a/libjava/gnu/classpath/jdwp/transport/JdwpConnection.java +++ b/libjava/gnu/classpath/jdwp/transport/JdwpConnection.java @@ -258,8 +258,7 @@ public class JdwpConnection public void sendPacket (JdwpPacket pkt) throws IOException { - byte[] data = pkt.toBytes (); - _outStream.write (data, 0, data.length); + pkt.write (_outStream); } /** diff --git a/libjava/gnu/classpath/jdwp/transport/JdwpPacket.java b/libjava/gnu/classpath/jdwp/transport/JdwpPacket.java index 485aa40..7fa93e2 100644 --- a/libjava/gnu/classpath/jdwp/transport/JdwpPacket.java +++ b/libjava/gnu/classpath/jdwp/transport/JdwpPacket.java @@ -39,6 +39,9 @@ exception statement from your version. */ package gnu.classpath.jdwp.transport; +import java.io.DataOutputStream; +import java.io.IOException; + /** * All command and reply packets in JDWP share * common header type information: @@ -238,49 +241,38 @@ public abstract class JdwpPacket return null; } - // Put subclass information into bytes - protected abstract int myToBytes (byte[] bytes, int index); + /** + * Put subclass information onto the stream + * + * @param dos the output stream to which to write + */ + protected abstract void myWrite (DataOutputStream dos) + throws IOException; - // Convert this packet to it byte representation (ready to send on the wire) - // NOTE: All integers should be big-endian. - public byte[] toBytes () + /** + * Writes the packet to the output stream + * + * @param dos the output stream to which to write the packet + */ + public void write (DataOutputStream dos) + throws IOException { - // Allocate a new array to hold contents of packet - int length = getLength (); - byte[] bytes = new byte[length]; - - int i = 0; - - // - // Packet layout: length, id, flags, packet-specific, data (optional) - // - // length - bytes[i++] = (byte) (length >>> 24); - bytes[i++] = (byte) (length >>> 16); - bytes[i++] = (byte) (length >>> 8); - bytes[i++] = (byte) length; + int length = getLength (); + dos.writeInt (length); - // id - bytes[i++] = (byte) (getId () >>> 24); - bytes[i++] = (byte) (getId () >>> 16); - bytes[i++] = (byte) (getId () >>> 8); - bytes[i++] = (byte) getId (); + // ID + dos.writeInt (getId ()); // flag - bytes[i++] = getFlags (); + dos.writeByte (getFlags ()); // packet-specific stuff - i += myToBytes (bytes, i); + myWrite (dos); // data (if any) byte[] data = getData (); - if (data.length > 0 && i < length) - { - // Would it pay to be over cautious? - System.arraycopy (data, 0, bytes, i, data.length); - } - - return bytes; + if (data != null && data.length > 0) + dos.write (data, 0, data.length); } } diff --git a/libjava/gnu/classpath/jdwp/transport/JdwpReplyPacket.java b/libjava/gnu/classpath/jdwp/transport/JdwpReplyPacket.java index ad4e07d..06d1aff 100644 --- a/libjava/gnu/classpath/jdwp/transport/JdwpReplyPacket.java +++ b/libjava/gnu/classpath/jdwp/transport/JdwpReplyPacket.java @@ -39,6 +39,9 @@ exception statement from your version. */ package gnu.classpath.jdwp.transport; +import java.io.DataOutputStream; +import java.io.IOException; + /** * A class represents a JDWP reply packet. * This class adds an error code to the packet header information @@ -115,13 +118,9 @@ public class JdwpReplyPacket extends JdwpPacket } // Writes the command packet data into the given buffer - protected int myToBytes (byte[] bytes, int index) - { - // Need to add error code - int i = 0; - bytes[index + i++] = (byte) (getErrorCode () >>> 8); - bytes[index + i++] = (byte) getErrorCode (); - - return i; + protected void myWrite (DataOutputStream dos) + throws IOException + { + dos.writeShort (getErrorCode ()); } } |