RFR: 8251261: CDS dumping should not clear states in live classes

Ioi Lam iklam at openjdk.java.net
Thu Sep 17 19:08:17 UTC 2020


We had an issue when CDS dumped a static archive (java -Xshare:dump), it would call `Klass::remove_unshareable_info()`
too early. In one of the test failures, ZGC was still scanning the heap and stepped on a class whose mirror has been
removed.

The fix is to avoid modifying the states of the Java classes during -Xshare:dump. Instead, we call
`Klass::remove_unshareable_info()` only on the **copy** of the classes which are written into the archive. It's safe to
do so because these copies are visible only to the CDS dumping code. They aren't accessible by the GC or any other
subsystems.

It turns out that we were already doing this for the dynamic archive. So I just generalized the code in
dynamicArchive.cpp and moved it to archiveBuilder.cpp. So this PR is one step forward for [JDK-8234693 Consolidate CDS
static and dynamic archive dumping code](https://bugs.openjdk.java.net/browse/JDK-8234693).

I also fixed another case where we modify the global VM state -- I removed `Universe::clear_basic_type_mirrors()`.

----

We are still modifying some global VM states (such as SystemDictionary::_well_known_klasses). They seem harmless now,
but we might have to do more fixes in the future.

-------------

Commit messages:
 - 8251261: CDS dumping should not clear states in live classes

Changes: https://git.openjdk.java.net/jdk/pull/227/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=227&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8251261
  Stats: 214 lines in 9 files changed: 75 ins; 128 del; 11 mod
  Patch: https://git.openjdk.java.net/jdk/pull/227.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/227/head:pull/227

PR: https://git.openjdk.java.net/jdk/pull/227


More information about the hotspot-runtime-dev mailing list