Symptom:
When old classes (i.e., class version is lower than 50) are loaded during dynamic CDS dump, they are usually linked during app execution. As part of linking, the class is verified by the old verifier, which is not supported by CDS. As a result, these old classes are not stored in the CDS image. A typical message is like this:
$ java -cp Test.jar -XX:ArchiveClassesAtExit=test.jsa TestApp
...
[warning][cds] Skipping MyOldClass: Old class has been linked.
...
Proposed fix:
Revert the linked old classes to unlinked state, so that they can be verified again during runtime.
This can be done by parsing the class again and storing the newly parsed (but not linked) InstanceKlass into the CDS archive. Something similar to
https://github.com/openjdk/jdk/blob/8e4ef818a90de35ae75e7f82a780653d623bb29c/src/hotspot/share/cds/lambdaFormInvokers.cpp#L186