Index: core/src/org/netbeans/core/modules/ModuleSystem.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/modules/ModuleSystem.java,v retrieving revision 1.34 diff -u -r1.34 ModuleSystem.java --- core/src/org/netbeans/core/modules/ModuleSystem.java 27 Mar 2003 00:01:30 -0000 1.34 +++ core/src/org/netbeans/core/modules/ModuleSystem.java 2 Apr 2003 17:17:04 -0000 @@ -23,7 +23,9 @@ import org.openide.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; +import java.net.MalformedURLException; import org.netbeans.core.NbTopManager; +import org.openide.util.Utilities; /** Controller of the IDE's whole module system. * Contains higher-level convenience methods to @@ -148,7 +150,34 @@ * case oh well... */ public void loadBootModules() { - String jrePrefix = "jar:file:" + System.getProperty("java.home"); + // Keep a list of manifest URL prefixes which we know we do not need to + // parse. Some of these manifests might be signed, and if so, we do not + // want to touch them, as it slows down startup quite a bit. + Collection ignoredPrefixes = new ArrayList(3); // List + try { + // skip the JDK/JRE libraries + String jdk = System.getProperty("java.home"); + if (jdk.endsWith(File.separator + "jre")) { // NOI18N + jdk = jdk.substring(0, jdk.length() - 4); + } + File f = new File(jdk); + ignoredPrefixes.add("jar:" + Utilities.toURL(f)); // NOI18N + // skip $nbhome/lib/ext/*.jar; all fixes modules should be in + // $nbhome/lib/ (or perhaps elsewhere, with -cp:a) + File nbhome = new File(System.getProperty("netbeans.home")); + f = new File(new File(nbhome, "lib"), "ext"); // NOI18N + ignoredPrefixes.add("jar:" + Utilities.toURL(f)); // NOI18N + // skip $nbhome/modules/autoload/ext/*.jar too; this is just to fix + // #32303, i.e. our jh.jar is added to boot cp on Solaris + f = new File(new File(new File(nbhome, "modules"), "autoload"), "ext"); // NOI18N + ignoredPrefixes.add("jar:" + Utilities.toURL(f)); // NOI18N + } catch (MalformedURLException e) { + Util.err.notify(ErrorManager.INFORMATIONAL, e); + } + if (Util.err.isLoggable(ErrorManager.INFORMATIONAL)) { + Util.err.log("ignoredPrefixes=" + ignoredPrefixes); + } + mgr.mutexPrivileged().enterWriteAccess(); ev.log(Events.START_LOAD_BOOT_MODULES); try { @@ -156,15 +185,35 @@ ClassLoader loader = ModuleSystem.class.getClassLoader(); Enumeration e = loader.getResources("META-INF/MANIFEST.MF"); // NOI18N ev.log(Events.PERF_TICK, "got all manifests"); // NOI18N - + + // There will be duplicates: cf. #32576. + Set checkedManifests = new HashSet(); // Set + MANIFESTS: while (e.hasMoreElements()) { URL manifestUrl = (URL)e.nextElement(); - // [PERF] skip the JDK libraries. They may be signed. - if (manifestUrl.toExternalForm().startsWith(jrePrefix)) { - continue; + if (!checkedManifests.add(manifestUrl)) { + // Already seen, ignore. + continue; + } + String manifestUrlS = manifestUrl.toExternalForm(); + Iterator it = ignoredPrefixes.iterator(); + while (it.hasNext()) { + if (manifestUrlS.startsWith((String)it.next())) { + continue MANIFESTS; + } + } + if (Util.err.isLoggable(ErrorManager.INFORMATIONAL)) { + Util.err.log("Checking boot manifest: " + manifestUrlS); } - InputStream is = manifestUrl.openStream(); + InputStream is; + try { + is = manifestUrl.openStream(); + } catch (IOException ioe) { + // Debugging for e.g. #32493 - which JAR was guilty? + Util.err.annotate(ioe, ErrorManager.UNKNOWN, "URL: " + manifestUrl, null, null, null); // NOI18N + throw ioe; + } try { Manifest mani = new Manifest(is); Attributes attr = mani.getMainAttributes();