{"record":{"id":"b66567d9d6e6a602","repo":"openjdk/jdk","slug":"compileproperties-failed","errorCode":null,"errorMessage":"CompileProperties failed.","messagePattern":"CompileProperties failed\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"make/langtools/tools/anttasks/CompilePropertiesTask.java","lineNumber":101,"sourceCode":"                    // grained enough; in practice, it is better to use \">=\".\n                    if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified())\n                        continue;\n                    destFile.getParentFile().mkdirs();\n                    mainOpts.add(\"-compile\");\n                    mainOpts.add(srcFile.getPath());\n                    mainOpts.add(destFile.getPath());\n                    mainOpts.add(superclass);\n                    count++;\n                }\n            }\n        }\n        if (mainOpts.size() > 0) {\n            log(\"Generating \" + count + \" resource files to \" + destDir, Project.MSG_INFO);\n            CompileProperties cp = new CompileProperties();\n            cp.setLog(log);\n            boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()]));\n            if (!ok)\n                throw new BuildException(\"CompileProperties failed.\");\n        }\n    }\n\n    private Path srcDirs;\n    private File destDir;\n    private String superclass = \"java.util.ListResourceBundle\";\n}\n","sourceCodeStart":83,"sourceCodeEnd":109,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/make/langtools/tools/anttasks/CompilePropertiesTask.java#L83-L109","documentation":"Thrown by the CompileProperties Ant task when the in-process invocation of the CompileProperties tool reports failure (run() returned false). CompileProperties converts .properties files into Java ListResourceBundle source files during the langtools build, so this error means one or more resource files could not be parsed or generated.","triggerScenarios":"Running the Ant 'generate-properties' style target when a .properties file under src/share/classes is malformed (bad unicode escape, duplicate key at same level, unescaped colon), a source file is unreadable, or the destination directory cannot be written. The task only throws when mainOpts is non-empty, i.e. at least one properties file was deemed out of date by the timestamp filter.","commonSituations":"JDK/langtools build after editing or adding a resource bundle; a properties file saved with a BOM or non-ISO-8859-1/Latin-1 encoding; a stale or read-only gensrc output directory from a previous interrupted build.","solutions":["Re-run the Ant target with -verbose / -debug: CompileProperties logs the offending file and reason via the injected log before returning false.","Inspect each .properties file that changed recently for duplicate keys, malformed \\u escapes, or stray characters; fix them.","Delete the gensrc destination directory (build/gensrc) so all resource files regenerate from a clean state.","Verify the destDir is writable and the srcDirs path attributes in the build.xml point at existing directories."],"exampleFix":"# before (broken properties: duplicate key)\nMyPanel.ok=OK\nMyPanel.ok=Sure\n\n# after\nMyPanel.ok=OK\nMyPanel.confirm=Sure","handlingStrategy":"validation","validationCode":"// before invoking the task/tool, screen the properties files\nfor (Path p : Files.newDirectoryStream(srcDir, \"**/*.properties\")) {\n    try (BufferedReader r = Files.newBufferedReader(p, StandardCharsets.ISO_8859_1)) {\n        Set<String> seen = new HashSet<>();\n        String line;\n        while ((line = r.readLine()) != null) {\n            line = line.trim();\n            if (line.isEmpty() || line.startsWith(\"#\")) continue;\n            String key = line.substring(0, line.indexOf('=')).trim();\n            if (!seen.add(key)) throw new IllegalStateException(p + \" duplicate key \" + key);\n            for (int i = 0; i < line.length() - 1; i++)\n                if (line.charAt(i) == '\\\\' && line.charAt(i + 1) == 'u'\n                    && (i + 6 > line.length() || !line.substring(i + 2, i + 6).matches(\"[0-9a-fA-F]{4}\")))\n                    throw new IllegalStateException(p + \" bad \\\\u escape at \" + i);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    compilePropertiesTask.execute();\n} catch (BuildException e) {\n    // the real reason was already logged via the Project logger; surface it\n    throw new BuildException(\"CompileProperties failed; see log lines above for the offending file\", e.getCause());\n}","preventionTips":["Keep resource files in ISO-8859-1 with \\uXXXX escapes; do not save them as UTF-8 with BOM.","Add a CI lint step that rejects duplicate keys in .properties files.","Clean the gensrc directory after switching branches so stale bundles never feed the task."],"tags":["ant","build","properties","i18n","resource-bundle"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}