diff options
author | Sverker Eriksson <[email protected]> | 2015-11-20 19:45:29 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-04-07 18:41:47 +0200 |
commit | 539ce190ba8f8842c24b17f3257c44cd850d7e01 (patch) | |
tree | 44fdc375d19068ca9434f943bb3d23bdfe79c570 /lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java | |
parent | 9c80b9ec06fc0ca89dcc8d797a2dbc408a162098 (diff) | |
download | otp-539ce190ba8f8842c24b17f3257c44cd850d7e01.tar.gz otp-539ce190ba8f8842c24b17f3257c44cd850d7e01.tar.bz2 otp-539ce190ba8f8842c24b17f3257c44cd850d7e01.zip |
jinterface: Support 32-bit creation values
Diffstat (limited to 'lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java index fa0815fbf0..50d825fb80 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java @@ -954,18 +954,23 @@ public class OtpInputStream extends ByteArrayInputStream { tag = read1skip_version(); - if (tag != OtpExternal.pidTag) { + if (tag != OtpExternal.pidTag && + tag != OtpExternal.newPidTag) { throw new OtpErlangDecodeException( "Wrong tag encountered, expected " + OtpExternal.pidTag + + " or " + OtpExternal.newPidTag + ", got " + tag); } node = read_atom(); - id = read4BE() & 0x7fff; // 15 bits - serial = read4BE() & 0x1fff; // 13 bits - creation = read1() & 0x03; // 2 bits - - return new OtpErlangPid(node, id, serial, creation); + id = read4BE(); + serial = read4BE(); + if (tag == OtpExternal.pidTag) + creation = read1(); + else + creation = read4BE(); + + return new OtpErlangPid(tag, node, id, serial, creation); } /** @@ -984,17 +989,22 @@ public class OtpInputStream extends ByteArrayInputStream { tag = read1skip_version(); - if (tag != OtpExternal.portTag) { + if (tag != OtpExternal.portTag && + tag != OtpExternal.newPortTag) { throw new OtpErlangDecodeException( "Wrong tag encountered, expected " + OtpExternal.portTag + + " or " + OtpExternal.newPortTag + ", got " + tag); } node = read_atom(); - id = read4BE() & 0xfffffff; // 28 bits - creation = read1() & 0x03; // 2 bits + id = read4BE(); + if (tag == OtpExternal.portTag) + creation = read1(); + else + creation = read4BE(); - return new OtpErlangPort(node, id, creation); + return new OtpErlangPort(tag, node, id, creation); } /** @@ -1021,16 +1031,23 @@ public class OtpInputStream extends ByteArrayInputStream { return new OtpErlangRef(node, id, creation); case OtpExternal.newRefTag: + case OtpExternal.newerRefTag: final int arity = read2BE(); + if (arity > 3) { + throw new OtpErlangDecodeException( + "Ref arity " + arity + " too large "); + } node = read_atom(); - creation = read1() & 0x03; // 2 bits + if (tag == OtpExternal.newRefTag) + creation = read1(); + else + creation = read4BE(); final int[] ids = new int[arity]; for (int i = 0; i < arity; i++) { ids[i] = read4BE(); } - ids[0] &= 0x3ffff; // first id gets truncated to 18 bits - return new OtpErlangRef(node, ids, creation); + return new OtpErlangRef(tag, node, ids, creation); default: throw new OtpErlangDecodeException( @@ -1200,15 +1217,18 @@ public class OtpInputStream extends ByteArrayInputStream { case OtpExternal.refTag: case OtpExternal.newRefTag: + case OtpExternal.newerRefTag: return new OtpErlangRef(this); case OtpExternal.mapTag: return new OtpErlangMap(this); case OtpExternal.portTag: + case OtpExternal.newPortTag: return new OtpErlangPort(this); case OtpExternal.pidTag: + case OtpExternal.newPidTag: return new OtpErlangPid(this); case OtpExternal.stringTag: |