summaryrefslogtreecommitdiff
path: root/lib/jinterface/java_src
diff options
context:
space:
mode:
authorRickard Green <rickard@erlang.org>2020-11-12 18:53:34 +0100
committerRickard Green <rickard@erlang.org>2020-11-12 18:53:34 +0100
commit45bb65da09ed1c3e26407f8a0ec5b9e64c6a6755 (patch)
tree49df3f6219df1c9e823a29cf945f47d8a6a38999 /lib/jinterface/java_src
parent0f0100618e3d050ea9f00517a4d7ba00bfb740b9 (diff)
parentbefd665b8fad4aabd66ee1ad20aa87390c995438 (diff)
downloaderlang-45bb65da09ed1c3e26407f8a0ec5b9e64c6a6755.tar.gz
Merge branch 'rickard/alias/OTP-16718' into rickard/alias/master/OTP-16718
* rickard/alias/OTP-16718: User defined tag in monitor messages Use alias in gen behaviours Introduce aliases for processes Introduce internal references containing pid of creator Allow huge remote references
Diffstat (limited to 'lib/jinterface/java_src')
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java48
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java2
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java4
3 files changed, 38 insertions, 16 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java
index 2bf8d9a56b..ce52d0c395 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java
@@ -136,15 +136,20 @@ public class OtpErlangRef extends OtpErlangObject {
final int creation) {
this.node = node;
- // use at most 3 words
+ // use at most 5 words
int len = ids.length;
- this.ids = new int[3];
- this.ids[0] = 0;
- this.ids[1] = 0;
- this.ids[2] = 0;
-
- if (len > 3) {
- len = 3;
+ if (len < 3) {
+ this.ids = new int[3];
+ this.ids[0] = 0;
+ this.ids[1] = 0;
+ this.ids[2] = 0;
+ }
+ else if (len <= 5) {
+ this.ids = new int[len];
+ }
+ else {
+ this.ids = new int[5];
+ len = 5;
}
System.arraycopy(ids, 0, this.ids, 0, len);
if (tag == OtpExternal.newRefTag) {
@@ -173,7 +178,7 @@ public class OtpErlangRef extends OtpErlangObject {
/**
* Get the array of id numbers from the ref. If this is an old style ref,
* the array is of length 1. If this is a new style ref, the array has
- * length 3.
+ * length 3-5.
*
* @return the array of id numbers from the ref.
*/
@@ -260,11 +265,28 @@ public class OtpErlangRef extends OtpErlangObject {
return false;
}
- if (isNewRef() && ref.isNewRef()) {
- return ids[0] == ref.ids[0] && ids[1] == ref.ids[1]
- && ids[2] == ref.ids[2];
+ if (ids.length != ref.ids.length) {
+ if (ids.length > ref.ids.length) {
+ for (int i = ref.ids.length; i < ids.length; i++) {
+ if (ids[i] != 0) {
+ return false;
+ }
+ }
+ }
+ else {
+ for (int i = ids.length; i < ref.ids.length; i++) {
+ if (ref.ids[i] != 0) {
+ return false;
+ }
+ }
+ }
+ }
+ for (int i = 0; i < ids.length; i++) {
+ if (ids[i] != ref.ids[i]) {
+ return false;
+ }
}
- return ids[0] == ref.ids[0];
+ return true;
}
/**
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 8cc5b3c21d..6d0b5634db 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java
@@ -1047,7 +1047,7 @@ public class OtpInputStream extends ByteArrayInputStream {
case OtpExternal.newRefTag:
case OtpExternal.newerRefTag:
final int arity = read2BE();
- if (arity > 3) {
+ if (arity > 5) {
throw new OtpErlangDecodeException(
"Ref arity " + arity + " too large ");
}
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java
index 917e5baf3a..27d025c0ee 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java
@@ -807,8 +807,8 @@ public class OtpOutputStream extends ByteArrayOutputStream {
*/
public void write_ref(final String node, final int[] ids, final int creation) {
int arity = ids.length;
- if (arity > 3) {
- arity = 3; // max 3 words in ref
+ if (arity > 5) {
+ arity = 5; // max 5 words in ref
}
write1(OtpExternal.newerRefTag);