openjdk/jdk · error · BuildException

CompileProperties failed.

Error message

CompileProperties failed.

What it means

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.

Source

Thrown at make/langtools/tools/anttasks/CompilePropertiesTask.java:101

                    // grained enough; in practice, it is better to use ">=".
                    if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified())
                        continue;
                    destFile.getParentFile().mkdirs();
                    mainOpts.add("-compile");
                    mainOpts.add(srcFile.getPath());
                    mainOpts.add(destFile.getPath());
                    mainOpts.add(superclass);
                    count++;
                }
            }
        }
        if (mainOpts.size() > 0) {
            log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO);
            CompileProperties cp = new CompileProperties();
            cp.setLog(log);
            boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()]));
            if (!ok)
                throw new BuildException("CompileProperties failed.");
        }
    }

    private Path srcDirs;
    private File destDir;
    private String superclass = "java.util.ListResourceBundle";
}

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Re-run the Ant target with -verbose / -debug: CompileProperties logs the offending file and reason via the injected log before returning false.
  2. Inspect each .properties file that changed recently for duplicate keys, malformed \u escapes, or stray characters; fix them.
  3. Delete the gensrc destination directory (build/gensrc) so all resource files regenerate from a clean state.
  4. Verify the destDir is writable and the srcDirs path attributes in the build.xml point at existing directories.

Example fix

# before (broken properties: duplicate key)
MyPanel.ok=OK
MyPanel.ok=Sure

# after
MyPanel.ok=OK
MyPanel.confirm=Sure
Defensive patterns

Strategy: validation

Validate before calling

// before invoking the task/tool, screen the properties files
for (Path p : Files.newDirectoryStream(srcDir, "**/*.properties")) {
    try (BufferedReader r = Files.newBufferedReader(p, StandardCharsets.ISO_8859_1)) {
        Set<String> seen = new HashSet<>();
        String line;
        while ((line = r.readLine()) != null) {
            line = line.trim();
            if (line.isEmpty() || line.startsWith("#")) continue;
            String key = line.substring(0, line.indexOf('=')).trim();
            if (!seen.add(key)) throw new IllegalStateException(p + " duplicate key " + key);
            for (int i = 0; i < line.length() - 1; i++)
                if (line.charAt(i) == '\\' && line.charAt(i + 1) == 'u'
                    && (i + 6 > line.length() || !line.substring(i + 2, i + 6).matches("[0-9a-fA-F]{4}")))
                    throw new IllegalStateException(p + " bad \\u escape at " + i);
        }
    }
}

Try / catch

try {
    compilePropertiesTask.execute();
} catch (BuildException e) {
    // the real reason was already logged via the Project logger; surface it
    throw new BuildException("CompileProperties failed; see log lines above for the offending file", e.getCause());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14). Data as JSON: /api/errors/b66567d9d6e6a602. Report an issue: GitHub.