{"record":{"id":"72f26f3bd380285c","repo":"oracle/graal","slug":"injectprofiles-during-replay","errorCode":null,"errorMessage":"injectProfiles during replay","messagePattern":"injectProfiles during replay","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationSupport.java","lineNumber":514,"sourceCode":"        CompilationTaskProduct product = compilationProduct.get();\n        compilationProduct.remove();\n        return product;\n    }\n\n    /**\n     * Injects profiles for the given method during recording.\n     *\n     * @param method the method to inject profiles into\n     * @param includeNormal whether to include normal profiles\n     * @param includeOSR whether to include OSR profiles\n     * @param profilingInfo the profiling information to inject\n     * @throws UnsupportedOperationException if called during replay\n     */\n    public void injectProfiles(ResolvedJavaMethod method, boolean includeNormal, boolean includeOSR, ProfilingInfo profilingInfo) {\n        if (proxies instanceof RecordingCompilationProxies recordingProxies) {\n            recordingProxies.injectProfiles(method, includeNormal, includeOSR, profilingInfo);\n        } else {\n            throw new UnsupportedOperationException(\"injectProfiles during replay\");\n        }\n    }\n}\n","sourceCodeStart":496,"sourceCodeEnd":518,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationSupport.java#L496-L518","documentation":"Thrown by ReplayCompilationSupport.injectProfiles when the method is called while the support object is in replay mode rather than recording mode. Profile injection only makes sense while recording (there is a live RecordingCompilationProxies to store the profiles); during replay, profiles come from the replay file, so the call is rejected with UnsupportedOperationException.","triggerScenarios":"Calling ReplayCompilationSupport.injectProfiles(method, includeNormal, includeOSR, profilingInfo) when the internal proxies field is a replay (non-recording) proxies instance — i.e. running with -Dgraal.ReplayCompilation in replay mode and something in the pipeline still tries to inject fresh profiles.","commonSituations":"Code written for the recording flow being reused during replay; a GraalVM version change where profile injection moved behind this guard; replaying a file while host VM flags enable profile injection paths.","solutions":["Only call injectProfiles during the recording phase (proxies instanceof RecordingCompilationProxies); during replay rely on the recorded data.","Gate the caller on the current mode (recording vs replay) before invoking injectProfiles.","Update both sides (recorder and replayer) to the same GraalVM build so the mode detection is consistent."],"exampleFix":"// before\nsupport.injectProfiles(method, true, true, profilingInfo);\n\n// after\nif (support.isRecording()) {\n    support.injectProfiles(method, true, true, profilingInfo);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// only inject when recording\nif (support.getProxies() instanceof RecordingCompilationProxies) {\n    support.injectProfiles(method, true, true, profilingInfo);\n}","tryCatchPattern":null,"preventionTips":["Gate all profile-injection call sites on recording mode, not replay mode.","During replay, rely exclusively on the data in the replay file."],"tags":["graalvm","replay-compilation","profiles","unsupported-operation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}