OtpErlangTuple fails on 0 arity tuples

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OtpErlangTuple fails on 0 arity tuples

Shawn Pearce
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];
!       }
    }
 
    /**



Reply | Threaded
Open this post in threaded view
|

OtpErlangTuple fails on 0 arity tuples

Ulf Wiger-4
On Thu, 25 Jan 2001, Shawn Pearce wrote:

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

0 arity tuples are definitely supported in Erlang.

Sometimes, they're even useful. ;)

/Uffe
--
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB



Reply | Threaded
Open this post in threaded view
|

OtpErlangTuple fails on 0 arity tuples

Shawn Pearce
Hence why I was sending them from an Erlang node to a Java node?  :)
My Java node expected a tuple there, and a 0 arity tuple meant something
special.  Buuuuut, code broke.  :-)


Ulf Wiger <etxuwig> scrawled:

> On Thu, 25 Jan 2001, Shawn Pearce wrote:
>
> >If 0 arity tuples were not meant to be supported in Erlang, perhaps
> >the compiler should be fixed to prevent making 0 arity tuples.  :-)
>
> 0 arity tuples are definitely supported in Erlang.
>
> Sometimes, they're even useful. ;)
>
> /Uffe
> --
> Ulf Wiger                                    tfn: +46  8 719 81 95
> Senior System Architect                      mob: +46 70 519 81 95
> Strategic Product & System Management    ATM Multiservice Networks
> Data Backbone & Optical Services Division      Ericsson Telecom AB
--
Shawn.

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