code: public int read_list_head() throws OtpErlangDecodeException {
          int arity = 0;
          final int tag = read1skip_version();
  
          switch (tag) {
          case OtpExternal.nilTag:
              arity = 0;
              break;
  
          case OtpExternal.stringTag:
              arity = read2BE();
              break;
  
          case OtpExternal.listTag:
              arity = read4BE();
              break;
  
          default:
              throw new OtpErlangDecodeException("Not valid list tag: " + tag);
          }
  
          return arity;
      }
docs: Read a list header from the stream.
  
  @return the arity of the list.
  
  @exception OtpErlangDecodeException
  if the next term in the stream is not a list.