openjdk/jdk · error

ERROR: Can't open replay file %s

Error message

ERROR: Can't open replay file %s

What it means

ciReplay (the -XX:+ReplayCompiles / -XX:ReplayDataFile=<file> machinery that replays a recorded compilation) failed to open the replay data file: CompileReplay's constructor does os::fopen(filename, "rt") and the result is null. It only prints the error — execution continues and parsing of the null stream fails immediately after, so replay silently does nothing.

Source

Thrown at src/hotspot/share/ci/ciReplay.cpp:151

  char* _bufptr;
  char* _buffer;
  int   _buffer_length;
  ReallocMark _nesting; // Safety checks for arena reallocation

  // "compile" data
  ciKlass* _iklass;
  Method*  _imethod;
  int      _entry_bci;
  int      _comp_level;

 public:
  CompileReplay(const char* filename, TRAPS) {
    _thread = THREAD;
    _loader = Handle(_thread, SystemDictionary::java_system_loader());

    _stream = os::fopen(filename, "rt");
    if (_stream == nullptr) {
      fprintf(stderr, "ERROR: Can't open replay file %s\n", filename);
    }

    _ci_inline_records = nullptr;
    _error_message = nullptr;

    _buffer_length = 32;
    _buffer = NEW_RESOURCE_ARRAY(char, _buffer_length);
    _bufptr = _buffer;

    _imethod = nullptr;
    _iklass  = nullptr;
    _entry_bci  = 0;
    _comp_level = 0;
    _version = 0;

    test();
  }

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Check that the replay data file exists at the exact path passed to -XX:ReplayDataFile (or replay_pid<pid>.log in the cwd for the default)
  2. Use an absolute path: -XX:ReplayDataFile=/abs/path/replay_pid123.log
  3. Verify read permissions on the file for the user running the JVM
  4. If the file was produced by a crashed process, re-run the original failing command from the directory where the crash happened so the relative default path resolves

Example fix

# before
java -XX:+ReplayCompiles -XX:ReplayDataFile=replay_pid123.log Main
# (run from wrong cwd -> file not found)

# after
java -XX:+ReplayCompiles -XX:ReplayDataFile=/home/user/crash/replay_pid123.log Main
Defensive patterns

Strategy: validation

Validate before calling

# Before running replay, verify the data file:
REPLAY=/abs/path/replay_pid$$.log
[ -f "$REPLAY" ] && [ -r "$REPLAY" ] || { echo "missing replay file $REPLAY" >&2; exit 2; }
java -XX:+ReplayCompiles -XX:ReplayDataFile="$REPLAY" -Xbatch Main

Prevention

When it happens

Trigger: Running java with -XX:+ReplayCompiles (or ciReplay::replay_impl triggered via the replay task) where the replay data file (default replay_pid<pid>.log, or the file named by -XX:ReplayDataFile=) does not exist, is not readable, or the path is relative to a different working directory than expected.

Common situations: After a JVM crash the hs-err file asks to run 'java -XX:+ReplayCompiles -XX:ReplayDataFile=replay_pid123.log ...' but the user runs from a different cwd; the replay file was cleaned up; permissions issues in sandboxed CI; typo in the ReplayDataFile path.

Related errors


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