quarkusio/quarkus · error · IllegalArgumentException

Unexpected end of input

Error message

Unexpected end of input: ${str}

What it means

TypeParser parses Java type signature strings (e.g. 'java.util.List<java.lang.String>') into Jandex type structures. This IllegalArgumentException is thrown by the unexpected() helper when the parser runs out of input while expecting another token, i.e. the type string is truncated/incomplete. The library throws it because a partial type string cannot describe a complete, well-formed type.

Solutions

  1. Print and inspect the full type string reported in the message and locate where it ends prematurely
  2. Complete the type signature (close generics with >, finish package/class name, add array brackets)
  3. Check the code or template that builds the string for truncation (substring, limit, line-wrap)
  4. Validate the string parses as a Java type signature before passing it to TypeParser

Example fix

// before
new TypeParser("java.util.List<java.lang.String").parse();
// after
new TypeParser("java.util.List<java.lang.String>").parse();
Defensive patterns

Strategy: validation

Validate before calling

boolean isCompleteTypeSignature(String s) {
    if (s == null || s.isBlank()) return false;
    int depth = 0;
    for (char c : s.toCharArray()) {
        if (c == '<') depth++;
        if (c == '>') depth--;
        if (depth < 0) return false;
    }
    return depth == 0 && !s.endsWith(".") && !s.endsWith(",");
}

Try / catch

try {
    new TypeParser(sig).parse();
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unexpected end of input")) {
        throw new IllegalArgumentException("Truncated type signature: " + sig, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling TypeParser.parse/parseReferenceType/parsePrimitiveType with a string that terminates where another token is required — e.g. 'java.util.', 'java.util.List<java.util', or 'Lcom/foo/' with the closing segment missing. unexpected("") is invoked when a consumed/peeked token is empty.

Common situations: Configuration properties (e.g. quarkus config referencing custom types) where the value was cut off; generated code emitting half-built type signatures; hand-edited annotations like @ConfigMapping signatures that were truncated by templating or string slicing.

Understand the failure class

Related errors


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

Appendix: source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/types/TypeParser.java:180

        try {
            return Class.forName(token, true, Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Unknown class: " + token, e);
        }
    }

    // ---

    private void expect(String expected) {
        String token = nextToken();
        if (!expected.equals(token)) {
            throw unexpected(token);
        }
    }

    private IllegalArgumentException unexpected(String token) {
        if (token.isEmpty()) {
            throw new IllegalArgumentException("Unexpected end of input: " + str);
        }
        return new IllegalArgumentException("Unexpected token '" + token + "' at position " + (pos - token.length())
                + ": " + str);
    }

    private String peekToken() {
        // skip whitespace
        while (pos < str.length() && Character.isWhitespace(str.charAt(pos))) {
            pos++;
        }

        // end of input
        if (pos == str.length()) {
            return "";
        }

        int pos = this.pos;

View on GitHub (pinned to e1c734241f)