{"record":{"id":"779c1f9a3498e4d3","repo":"oracle/graal","slug":"failed-to-parse-experiment-experimentid-in-reso","errorCode":null,"errorMessage":"Failed to parse experiment {experimentId} in {resource}: expected position to be an instance of Integer but got \"{actualObject}\"","messagePattern":"Failed to parse experiment (.+?) in (.+?): expected position to be an instance of Integer but got \"(.+?)\"","errorType":"exception","errorClass":"ExperimentParserTypeError","httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/parser/CompilationUnitTreeParser.java","lineNumber":157,"sourceCode":"            } else {\n                optimizationPhase.addChild(parseOptimizationPhase(childMap));\n            }\n        }\n        return optimizationPhase;\n    }\n\n    private Optimization parseOptimization(ExperimentJSONParser.JSONMap optimization) throws ExperimentParserTypeError {\n        String optimizationName = optimization.property(OptimizationLogImpl.OPTIMIZATION_NAME_PROPERTY).asString();\n        String eventName = optimization.property(OptimizationLogImpl.EVENT_NAME_PROPERTY).asString();\n        ExperimentJSONParser.JSONLiteral positionObject = optimization.property(OptimizationLogImpl.POSITION_PROPERTY);\n        Position position = Position.EMPTY;\n        if (!positionObject.isNull()) {\n            MapCursor<String, Object> cursor = positionObject.asMap().getInnerMap().getEntries();\n            List<String> methodNames = new ArrayList<>();\n            List<Integer> bcis = new ArrayList<>();\n            while (cursor.advance()) {\n                if (!(cursor.getValue() instanceof Integer)) {\n                    throw new ExperimentParserTypeError(experimentId, fileView.getSymbolicPath(), OptimizationLogImpl.POSITION_PROPERTY, Integer.class, cursor.getValue());\n                }\n                methodNames.add(Method.removeMethodVariantKey(cursor.getKey()));\n                bcis.add((Integer) cursor.getValue());\n            }\n            position = Position.create(methodNames, bcis);\n        }\n        EconomicMap<String, Object> properties = optimization.getInnerMap();\n        properties.removeKey(OptimizationLogImpl.OPTIMIZATION_NAME_PROPERTY);\n        properties.removeKey(OptimizationLogImpl.EVENT_NAME_PROPERTY);\n        properties.removeKey(OptimizationLogImpl.POSITION_PROPERTY);\n        return new Optimization(optimizationName, eventName, position, properties.isEmpty() ? null : properties);\n    }\n}\n","sourceCodeStart":139,"sourceCodeEnd":171,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/parser/CompilationUnitTreeParser.java#L139-L171","documentation":"While converting an optimization's position map, parseOptimization throws ExperimentParserTypeError when a position value is not a java.lang Integer — the optimization log encodes each inlining position as method-name -> bci, and every bci must be a JSON number that decodes to Integer. The error names the experiment, file, the 'position' property, the expected type and the offending object.","triggerScenarios":"An optimization log whose position map contains a non-integer bci, e.g. \"position\": {\"m(int)\": \"42\"} (string), a float bci, or a null. Usually produced by a hand-edited log or a mismatched/buggy optimization-log writer version.","commonSituations":"Editing or programmatically generating optimization logs; JSON serializers that quote numbers or emit doubles; mixing logs produced by one GraalVM version with a profdiff from another whose schema drifted.","solutions":["Regenerate the optimization log with the matching GraalVM/profdiff version instead of editing it by hand.","If post-processing logs, keep bcis as unquoted JSON integers.","Validate the file: every entry of each 'position' object must map a string method name to an integer."],"exampleFix":"// before (log content)\n{\"name\":\"inlining\",\"event\":\"...\",\"position\":{\"m(int)\":\"7\"}}\n// after\n{\"name\":\"inlining\",\"event\":\"...\",\"position\":{\"m(int)\":7}}","handlingStrategy":"validation","validationCode":"// Validate a position object before handing the log to profdiff\nObject pos = optimization.get(\"position\");\nif (pos instanceof Map<?,?> m) {\n    for (Object v : m.values()) if (!(v instanceof Integer)) throw new IllegalArgumentException(\"Non-integer bci: \" + v);\n}","typeGuard":"static boolean positionsAreIntegerBcis(Map<?,?> position) {\n    return position.values().stream().allMatch(v -> v instanceof Integer);\n}","tryCatchPattern":"try {\n    parser.parse();\n} catch (ExperimentParserTypeError e) {\n    // message names file, 'position', expected Integer, and the actual value; fix the JSON\n}","preventionTips":["Never hand-edit optimization logs; regenerate them.","Match the GraalVM version that produced the logs with the profdiff that parses them."],"tags":["profdiff","json","type-mismatch","optimization-log"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}