public static boolean isValidShape(int opcode) {
    /*
     * Note: This method bakes in knowledge that all opcodes are
     * one of the forms:
     *
     *   * single byte in range 0x01..0xfe -- normal opcodes
     *   * (byteValue << 8) -- nop and data payload opcodes
     *   * ((byteValue << 8) | 0xff) -- 16-bit extended opcodes
     *   * SPECIAL_FORMAT or NO_NEXT -- pseudo-opcodes
     */

    // Note: SPECIAL_FORMAT == NO_NEXT.
    if (opcode < SPECIAL_FORMAT) {
      return false;
    } else if (opcode == SPECIAL_FORMAT) {
      return true;
    }

    int lowByte = opcode & 0xff;
    if ((lowByte == 0) || (lowByte == 0xff)) {
      return true;
    }

    return (opcode & 0xff00) == 0;
  }
Determines if the given opcode has the right "shape" to be valid. This includes the range
{@code 0x01..0xfe}, the range {@code 0x00ff..0xffff} where the low-order byte is either {@code
0} or {@code 0xff}, and the special opcode values {@code SPECIAL_FORMAT} and {@code NO_NEXT}.
Note that not all of the opcode values that pass this test are in fact used. This method is
meant to perform a quick check to reject blatantly wrong values (e.g. when validating
arguments).

@param opcode the opcode value
@return {@code true} iff the value has the right "shape" to be possibly valid
android/android_framework/dex-maker/src/main/java/com/android/dx/io/Opcodes.java