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/OtpErlangPid.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/OtpErlangPid.java')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java index 20b7ff6a7f..66b4475a9e 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java @@ -27,6 +27,7 @@ public class OtpErlangPid extends OtpErlangObject implements Comparable<Object> // don't change this! private static final long serialVersionUID = 1664394142301803659L; + private final int tag; private final String node; private final int id; private final int serial; @@ -44,6 +45,7 @@ public class OtpErlangPid extends OtpErlangObject implements Comparable<Object> public OtpErlangPid(final OtpLocalNode self) { final OtpErlangPid p = self.createPid(); + tag = p.tag; id = p.id; serial = p.serial; creation = p.creation; @@ -65,6 +67,7 @@ public class OtpErlangPid extends OtpErlangObject implements Comparable<Object> throws OtpErlangDecodeException { final OtpErlangPid p = buf.read_pid(); + tag = p.tag; node = p.node(); id = p.id(); serial = p.serial(); @@ -85,15 +88,52 @@ public class OtpErlangPid extends OtpErlangObject implements Comparable<Object> * used. * * @param creation - * yet another arbitrary number. Only the low order 2 bits will + * yet another arbitrary number. Ony the low order 2 bits will * be used. */ public OtpErlangPid(final String node, final int id, final int serial, - final int creation) { - this.node = node; - this.id = id & 0x7fff; // 15 bits - this.serial = serial & 0x1fff; // 13 bits - this.creation = creation & 0x03; // 2 bits + final int creation) { + this(OtpExternal.pidTag, node, id, serial, creation); + } + + /** + * Create an Erlang pid from its components. + * + * @param tag + * the external format to be compliant with + * OtpExternal.pidTag where only a subset of the bits are significant (see other constructor). + * OtpExternal.newPidTag where all 32 bits of id,serial and creation are significant. + * newPidTag can only be decoded by OTP-19 and newer. + * @param node + * the nodename. + * + * @param id + * an arbitrary number. + * + * @param serial + * another arbitrary number. + * + * @param creation + * yet another arbitrary number. + */ + protected OtpErlangPid(final int tag, final String node, final int id, + final int serial, final int creation) { + this.tag = tag; + this.node = node; + if (tag == OtpExternal.pidTag) { + this.id = id & 0x7fff; // 15 bits + this.serial = serial & 0x1fff; // 13 bits + this.creation = creation & 0x03; // 2 bits + } + else { // allow all 32 bits for newPidTag + this.id = id; + this.serial = serial; + this.creation = creation; + } + } + + protected int tag() { + return tag; } /** @@ -151,7 +191,7 @@ public class OtpErlangPid extends OtpErlangObject implements Comparable<Object> */ @Override public void encode(final OtpOutputStream buf) { - buf.write_pid(node, id, serial, creation); + buf.write_pid(this); } /** |