code: public byte[] read_bitstr(final int pad_bits[])
              throws OtpErlangDecodeException {
          int tag;
          int len;
          byte[] bin;
  
          tag = read1skip_version();
  
          if (tag != OtpExternal.bitBinTag) {
              throw new OtpErlangDecodeException(
                      "Wrong tag encountered, expected " + OtpExternal.bitBinTag
                              + ", got " + tag);
          }
  
          len = read4BE();
          bin = new byte[len];
          final int tail_bits = read1();
          if (tail_bits < 0 || 7 < tail_bits) {
              throw new OtpErlangDecodeException(
                      "Wrong tail bit count in bitstr: " + tail_bits);
          }
          if (len == 0 && tail_bits != 0) {
              throw new OtpErlangDecodeException(
                      "Length 0 on bitstr with tail bit count: " + tail_bits);
          }
          this.readN(bin);
  
          pad_bits[0] = 8 - tail_bits;
          return bin;
      }
docs: Read an Erlang bitstr from the stream.
  
  @param pad_bits
  an int array whose first element will be set to the number of
  pad bits in the last byte.
  
  @return a byte array containing the value of the bitstr.
  
  @exception OtpErlangDecodeException
  if the next term in the stream is not a bitstr.