Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java
41159 views
1
/*
2
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
package jdk.internal.module;
26
27
import java.util.function.Function;
28
import java.lang.module.Configuration;
29
import java.lang.module.ModuleFinder;
30
import jdk.internal.misc.CDS;
31
32
/**
33
* Used by ModuleBootstrap for archiving the configuration for the boot layer,
34
* and the system module finder.
35
*/
36
class ArchivedModuleGraph {
37
private static ArchivedModuleGraph archivedModuleGraph;
38
39
private final boolean hasSplitPackages;
40
private final boolean hasIncubatorModules;
41
private final ModuleFinder finder;
42
private final Configuration configuration;
43
private final Function<String, ClassLoader> classLoaderFunction;
44
45
private ArchivedModuleGraph(boolean hasSplitPackages,
46
boolean hasIncubatorModules,
47
ModuleFinder finder,
48
Configuration configuration,
49
Function<String, ClassLoader> classLoaderFunction) {
50
this.hasSplitPackages = hasSplitPackages;
51
this.hasIncubatorModules = hasIncubatorModules;
52
this.finder = finder;
53
this.configuration = configuration;
54
this.classLoaderFunction = classLoaderFunction;
55
}
56
57
ModuleFinder finder() {
58
return finder;
59
}
60
61
Configuration configuration() {
62
return configuration;
63
}
64
65
Function<String, ClassLoader> classLoaderFunction() {
66
return classLoaderFunction;
67
}
68
69
boolean hasSplitPackages() {
70
return hasSplitPackages;
71
}
72
73
boolean hasIncubatorModules() {
74
return hasIncubatorModules;
75
}
76
77
/**
78
* Returns the ArchivedModuleGraph for the given initial module.
79
*/
80
static ArchivedModuleGraph get(String mainModule) {
81
ArchivedModuleGraph graph = archivedModuleGraph;
82
// We only allow the unnamed module (default) case for now
83
if (mainModule == null) {
84
return graph;
85
} else {
86
return null;
87
}
88
}
89
90
/**
91
* Archive the module graph for the given initial module.
92
*/
93
static void archive(boolean hasSplitPackages,
94
boolean hasIncubatorModules,
95
ModuleFinder finder,
96
Configuration configuration,
97
Function<String, ClassLoader> classLoaderFunction) {
98
archivedModuleGraph = new ArchivedModuleGraph(hasSplitPackages,
99
hasIncubatorModules,
100
finder,
101
configuration,
102
classLoaderFunction);
103
}
104
105
static {
106
CDS.initializeFromArchive(ArchivedModuleGraph.class);
107
}
108
}
109
110