quarkusio/quarkus · error · IllegalArgumentException
Unexpected end of input: ${str}
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.
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)
Solutions
- Print and inspect the full type string reported in the message and locate where it ends prematurely
- Complete the type signature (close generics with >, finish package/class name, add array brackets)
- Check the code or template that builds the string for truncation (substring, limit, line-wrap)
- 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
- Always build signatures with helper methods, not raw string concatenation
- Balance < > and [ ] brackets programmatically when composing generics
- Unit-test every configured type-string before it reaches build time
- Log the full signature on failure (the exception already includes it)
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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unexpected character '${str.charAt(pos)}' at position ${pos}
- One of type, version or separating them ':' is missing from
- Invalid command line: ${cmdLine}
- Failed to parse cookie:
- Entry with empty key <entry>
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/3416ba02775e8457.
Report an issue: GitHub.