code: private static void check(byte[] encoding) throws IOException {
          int length = encoding.length;
          if (length < 1 ||      // too short
                  (encoding[length - 1] & 0x80) != 0) {  // not ended
              throw new IOException("ObjectIdentifier() -- " +
                      "Invalid DER encoding, not ended");
          }
          for (int i=0; i<length; i++) {
              // 0x80 at the beginning of a subidentifier
              if (encoding[i] == (byte)0x80 &&
                      (i==0 || (encoding[i-1] & 0x80) == 0)) {
                  throw new IOException("ObjectIdentifier() -- " +
                          "Invalid DER encoding, useless extra octet detected");
              }
          }
      }
docs: Check the DER encoding. Since DER encoding defines that the integer bits
  are unsigned, so there's no need to check the MSB.