projectlombok/lombok · error · BuildException

Unknown charset

Error message

Unknown charset: ${encoding}

What it means

Before running, the Ant task calls `Delombok.setCharset(encoding)`; if the charset name is not supported by the JVM, `UnsupportedCharsetException` is caught and rethrown as a BuildException 'Unknown charset: <name>'. This fails fast rather than producing mojibake output.

Solutions

  1. Use a canonical charset name such as `UTF-8`, `ISO-8859-1`, or `US-ASCII` (see `Charset.availableCharsets()` / `Charset.isSupported(name)` in the same JVM)
  2. Trim whitespace and fix typos in the `encoding` attribute
  3. Omit the encoding attribute to use the platform default

Example fix

<!-- before -->
<delombok from="src" to="out" encoding="utf8"/>
<!-- after -->
<delombok from="src" to="out" encoding="UTF-8"/>
Defensive patterns

Strategy: validation

Validate before calling

if (encoding != null && !java.nio.charset.Charset.isSupported(encoding.trim()))
    throw new BuildException("Unsupported charset: " + encoding);

Try / catch

catch (BuildException e) { if (e.getMessage().startsWith("Unknown charset")) { /* fix encoding attribute to canonical name */ } throw e; }

Prevention

When it happens

Trigger: Setting `encoding="utf8"`-style aliases the JVM does not recognize (canonical is `UTF-8`), a misspelled name like `utf-8` with stray whitespace, or a charset unavailable in the target JVM's provider list.

Common situations: Copying charset names from OS tools (e.g. 'utf8', 'ansi_x3.4-1968' variants) into Ant attributes; cross-platform builds where a charset exists on the dev machine but not the CI JVM.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07). Data as JSON: /api/errors/b14360568eccdb71. Report an issue: GitHub.

Appendix: source

Thrown at src/delombok/lombok/delombok/ant/DelombokTaskImpl.java:59

	private Path classpath;
	private Path sourcepath;
	private Path modulepath;
	private boolean verbose;
	private String encoding;
	private Path path;
	private List<String> formatOptions = new ArrayList<String>();
	
	public void execute(Location location) throws BuildException {
		if (fromDir == null && path == null) throw new BuildException("Either 'from' attribute, or nested <fileset> tags are required.");
		if (fromDir != null && path != null) throw new BuildException("You can't specify both 'from' attribute and nested filesets. You need one or the other.");
		if (toDir == null) throw new BuildException("The to attribute is required.");
		
		Delombok delombok = new Delombok();
		if (verbose) delombok.setVerbose(true);
		try {
			if (encoding != null) delombok.setCharset(encoding);
		} catch (UnsupportedCharsetException e) {
			throw new BuildException("Unknown charset: " + encoding, location);
		}
		
		if (classpath != null) delombok.setClasspath(classpath.toString());
		if (sourcepath != null) delombok.setSourcepath(sourcepath.toString());
		if (modulepath != null) delombok.setModulepath(modulepath.toString());
		
		try {
			delombok.setFormatPreferences(Delombok.formatOptionsToMap(formatOptions));
		} catch (InvalidFormatOptionException e) {
			throw new BuildException(e.getMessage() + " Run java -jar lombok.jar --format-help for detailed format help.");
		}
		
		delombok.setOutput(toDir);
		try {
			if (fromDir != null) delombok.addDirectory(fromDir);
			else {
				Iterator<?> it = path.iterator();
				while (it.hasNext()) {

View on GitHub (pinned to 6d6a3e9fec)