oracle/graal · error · ExperimentParserTypeError
Failed to parse experiment {experimentId} in {resource}: exp
Error message
Failed to parse experiment {experimentId} in {resource}: expected {objectName} to be an instance of {expectedType} but got "{actualObject}" What it means
The central type-narrowing check of ExperimentJSONParser: JSONLiteral.asInstanceOf(clazz) throws ExperimentParserTypeError when the decoded JSON value is not of the requested Java type. Every asInt/asString/asMap/asList/asLong/asBoolean call on log JSON funnels through it, so any schema mismatch in a proftool or optimization-log JSON surfaces here with the experiment id, symbolic file path, offending property name, expected type, and actual value.
Source
Thrown at compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/parser/ExperimentJSONParser.java:72
*/
private final Object object;
/**
* The name of the literal.
*/
private final String objectName;
private JSONLiteral(Object object, String objectName) {
this.object = object;
this.objectName = objectName;
}
@SuppressWarnings("unchecked")
private <T> T asInstanceOf(Class<T> clazz) throws ExperimentParserTypeError {
if (clazz.isInstance(object)) {
return (T) object;
}
throw new ExperimentParserTypeError(experimentId, file.getSymbolicPath(), objectName, clazz, object);
}
private <T> T asNullableInstanceOf(Class<T> clazz) throws ExperimentParserTypeError {
if (object == null) {
return null;
}
return asInstanceOf(clazz);
}
public boolean isNull() {
return object == null;
}
public String asString() throws ExperimentParserTypeError {
return asInstanceOf(String.class);
}
public boolean asBoolean() throws ExperimentParserTypeError {View on GitHub (pinned to a66e9ccd1d)
Solutions
- Use a proftool output and optimization logs generated by the same GraalVM build as the profdiff you run.
- Inspect the reported {resource}/{objectName} in the JSON and make its type match the schema (integers unquoted, maps as objects, arrays as arrays).
- Regenerate the experiment data rather than patching JSON by hand.
Defensive patterns
Strategy: try-catch
Validate before calling
// Lightweight schema check before full parsing
Object totalPeriod = proftoolMap.get("total_period");
if (!(totalPeriod instanceof Number)) throw new IllegalStateException("total_period must be numeric"); Try / catch
try {
new ExperimentJSONParser(experimentId, fileView).parse();
} catch (ExperimentParserTypeError e) {
// message: experiment, resource, property, expected vs actual type; fix that JSON field
} Prevention
- Generate and parse logs with the same GraalVM version.
- Do not edit JSON logs with tools that retype values (quoting numbers).
When it happens
Trigger: A proftool JSON where 'total_period' is a string, an optimization tree node whose 'name' is a number, a list property holding an object, etc. — any asX() accessor invoked on a JSON literal of a different type.
Common situations: Mixing proftool/optimization logs from a GraalVM version whose JSON schema differs from the profdiff version parsing them; hand-modified logs; third-party tools writing the log fields with different types.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse experiment {experimentId} in {resource}: exp
- Failed to parse experiment {experimentId} in compilation uni
- Failed to parse experiment {experimentId} in {resource}: {me
- Failed to serialize ${op} due to: ${cause}
- Unknown class ${className} for constant${value}
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/5531a1cf7e9da813.
Report an issue: GitHub.