in core/src/main/java/com/jetbrains/sa/jdwp/Packet.java [93:129]
public static Packet fromByteArray(byte[] b) throws IOException {
if (b.length < 11) {
throw new IOException("packet is insufficient size");
}
int b0 = b[0] & 0xff;
int b1 = b[1] & 0xff;
int b2 = b[2] & 0xff;
int b3 = b[3] & 0xff;
int len = ((b0 << 24) | (b1 << 16) | (b2 << 8) | (b3 << 0));
if (len != b.length) {
throw new IOException("length size mis-match");
}
int b4 = b[4] & 0xff;
int b5 = b[5] & 0xff;
int b6 = b[6] & 0xff;
int b7 = b[7] & 0xff;
Packet p = new Packet();
p.id = ((b4 << 24) | (b5 << 16) | (b6 << 8) | (b7 << 0));
p.flags = (short)(b[8] & 0xff);
if ((p.flags & Packet.Reply) == 0) {
p.cmdSet = (short)(b[9] & 0xff);
p.cmd = (short)(b[10] & 0xff);
} else {
short b9 = (short)(b[9] & 0xff);
short b10 = (short)(b[10] & 0xff);
p.errorCode = (short)((b9 << 8) + (b10 << 0));
}
p.data = new byte[b.length - 11];
System.arraycopy(b, 11, p.data, 0, p.data.length);
return p;
}