Lines 52-57
import java.util.Date;
Link Here
|
52 |
import java.util.Date; |
52 |
import java.util.Date; |
53 |
import java.util.HashMap; |
53 |
import java.util.HashMap; |
54 |
import java.util.HashSet; |
54 |
import java.util.HashSet; |
|
|
55 |
import java.util.LinkedList; |
55 |
import java.util.List; |
56 |
import java.util.List; |
56 |
import java.util.Locale; |
57 |
import java.util.Locale; |
57 |
import java.util.Map; |
58 |
import java.util.Map; |
Lines 93-99
import org.xml.sax.SAXException;
Link Here
|
93 |
* @author Jesse Glick, Jan Pokorsky, Jaroslav Tulach, et al. |
94 |
* @author Jesse Glick, Jan Pokorsky, Jaroslav Tulach, et al. |
94 |
*/ |
95 |
*/ |
95 |
final class NbInstaller extends ModuleInstaller { |
96 |
final class NbInstaller extends ModuleInstaller { |
96 |
|
97 |
|
|
|
98 |
private static final Logger LOG = Logger.getLogger(NbInstaller.class.getName()); |
99 |
|
97 |
/** set of manifest sections for each module */ |
100 |
/** set of manifest sections for each module */ |
98 |
private final Map<Module,Set<ManifestSection>> sections = new HashMap<Module,Set<ManifestSection>>(100); |
101 |
private final Map<Module,Set<ManifestSection>> sections = new HashMap<Module,Set<ManifestSection>>(100); |
99 |
/** ModuleInstall classes for each module that declares one */ |
102 |
/** ModuleInstall classes for each module that declares one */ |
Lines 110-117
final class NbInstaller extends ModuleIn
Link Here
|
110 |
private ModuleManager mgr; |
113 |
private ModuleManager mgr; |
111 |
/** set of permitted core or package dependencies from a module */ |
114 |
/** set of permitted core or package dependencies from a module */ |
112 |
private final Map<Module,Set<String>> kosherPackages = new HashMap<Module,Set<String>>(100); |
115 |
private final Map<Module,Set<String>> kosherPackages = new HashMap<Module,Set<String>>(100); |
113 |
/** Package prefixes passed as special system property. */ |
116 |
/** classpath ~ JRE packages to be hidden from a module */ |
114 |
private static String[] specialResourcePrefixes = null; |
117 |
private final Map<Module,List<Module.PackageExport>> hiddenClasspathPackages = new HashMap<Module,List<Module.PackageExport>>(); |
115 |
|
118 |
|
116 |
/** Create an NbInstaller. |
119 |
/** Create an NbInstaller. |
117 |
* You should also call {@link #registerManager} and if applicable |
120 |
* You should also call {@link #registerManager} and if applicable |
Lines 135-140
final class NbInstaller extends ModuleIn
Link Here
|
135 |
// @SuppressWarnings("unchecked") |
138 |
// @SuppressWarnings("unchecked") |
136 |
public void prepare(Module m) throws InvalidException { |
139 |
public void prepare(Module m) throws InvalidException { |
137 |
ev.log(Events.PREPARE, m); |
140 |
ev.log(Events.PREPARE, m); |
|
|
141 |
checkForHiddenPackages(m); |
138 |
Set<ManifestSection> mysections = null; |
142 |
Set<ManifestSection> mysections = null; |
139 |
Class<?> clazz = null; |
143 |
Class<?> clazz = null; |
140 |
{ |
144 |
{ |
Lines 224-229
final class NbInstaller extends ModuleIn
Link Here
|
224 |
layers.put(m, layerResource); |
228 |
layers.put(m, layerResource); |
225 |
} |
229 |
} |
226 |
} |
230 |
} |
|
|
231 |
|
232 |
private void checkForHiddenPackages(Module m) throws InvalidException { |
233 |
List<Module.PackageExport> hiddenPackages = new ArrayList<Module.PackageExport>(); |
234 |
List<Module> mWithDeps = new LinkedList<Module>(); |
235 |
mWithDeps.add(m); |
236 |
for (Dependency d : m.getDependencies()) { |
237 |
if (d.getType() == Dependency.TYPE_MODULE) { |
238 |
Module _m = mgr.get((String) Util.parseCodeName(d.getName())[0]); |
239 |
assert _m != null : d; |
240 |
mWithDeps.add(_m); |
241 |
} |
242 |
} |
243 |
for (Module _m : mWithDeps) { |
244 |
String hidden = (String) _m.getAttribute("OpenIDE-Module-Hide-Classpath-Packages"); // NOI18N |
245 |
if (hidden != null) { |
246 |
for (String piece : hidden.trim().split("[ ,]+")) { // NOI18N |
247 |
try { |
248 |
if (piece.endsWith(".*")) { // NOI18N |
249 |
String pkg = piece.substring(0, piece.length() - 2); |
250 |
Dependency.create(Dependency.TYPE_MODULE, pkg); |
251 |
if (pkg.lastIndexOf('/') != -1) { |
252 |
throw new IllegalArgumentException("Illegal OpenIDE-Module-Hide-Classpath-Packages: " + hidden); // NOI18N |
253 |
} |
254 |
hiddenPackages.add(new Module.PackageExport(pkg.replace('.', '/') + '/', false)); |
255 |
} else if (piece.endsWith(".**")) { // NOI18N |
256 |
String pkg = piece.substring(0, piece.length() - 3); |
257 |
Dependency.create(Dependency.TYPE_MODULE, pkg); |
258 |
if (pkg.lastIndexOf('/') != -1) { |
259 |
throw new IllegalArgumentException("Illegal OpenIDE-Module-Hide-Classpath-Packages: " + hidden); // NOI18N |
260 |
} |
261 |
hiddenPackages.add(new Module.PackageExport(pkg.replace('.', '/') + '/', true)); |
262 |
} else { |
263 |
throw new IllegalArgumentException("Illegal OpenIDE-Module-Hide-Classpath-Packages: " + hidden); // NOI18N |
264 |
} |
265 |
} catch (IllegalArgumentException x) { |
266 |
throw new InvalidException(_m, x.getMessage()); |
267 |
} |
268 |
} |
269 |
} |
270 |
} |
271 |
if (!hiddenPackages.isEmpty()) { |
272 |
hiddenClasspathPackages.put(m, hiddenPackages); |
273 |
} |
274 |
} |
227 |
|
275 |
|
228 |
public void dispose(Module m) { |
276 |
public void dispose(Module m) { |
229 |
Util.err.fine("dispose: " + m); |
277 |
Util.err.fine("dispose: " + m); |
Lines 237-242
final class NbInstaller extends ModuleIn
Link Here
|
237 |
installs.remove(m); |
285 |
installs.remove(m); |
238 |
layers.remove(m); |
286 |
layers.remove(m); |
239 |
kosherPackages.remove(m); |
287 |
kosherPackages.remove(m); |
|
|
288 |
hiddenClasspathPackages.remove(m); |
240 |
} |
289 |
} |
241 |
|
290 |
|
242 |
public void load(List<Module> modules) { |
291 |
public void load(List<Module> modules) { |
Lines 727-734
final class NbInstaller extends ModuleIn
Link Here
|
727 |
arr.add("org.openide.modules.os.Solaris"); // NOI18N |
776 |
arr.add("org.openide.modules.os.Solaris"); // NOI18N |
728 |
} |
777 |
} |
729 |
|
778 |
|
730 |
// module format is now 1 |
779 |
// module format is now 2 |
731 |
arr.add ("org.openide.modules.ModuleFormat1"); // NOI18N |
780 |
arr.add("org.openide.modules.ModuleFormat1"); // NOI18N |
|
|
781 |
arr.add("org.openide.modules.ModuleFormat2"); // NOI18N |
732 |
|
782 |
|
733 |
return arr.toArray (new String[0]); |
783 |
return arr.toArray (new String[0]); |
734 |
} |
784 |
} |
Lines 743-775
final class NbInstaller extends ModuleIn
Link Here
|
743 |
for (String cppkg : CLASSPATH_PACKAGES) { |
793 |
for (String cppkg : CLASSPATH_PACKAGES) { |
744 |
if (pkg.startsWith(cppkg) && !findKosher(m).contains(cppkg)) { |
794 |
if (pkg.startsWith(cppkg) && !findKosher(m).contains(cppkg)) { |
745 |
// Undeclared use of a classpath package. Refuse it. |
795 |
// Undeclared use of a classpath package. Refuse it. |
746 |
if (Util.err.isLoggable(Level.FINE)) { |
796 |
if (LOG.isLoggable(Level.FINE)) { |
747 |
Util.err.fine("Refusing to load classpath package " + pkg + " for " + m.getCodeNameBase() + " without a proper dependency"); // NOI18N |
797 |
LOG.fine("Refusing to load classpath package " + pkg + " for " + m.getCodeNameBase() + " without a proper dependency"); // NOI18N |
748 |
} |
798 |
} |
749 |
return false; |
799 |
return false; |
750 |
} |
800 |
} |
751 |
} |
801 |
} |
|
|
802 |
List<Module.PackageExport> hiddenPackages = hiddenClasspathPackages.get(m); |
803 |
if (hiddenPackages != null) { |
804 |
for (Module.PackageExport hidden : hiddenPackages) { |
805 |
if (hidden.recursive ? pkg.startsWith(hidden.pkg) : pkg.equals(hidden.pkg)) { |
806 |
if (LOG.isLoggable(Level.FINE)) { |
807 |
LOG.fine("Refusing to load classpath package " + pkg + " for " + m.getCodeNameBase()); |
808 |
} |
809 |
return false; |
810 |
} |
811 |
} |
812 |
} |
813 |
} |
814 |
if (LOG.isLoggable(Level.FINER)) { |
815 |
LOG.finer("Delegating resource " + pkg + " from " + parent + " for " + m.getCodeNameBase()); |
752 |
} |
816 |
} |
753 |
return true; |
817 |
return true; |
754 |
} |
818 |
} |
755 |
|
819 |
|
756 |
private static final String[] CLASSPATH_PACKAGES = new String[] { |
820 |
private static final String[] CLASSPATH_PACKAGES = { |
757 |
// core.jar shall be inaccessible |
821 |
// core.jar shall be inaccessible |
758 |
"org/netbeans/core/startup/", |
822 |
"org/netbeans/core/startup/", |
759 |
// Java language infrastructure bundled with IDE; do not want clashes with JDK 6: |
823 |
// Do not add JRE packages here! See issue #96711 for the alternative. |
760 |
"com/sun/tools/javac/", |
|
|
761 |
"com/sun/tools/javadoc/", |
762 |
"com/sun/javadoc/", |
763 |
"com/sun/source/", |
764 |
"javax/annotation/", |
765 |
"javax/lang/model/", |
766 |
"javax/tools/", |
767 |
// do not want JAX-WS 2.0 classes from JDK 6; |
768 |
"javax/xml/bind/", // NOI18N |
769 |
"javax/xml/ws/", // NOI18N |
770 |
"javax/xml/stream/", // NOI18N |
771 |
"javax/jws/", // NOI18N |
772 |
"javax/xml/soap/" // NOI18N |
773 |
}; |
824 |
}; |
774 |
|
825 |
|
775 |
private Set<String> findKosher(Module m) { |
826 |
private Set<String> findKosher(Module m) { |