JDK-8277301 : ciReplay: tag mismatch: wrong class files?
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 18
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-11-16
  • Updated: 2025-09-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
ReplayCompile could fail with following errors when parsing replay_pid files:
 1 - Failed on hidden class with comment expected
 2 - Failed on line not properly terminated
 3 - Failed on tag mismatch: wrong class files?
 4 - Failed on unknown command
     
In case of error 4 the unknown command is "anceKlass". Looks like 'instanceKlass' command was cut of for some reason. Could it be because of JDK-8276965? 


To reproduce above issues run java/lang/String/CompactString/CharAt.java and java/lang/String/CompactString/CompareTo.java tests without any VM flags just to get these tests compiled:
> $JT_HOME/bin/jtreg -jdk:$TESTED_JDK -retain:all open/test/jdk/java/lang/String/CompactString/CharAt.java
  $JT_HOME/bin/jtreg -jdk:$TESTED_JDK -retain:all open/test/jdk/java/lang/String/CompactString/CompareTo.java


Then set classpath like:
> CLASSPATH="JTwork/classes/java/lang/String/CompactString/CharAt.d:JTwork/classes/java/lang/String/CompactString/CompareTo.d:$JT_HOME/lib/testng.jar:$JT_HOME/lib/jcommander.jar:$JT_HOME/lib/guice.jar:$JT_HOME/lib/javatest.jar:$JT_HOME/lib/jtreg.jar"

And then run replay files one by one
> $TESTED_JDK/bin/java -cp $CLASSPATH  -XX:+ReplayCompiles -XX:ReplayDataFile=replay_bug_[N].log

Note, replay_bug_N.log file is used to reproduce issue N.
Comments
I don't know of a good workaround. You could try editing the replay file so the constant pool tag in the error message matches, but if the problem is because the constant pool order is not deterministic because it wasn't loaded by CDS, when it's a moving target that can change on every run.
24-09-2025

Is there any workaround for the issue when replaying compiles?
23-09-2025

As [~dlong] explained in https://bugs.openjdk.java.net/browse/JDK-8276969?focusedCommentId=14458975&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14458975, the problem is that the order of method related constant pool entries differs between runs. I debugged this in-depth because we hit this with Valhalla where it triggered reliably due to CDS being disabled (see JDK-8308756 for details). The root cause is in Method::sort_methods where methods are sorted by symbol addresses (see Symbol::fast_compare) which might obviously differ between runs. This only affects klasses that get extra slots added by DefaultMethods::generate_default_methods. If they are loaded from the CDS archive, the order is preserved. I attached a minimal replay file that reproduces this: java -XX:+ReplayCompiles -XX:ReplayDataFile=test.log -Xshare:off Error while parsing line 5 at position 220: tag mismatch: wrong class files? Failed on tag mismatch: wrong class files?
02-06-2023

I can reliably reproduce this with test/hotspot/jtreg/compiler/ciReplay/TestInliningProtectionDomain.java and -Xshare:off: java.lang.RuntimeException: Unexpected exit code for positive case: [-XX:LogFile=hotspot_replay.log, -XX:+LogCompilation, -XX:CompileCommand=option,compiler.ciReplay.ProtectionDomainTestCompiledBefore::test,bool,PrintInlining,true]: expected 1 to equal 0 at jdk.test.lib.Asserts.fail(Asserts.java:594) at jdk.test.lib.Asserts.assertEquals(Asserts.java:205) at jdk.test.lib.Asserts.assertEQ(Asserts.java:178) at compiler.ciReplay.CiReplayBase.positiveTest(CiReplayBase.java:271) at compiler.ciReplay.TestInliningProtectionDomain.testAction(TestInliningProtectionDomain.java:59) at compiler.ciReplay.DumpReplayBase.runTest(DumpReplayBase.java:54) at compiler.ciReplay.InliningBase.runTest(InliningBase.java:54) at compiler.ciReplay.TestInliningProtectionDomain.<init>(TestInliningProtectionDomain.java:54) at compiler.ciReplay.TestInliningProtectionDomain.main(TestInliningProtectionDomain.java:43) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:578) at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138) at java.base/java.lang.Thread.run(Thread.java:1583) The root cause is: [...] Resolving klass java/lang/reflect/AccessibleObject at 2 Resolving klass java/lang/reflect/Method at 2 Resolving klass java/lang/reflect/Executable at 36 Warning: entry was unresolved in the replay data: java/util/concurrent/ConcurrentHashMap$ForwardingNode Error while parsing line 644 at position 220: tag mismatch: wrong class files? Failed on tag mismatch: wrong class files?
02-06-2023

