{"record":{"id":"b14360568eccdb71","repo":"projectlombok/lombok","slug":"unknown-charset-encoding","errorCode":null,"errorMessage":"Unknown charset: ${encoding}","messagePattern":"Unknown charset: (.+?)","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/delombok/lombok/delombok/ant/DelombokTaskImpl.java","lineNumber":59,"sourceCode":"\tprivate Path classpath;\n\tprivate Path sourcepath;\n\tprivate Path modulepath;\n\tprivate boolean verbose;\n\tprivate String encoding;\n\tprivate Path path;\n\tprivate List<String> formatOptions = new ArrayList<String>();\n\t\n\tpublic void execute(Location location) throws BuildException {\n\t\tif (fromDir == null && path == null) throw new BuildException(\"Either 'from' attribute, or nested <fileset> tags are required.\");\n\t\tif (fromDir != null && path != null) throw new BuildException(\"You can't specify both 'from' attribute and nested filesets. You need one or the other.\");\n\t\tif (toDir == null) throw new BuildException(\"The to attribute is required.\");\n\t\t\n\t\tDelombok delombok = new Delombok();\n\t\tif (verbose) delombok.setVerbose(true);\n\t\ttry {\n\t\t\tif (encoding != null) delombok.setCharset(encoding);\n\t\t} catch (UnsupportedCharsetException e) {\n\t\t\tthrow new BuildException(\"Unknown charset: \" + encoding, location);\n\t\t}\n\t\t\n\t\tif (classpath != null) delombok.setClasspath(classpath.toString());\n\t\tif (sourcepath != null) delombok.setSourcepath(sourcepath.toString());\n\t\tif (modulepath != null) delombok.setModulepath(modulepath.toString());\n\t\t\n\t\ttry {\n\t\t\tdelombok.setFormatPreferences(Delombok.formatOptionsToMap(formatOptions));\n\t\t} catch (InvalidFormatOptionException e) {\n\t\t\tthrow new BuildException(e.getMessage() + \" Run java -jar lombok.jar --format-help for detailed format help.\");\n\t\t}\n\t\t\n\t\tdelombok.setOutput(toDir);\n\t\ttry {\n\t\t\tif (fromDir != null) delombok.addDirectory(fromDir);\n\t\t\telse {\n\t\t\t\tIterator<?> it = path.iterator();\n\t\t\t\twhile (it.hasNext()) {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/projectlombok/lombok/blob/6d6a3e9fec0a9555702561fbeb8eac836575116e/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)","Trim whitespace and fix typos in the `encoding` attribute","Omit the encoding attribute to use the platform default"],"exampleFix":"<!-- before -->\n<delombok from=\"src\" to=\"out\" encoding=\"utf8\"/>\n<!-- after -->\n<delombok from=\"src\" to=\"out\" encoding=\"UTF-8\"/>","handlingStrategy":"validation","validationCode":"if (encoding != null && !java.nio.charset.Charset.isSupported(encoding.trim()))\n    throw new BuildException(\"Unsupported charset: \" + encoding);","typeGuard":null,"tryCatchPattern":"catch (BuildException e) { if (e.getMessage().startsWith(\"Unknown charset\")) { /* fix encoding attribute to canonical name */ } throw e; }","preventionTips":["Use canonical JVM charset names (UTF-8, ISO-8859-1)","Call Charset.isSupported() before deploying new encodings","Omit encoding to fall back to the platform default when unsure"],"tags":["ant","charset","encoding","build"],"backgroundTag":"invalid-argument-value","analyzedSha":"6d6a3e9fec0a9555702561fbeb8eac836575116e","analyzedAt":"2026-09-07T23:18:01.841Z","contentChangedAt":"2026-09-07T23:18:01.841Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}