quarkusio/quarkus · error · IllegalArgumentException

Unknown jandex type: ${jandexType}

Error message

Unknown jandex type: ${jandexType}

What it means

The outer switch in AsmUtil.visitLdc handles non-primitive Jandex kinds: CLASS, TYPE_VARIABLE (bounds), WILDCARD_TYPE, VOID, etc. The default branch throws this IllegalArgumentException when a Jandex Type kind has no LDC emission strategy implemented — the requested type cannot be represented as a loadable constant by this utility.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/util/AsmUtil.java:218

            case TYPE_VARIABLE:
                List<Type> bounds = jandexType.asTypeVariable().bounds();
                if (bounds.isEmpty())
                    mv.visitLdcInsn(org.objectweb.asm.Type.getType(Object.class));
                else
                    visitLdc(mv, bounds.get(0));
                break;
            case UNRESOLVED_TYPE_VARIABLE:
            case TYPE_VARIABLE_REFERENCE:
                mv.visitLdcInsn(org.objectweb.asm.Type.getType(Object.class));
                break;
            case VOID:
                mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
                break;
            case WILDCARD_TYPE:
                visitLdc(mv, jandexType.asWildcardType().extendsBound());
                break;
            default:
                throw new IllegalArgumentException("Unknown jandex type: " + jandexType);
        }
    }

    /**
     * Calls the right boxing method for the given Jandex Type if it is a primitive.
     *
     * @param mv The MethodVisitor on which to visit the boxing instructions
     * @param jandexType The Jandex Type to box if it is a primitive.
     */
    public static void boxIfRequired(MethodVisitor mv, Type jandexType) {
        if (jandexType.kind() == Kind.PRIMITIVE) {
            switch (jandexType.asPrimitiveType().primitive()) {
                case BOOLEAN:
                    mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false);
                    break;
                case BYTE:
                    mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
                    break;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Extend AsmUtil.visitLdc's switch to handle the reported kind (e.g. for parameterized types, load the raw class constant)
  2. Pre-resolve the type: for parameterized types pass the erasure; for arrays load the array class constant
  3. Check which caller passes this type and correct the type derivation upstream
  4. Add tests for all Jandex kinds used by your extension's generated code

Example fix

// before
AsmUtil.visitLdc(mv, parameterizedType); // kind unhandled -> throws
// after
AsmUtil.visitLdc(mv, parameterizedType.asParameterizedType().name()); // CLASS kind, loads raw class
Defensive patterns

Strategy: type-guard

Validate before calling

boolean outerLdcSupported(org.jboss.jandex.Type t) {
    return switch (t.kind()) {
        case CLASS, PRIMITIVE, VOID, TYPE_VARIABLE, WILDCARD_TYPE -> true;
        default -> false;
    };
}

Type guard

// erasure-first narrowing: only emit constants for erasable kinds
org.jboss.jandex.Type erasureForLdc(org.jboss.jandex.Type t) {
    if (t.kind() == org.jboss.jandex.Type.Kind.PARAMETERIZED_TYPE) {
        return org.jboss.jandex.Type.create(t.asParameterizedType().name());
    }
    return t;
}

Try / catch

try {
    AsmUtil.visitLdc(mv, jandexType);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unknown jandex type")) {
        throw new IllegalStateException("Unsupported type kind for LDC: " + jandexType, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling visitLdc with kinds such as PARAMETERIZED_TYPE (if unhandled), ARRAY (if unhandled), or other composite kinds the switch does not enumerate; passing a null/empty or synthetic Jandex type whose kind() falls through.

Common situations: Generated-code extensions encountering generic/parameterized types at bytecode-generation time; annotation value extraction returning kinds the recorder did not anticipate; Jandex library upgrade changing kind coverage.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/29ad7c53f1880ece. Report an issue: GitHub.