I believe the only remaining issue out of the 4 is this one: 3 - Failed on tag mismatch: wrong class files? so I'm updating the synopsis.
28-01-2022

"Failed on hidden class with comment expected" is due to printing in ciEnv::dump_replay_data_helper that doesn't append comment for hidden classes. I filed a new bug: JDK-8277423
18-11-2021

Dean [~dlong], to reproduce "Failed on hidden class with comment expected" do for example: - Copy open/test/jdk/java/lang/Math/MultiplicationTests.java to some local dir - Apply the following changes so you don't depend on any libraries: 36c36 < import jdk.test.lib.RandomFactory; --- > import java.util.Random; 45c45 < private static java.util.Random rnd = RandomFactory.getRandom(); --- > private static java.util.Random rnd = new Random(0); - compile $TESTED_JDK/bin/javac MultiplicationTests.java - run $TESTED_JDK/bin/java -XX:ReplaySuppressInitializers=0 -XX:+ReplayCompiles -XX:ReplayDataFile=replay_bug8277301_01b.log To generate the bad replay file do: > $TESTED_JDK/bin/java -XX:ReplaySuppressInitializers=0 -Xbatch -XX:CICrashAt=39 MultiplicationTests In case -XX:CICrashAt=39 doesn't lead to bad replay file run: > java -XX:ReplaySuppressInitializers=0 -XX:CompileCommand=option,*::*,DumpReplay -Xbatch MultiplicationTests and see when bad replay file is generated.
18-11-2021

For the tag mismatch error, see this comment: https://bugs.openjdk.java.net/browse/JDK-8276969?focusedCommentId=14458975&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14458975 It may be the same problem as JDK-8012384. I was hoping the "hidden class with comment expected" error was caused by JDK-8277316. The problem must be when the replay file is written, so just having the bad replay file is not enough. [~epavlova] I need a way to reproduce the problem in gdb to make progress.
18-11-2021

.jtr files generated by jtreg has rerun blocks which by mistake have VM flags added to javac but not to java command. As result -XX:ReplaySuppressInitializers=0 was not used when rerunning tests. -XX:ReplaySuppressInitializers=0 is needed to workaround existing ciReplay issues. I did rerun testing with proper flags and the failures 2 - Failed on line not properly terminated 4 - Failed on unknown command are not seen anymore. The failures 1 - Failed on hidden class with comment expected 3 - Failed on tag mismatch: wrong class files? are still seen.
18-11-2021

[~dlong], only failure " 4 - Failed on unknown command" seems went away. All other failures are still seen. I will update replay files to reproduce the issues.
18-11-2021

[~epavlova], do any of these failures still reproduce with the latest fixes?
18-11-2021

I filed a new bug for failure 4: JDK-8277316
17-11-2021

[~dlong], to reproduce replay_bug_01.log failure use for example open/test/jdk/java/lang/Math/MultiplicationTests.java - First run it using jtreg just to get all required files compiled - Then modify paths in following script and run it ======= TESTED_JDK=<path to tested jdk> JT_HOME=<path to jtreg> CP="JTwork/classes/java/lang/Math/MultiplicationTests.d:JTwork/classes/test/lib:${JT_HOME}/lib/jtreg.jar" ${TESTED_JDK}/bin/java \ -classpath $CP -XX:CompileCommand=option,*::*,DumpReplay -XX:ReplaySuppressInitializers=0 MultiplicationTests for i in `ls replay_pid*` do echo $i ${TESTED_JDK}/bin/java -classpath $CP -XX:ReplaySuppressInitializers=0 -XX:+ReplayCompiles -XX:ReplayDataFile=$i echo done =======
17-11-2021

ILW = various uncommon replay failures = MMH = P3
17-11-2021

[~epavlova] I need more details on the replay_bug_03.log failure. When I run it, I get a mismatch on a testng class, which probably means my jtreg version is different from yours.
17-11-2021

The replay_bug_02.log failure is because replay isn't actually resolving the MethodHandle in the constant pool. I filed a new bug: JDK-8277310.
17-11-2021

[~dlong], interesting. Basically the test is just run with -XX:CompileCommand=option,*::*,DumpReplay . jdk/java/lang/String/CompactString/* are testng tests. May be there is something related to testng which causes some concurrency issue, I will look. I will also try to see if these issues are seen in non testng tests.
17-11-2021

replay_bug_01.log doesn't have a comment after the hidden class on line 6 replay_bug_04.log has 2 compile lines. It looks like a replay file was written on top of an existing replay file, but not truncated. [~epavlova], what are the steps to create these corrupted replay files?
16-11-2021