apache/dubbo · error · IllegalStateException
Compilation failed. class: {}, diagnostics: {}
Error message
Compilation failed. class: {}, diagnostics: {} What it means
Thrown by JdkCompiler.doCompile when the JSR-199 compilation task returns null or false, indicating the source did not compile. The bundled diagnosticCollector.getDiagnostics() output lists the compiler errors (syntax, unresolved symbols, etc.).
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/JdkCompiler.java:127
@Override
public Class<?> doCompile(ClassLoader ignored, String name, String sourceCode) throws Throwable {
int i = name.lastIndexOf('.');
String packageName = i < 0 ? "" : name.substring(0, i);
String className = i < 0 ? name : name.substring(i + 1);
JavaFileObjectImpl javaFileObject = new JavaFileObjectImpl(className, sourceCode);
javaFileManager.putFileForInput(
StandardLocation.SOURCE_PATH, packageName, className + ClassUtils.JAVA_EXTENSION, javaFileObject);
Boolean result = compiler.getTask(
null,
javaFileManager,
diagnosticCollector,
options,
null,
Collections.singletonList(javaFileObject))
.call();
if (result == null || !result) {
throw new IllegalStateException(
"Compilation failed. class: " + name + ", diagnostics: " + diagnosticCollector.getDiagnostics());
}
return classLoader.loadClass(name);
}
private static final class JavaFileObjectImpl extends SimpleJavaFileObject {
private final CharSequence source;
private ByteArrayOutputStream bytecode;
public JavaFileObjectImpl(final String baseName, final CharSequence source) {
super(ClassUtils.toURI(baseName + ClassUtils.JAVA_EXTENSION), Kind.SOURCE);
this.source = source;
}
JavaFileObjectImpl(final String name, final Kind kind) {
super(ClassUtils.toURI(name), kind);
source = null;View on GitHub (pinned to 3a3043227f)
Solutions
- Inspect the diagnostics list in the exception message — each Diagnostic names the file, line, and error.
- Fix the specific syntax/type error reported by the compiler.
- Ensure all referenced classes are available to the compilation classloader.
- Run on a full JDK (not a JRE) so javax.tools.ToolProvider.getSystemJavaCompiler is non-null.
Defensive patterns
Strategy: try-catch
Try / catch
try {
compiler.doCompile(classLoader, name, source);
} catch (IllegalStateException e) {
// parse diagnostics in e.getMessage(); fix source/classpath
} Prevention
- Inspect the diagnostics list in the exception to find each compiler error.
- Ensure all referenced classes are on the compilation classpath.
- Run on a full JDK (not a JRE) so the system compiler is available.
- Validate generated source for obvious syntax issues before compiling.
When it happens
Trigger: The source code passed to JdkCompiler (the default SPI compiler when running on a JDK) contains a syntax error, references an undefined type/member, or violates Java language rules, so the compiler task returns false.
Common situations: Generated Adaptive/SPI extension source is invalid. A class referenced by the generated source is not on the classpath. Running on a JRE (not JDK) where the compiler tool is unavailable can also yield a failed task. Source/target version mismatch with the running JDK.
Related errors
- No such class name in {}
- Failed to compile class, cause: {}, class: {}, code: {} , s
- The java code not endsWith "}", code: {}
- source == null
- The method %s of interface %s is not adaptive method!
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/6b514e705b2c4edb.
Report an issue: GitHub.