projectlombok/lombok · error · IllegalArgumentException
Invalid type name
Error message
Invalid type name
What it means
TypeName.valueOf parses a dotted type name used as a lombok configuration value. It returns null for null/blank input and throws IllegalArgumentException when any dot-separated segment fails JavaIdentifiers.isValidJavaIdentifier. This ensures only syntactically valid type names are stored as configuration values.
Solutions
- Fix the type name so every dot-separated part is a valid Java identifier (letters, digits, $, _, not starting with a digit)
- Remove empty segments caused by leading, trailing, or consecutive dots
- Pre-validate segments with a regex such as ^[A-Za-z_$][A-Za-z0-9_$]*$ for each part
Example fix
// before
TypeName.valueOf("com.example.-.Foo")
// after
TypeName.valueOf("com.example.core.Foo") Defensive patterns
Strategy: validation
Validate before calling
boolean isValidTypeName(String s) {
if (s == null || s.trim().isEmpty()) return true;
for (String p : s.trim().split("\\."))
if (!p.matches("[A-Za-z_$][A-Za-z0-9_$]*")) return false;
return true;
} Try / catch
try { TypeName t = TypeName.valueOf(cfg); ... } catch (IllegalArgumentException e) { log.configError("Invalid type name in config", e); } Prevention
- Validate config strings segment-by-segment before storing
- Watch for empty segments from double dots or trailing dots
- Never embed version qualifiers or hyphens in Java type names
When it happens
Trigger: Calling TypeName.valueOf with a string where at least one segment between dots is not a valid Java identifier: empty segments (leading/trailing/double dots), segments starting with a digit (e.g. "3rdParty.Type"), or segments containing hyphens, spaces or other symbols.
Common situations: A lombok.config value like 'import: lombok/Getter', a typo'd class name such as 'com.example..Foo', or version-qualified names with hyphens passed where a Java type name is expected.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Minor version must be between 0 and 999
- Lombok supports at most v
- Invalid value
- Invalid identifier
- The declaration must follow the pattern: [LoggerType…
AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07).
Data as JSON: /api/errors/8320ab9245ea0ad9.
Report an issue: GitHub.
Appendix: source
Thrown at src/core/lombok/core/configuration/TypeName.java:38
* THE SOFTWARE.
*/
package lombok.core.configuration;
import lombok.core.JavaIdentifiers;
public final class TypeName implements ConfigurationValueType {
private final String name;
private TypeName(String name) {
this.name = name;
}
public static TypeName valueOf(String name) {
if (name == null || name.trim().isEmpty()) return null;
String trimmedName = name.trim();
for (String identifier : trimmedName.split("\\.")) {
if (!JavaIdentifiers.isValidJavaIdentifier(identifier)) throw new IllegalArgumentException("Invalid type name " + trimmedName + " (part " + identifier + ")");
}
return new TypeName(trimmedName);
}
public static String description() {
return "type-name";
}
public static String exampleValue() {
return "<fully.qualified.Type>";
}
@Override public boolean equals(Object obj) {
if (!(obj instanceof TypeName)) return false;
return name.equals(((TypeName) obj).name);
}
@Override public int hashCode() {View on GitHub (pinned to 6d6a3e9fec)