OtpErlangTuple fails on 0 arity tuples

Shawn Pearce spearce@REDACTED
Fri Jan 26 03:19:17 CET 2001


I have an Erlang node which just sent an empty tuple ({}) to a Java
node.  When I asked for the arity of that tuple, I expected to get
0.  Instead I got a NullPointerException in the arity() method of
OtpErlangJava.

Apparently, when the tuple is read in from the network its arity is
0 so the elems array inside of the OtpErlangJava was never initialized.
This caused the Java expression 'elems.length' to fail.

This error shows up in R7B-0.

I've included a patch below which definately fixes the problem.

If 0 arity tuples were not meant to be supported in Erlang, perhaps
the compiler should be fixed to prevent making 0 arity tuples.  :-)

--
Shawn.

  ``If this had been a real
    life, you would have
    received instructions
    on where to go and what
    to do.''




*** OtpErlangTuple.java.orig    Thu Jan 25 21:11:39 2001
--- OtpErlangTuple.java Thu Jan 25 21:13:58 2001
***************
*** 105,113 ****
        this.elems = new OtpErlangObject[arity];
  
        for (int i=0; i<arity; i++) {
!       elems[i] = buf.read_any();
!       }
!     }
    }
  
    /**
--- 105,115 ----
        this.elems = new OtpErlangObject[arity];
  
        for (int i=0; i<arity; i++) {
!           elems[i] = buf.read_any();
!         }
!     } else {
!         this.elems = new OtpErlangObject[0];
!       }
    }
  
    /**




More information about the erlang-questions mailing list