Problem description:
See JDK-8168703 for more details. In summary:
In order to support a wide range of metaspace size, AOT forces klass_shift to 3. However, in JDK 9, CDS shared string regions will always be dumped with klass_shift of 0 (because CompressedClassSpaceSize has a hard limit of 3GB, and during archive creation, the klass space is always based from 0x80000000). As a result, the shared string regions will fail to load when AOT is enabled.
Possible fixes:
[Option A] Change CDS to be similar to AOT (JDK-8173054). Always force _narrow_klass._shift to be 3. This will allow CDS to be compatible with different sizes of heap and metaspace settings. The downside is small performance degradation when AOT is not used.
[Option B] In the CDS archive, create 2 separate string regions, one for klasshift=0, and another for klasshift=3. Map the correct one according to runtime settings.