8207263: Store the Configuration for system modules into CDS archive

Archive boot layer Configuration.

Reviewed-by: redestad, iklam, ccheung
This commit is contained in:
Jiangli Zhou 2018-08-10 00:35:57 -04:00
parent 5858a507f4
commit a5d14313f5
13 changed files with 353 additions and 45 deletions

View file

@ -41,8 +41,10 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.misc.VM;
import jdk.internal.module.ModuleReferenceImpl;
import jdk.internal.module.ModuleTarget;
import jdk.internal.vm.annotation.Stable;
/**
* A configuration that is the result of <a href="package-summary.html#resolution">
@ -103,7 +105,17 @@ import jdk.internal.module.ModuleTarget;
public final class Configuration {
// @see Configuration#empty()
private static final Configuration EMPTY_CONFIGURATION = new Configuration();
// EMPTY_CONFIGURATION may be initialized from the CDS archive.
private static @Stable Configuration EMPTY_CONFIGURATION;
static {
// Initialize EMPTY_CONFIGURATION from the archive.
VM.initializeFromArchive(Configuration.class);
// Create a new empty Configuration if there is no archived version.
if (EMPTY_CONFIGURATION == null) {
EMPTY_CONFIGURATION = new Configuration();
}
}
// parent configurations, in search order
private final List<Configuration> parents;

View file

@ -36,6 +36,7 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.VM;
import jdk.internal.vm.annotation.Stable;
/**
@ -409,7 +410,15 @@ class ImmutableCollections {
static final class ListN<E> extends AbstractImmutableList<E>
implements Serializable {
static final List<?> EMPTY_LIST = new ListN<>();
// EMPTY_LIST may be initialized from the CDS archive.
static @Stable List<?> EMPTY_LIST;
static {
VM.initializeFromArchive(ListN.class);
if (EMPTY_LIST == null) {
EMPTY_LIST = new ListN<>();
}
}
@Stable
private final E[] elements;
@ -567,7 +576,15 @@ class ImmutableCollections {
static final class SetN<E> extends AbstractImmutableSet<E>
implements Serializable {
static final Set<?> EMPTY_SET = new SetN<>();
// EMPTY_SET may be initialized from the CDS archive.
static @Stable Set<?> EMPTY_SET;
static {
VM.initializeFromArchive(SetN.class);
if (EMPTY_SET == null) {
EMPTY_SET = new SetN<>();
}
}
@Stable
final E[] elements;
@ -772,7 +789,15 @@ class ImmutableCollections {
*/
static final class MapN<K,V> extends AbstractImmutableMap<K,V> {
static final Map<?,?> EMPTY_MAP = new MapN<>();
// EMPTY_MAP may be initialized from the CDS archive.
static @Stable Map<?,?> EMPTY_MAP;
static {
VM.initializeFromArchive(MapN.class);
if (EMPTY_MAP == null) {
EMPTY_MAP = new MapN<>();
}
}
@Stable
final Object[] table; // pairs of key, value