Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/tools/sjavac/Module.java
38899 views
1
/*
2
* Copyright (c) 2012, 2013, 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
26
package com.sun.tools.sjavac;
27
28
import java.io.File;
29
import java.net.URI;
30
import java.util.HashMap;
31
import java.util.List;
32
import java.util.Map;
33
import java.util.Set;
34
35
/**
36
* The module is the root of a set of packages/sources/artifacts.
37
* At the moment there is only one module in use, the empty/no-name/default module.
38
*
39
* <p><b>This is NOT part of any supported API.
40
* If you write code that depends on this, you do so at your own
41
* risk. This code and its internal interfaces are subject to change
42
* or deletion without notice.</b></p>
43
*/
44
public class Module implements Comparable<Module> {
45
private String name;
46
private String dirname;
47
private Map<String,Package> packages = new HashMap<String,Package>();
48
private Map<String,Source> sources = new HashMap<String,Source>();
49
private Map<String,File> artifacts = new HashMap<String,File>();
50
51
public Module(String n, String dn) {
52
name = n;
53
dirname = n;
54
}
55
56
public String name() { return name; }
57
public String dirname() { return dirname; }
58
public Map<String,Package> packages() { return packages; }
59
public Map<String,Source> sources() { return sources; }
60
public Map<String,File> artifacts() { return artifacts; }
61
62
@Override
63
public boolean equals(Object o) {
64
return (o instanceof Module) && name.equals(((Module)o).name);
65
}
66
67
@Override
68
public int hashCode() {
69
return name.hashCode();
70
}
71
72
@Override
73
public int compareTo(Module o) {
74
return name.compareTo(o.name);
75
}
76
77
public void save(StringBuilder b) {
78
b.append("M ").append(name).append(":").append("\n");
79
Package.savePackages(packages, b);
80
}
81
82
public static Module load(String l) {
83
int cp = l.indexOf(':',2);
84
if (cp == -1) return null;
85
String name = l.substring(2,cp);
86
return new Module(name, "");
87
}
88
89
public static void saveModules(Map<String,Module> ms, StringBuilder b)
90
{
91
for (Module m : ms.values()) {
92
m.save(b);
93
}
94
}
95
96
public void addPackage(Package p) {
97
packages.put(p.name(), p);
98
}
99
100
public Package lookupPackage(String pkg) {
101
Package p = packages.get(pkg);
102
if (p == null) {
103
p = new Package(this, pkg);
104
packages.put(pkg, p);
105
}
106
return p;
107
}
108
109
public void addSource(String pkg, Source src) {
110
Package p = lookupPackage(pkg);
111
src.setPackage(p);
112
p.addSource(src);
113
sources.put(src.file().getPath(), src);
114
}
115
116
public Source lookupSource(String path) {
117
return sources.get(path);
118
}
119
120
public void addArtifacts(String pkg, Set<URI> as) {
121
Package p = lookupPackage(pkg);
122
for (URI u : as) {
123
p.addArtifact(new File(u));
124
}
125
}
126
127
public void setDependencies(String pkg, Set<String> deps) {
128
Package p = lookupPackage(pkg);
129
p.setDependencies(deps);
130
}
131
132
public void setPubapi(String pkg, List<String> ps) {
133
Package p = lookupPackage(pkg);
134
p.setPubapi(ps);
135
}
136
137
public boolean hasPubapiChanged(String pkg, List<String> ps) {
138
Package p = lookupPackage(pkg);
139
return p.hasPubapiChanged(ps);
140
}
141
}
142
143