public byte[] readPacket() throws IOException { DataInputStream stream; synchronized (this) { if (!isOpen()) { throw new ClosedConnectionException(); } stream = new DataInputStream(fTransport.getInputStream()); } synchronized (stream) { int packetLength = 0; try { packetLength = stream.readInt(); } catch (IOException e) { throw new ClosedConnectionException(); } if (packetLength < 11) { throw new IOException("JDWP Packet under 11 bytes"); //$NON-NLS-1$ } byte[] packet = new byte[packetLength]; packet[0] = (byte) ((packetLength >>> 24) & 0xFF); packet[1] = (byte) ((packetLength >>> 16) & 0xFF); packet[2] = (byte) ((packetLength >>> 8) & 0xFF); packet[3] = (byte) ((packetLength >>> 0) & 0xFF); stream.readFully(packet, 4, packetLength - 4); return packet; } }