oracle/graal · error · IllegalArgumentException

No opcode for %s

Error message

No opcode for %s

What it means

Bytecodes.valueOf(String) maps an opcode mnemonic (e.g. "IADD", "invokedynamic") back to its numeric opcode by scanning the internal name table, ignoring case. If the string does not match any known JVM opcode mnemonic it throws IllegalArgumentException. The accepted set is exactly the standard JVMS opcode mnemonic list held in Bytecodes.nameArray.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/bytecode/Bytecodes.java:635

            return "<illegal opcode: " + opcode + ">";
        }
        return name;
    }

    /**
     * Gets the opcode corresponding to a given mnemonic.
     *
     * @param name an opcode mnemonic
     * @return the opcode corresponding to {@code mnemonic}
     * @throws IllegalArgumentException if {@code name} does not denote a valid opcode
     */
    public static int valueOf(String name) {
        for (int opcode = 0; opcode < nameArray.length; ++opcode) {
            if (name.equalsIgnoreCase(nameArray[opcode])) {
                return opcode;
            }
        }
        throw new IllegalArgumentException("No opcode for " + name);
    }

    /**
     * Determines if a given opcode is an instruction that has a 2 or 4 byte operand that is an
     * offset to another instruction in the same method. This does not include the
     * {@linkplain #TABLESWITCH switch} instructions.
     *
     * @param opcode an opcode to test
     * @return {@code true} iff {@code opcode} is a branch instruction with a single operand
     */
    public static boolean isBranch(int opcode) {
        return (flagsArray[opcode & 0xff] & BRANCH) != 0;
    }

    /**
     * Determines if a given opcode denotes a conditional branch.
     *
     * @param opcode

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Correct the mnemonic to an exact (case-insensitive) JVM opcode name, e.g. Bytecodes.valueOf("IADD").
  2. Validate/normalize input against Bytecodes.nameOf(opcode) output or the JVMS mnemonic list before calling valueOf.
  3. Trim surrounding whitespace from the string before the call; valueOf does not do it for you.

Example fix

// before
int op = Bytecodes.valueOf("iadd "); // trailing space -> throws

// after
int op = Bytecodes.valueOf("iadd".trim());
Defensive patterns

Strategy: validation

Validate before calling

static boolean isKnownOpcode(String name) {
    for (int op = 0; op <= Bytecodes.LAST_JAVA_OPCODE; op++) {
        if (Bytecodes.nameOf(op).equalsIgnoreCase(name.trim())) {
            return true;
        }
    }
    return false;
}
// call before Bytecodes.valueOf(name.trim())

Try / catch

try {
    int opcode = Bytecodes.valueOf(name);
} catch (IllegalArgumentException e) {
    // report unknown mnemonic to the user / config author
}

Prevention

When it happens

Trigger: Calling Bytecodes.valueOf with a misspelled mnemonic ("IADD " with whitespace, "iaddx"), a pseudo-instruction name that is not a real opcode, or an instruction name from a non-JVM bytecode (Dalen, WASM). Whitespace is not trimmed and unknown names have no fuzzy matching.

Common situations: Tooling that parses textual bytecode or user-supplied opcode lists; configuration files listing opcodes by name where a typo or a JVM-version-specific opcode (e.g. a newly constant-folded instruction) slips in. Also when porting code between JVM versions where the mnemonic table gained or lost entries.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/3b17706f24bdff4d. Report an issue: GitHub.