Index: core/src/org/netbeans/Main.java
===================================================================
RCS file: /cvs/core/src/org/netbeans/Main.java,v
retrieving revision 1.20
diff -u -r1.20 Main.java
--- core/src/org/netbeans/Main.java 21 Oct 2002 08:51:22 -0000 1.20
+++ core/src/org/netbeans/Main.java 24 Oct 2002 17:46:26 -0000
@@ -16,10 +16,9 @@
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
+import java.util.*;
import java.lang.reflect.Method;
-import java.util.Collection;
+import java.util.jar.JarFile;
/** Bootstrap main class.
* @author Jaroslav Tulach, Jesse Glick
@@ -36,12 +35,6 @@
build_cp (new File (home), list);
}
- java.util.ListIterator it = list.listIterator();
- while (it.hasNext()) {
- File f = (File)it.next();
- it.set(new java.util.jar.JarFile (f));
- }
-
//
// prepend classpath
//
@@ -52,7 +45,26 @@
list.add (0, new File (tok.nextToken()));
}
}
+
+ // Compute effective dynamic classpath (mostly lib/*.jar) for TopLogging, NbInstaller:
+ StringBuffer buf = new StringBuffer(1000);
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ if (buf.length() > 0) {
+ buf.append(File.pathSeparatorChar);
+ }
+ buf.append(((File)it.next()).getAbsolutePath());
+ }
+ System.setProperty("netbeans.dynamic.classpath", buf.toString());
+ // JarClassLoader treats a File as a dir; for a ZIP/JAR, needs JarFile
+ ListIterator it2 = list.listIterator();
+ while (it2.hasNext()) {
+ File f = (File)it2.next();
+ if (f.isFile()) {
+ it2.set(new JarFile (f));
+ }
+ }
// XXX separate openide.jar and core*.jar into different classloaders
ClassLoader loader = new JarClassLoader (list, new ClassLoader[] {
@@ -95,9 +107,6 @@
private static void build_cp(File base, Collection toAdd) {
- // --> IMPORTANT! <--
- // Please keep this logic in synch with impl of NbInstaller.getEffectiveClasspath.
- // Otherwise the "effective classpath" will be displayed inaccurately.
append_jars_to_cp (new File (base, "lib/patches"), toAdd);
append_jars_to_cp (new File (base, "lib"), toAdd);
// XXX a minor optimization: exclude any unused locale JARs
Index: core/src/org/netbeans/core/TopLogging.java
===================================================================
RCS file: /cvs/core/src/org/netbeans/core/TopLogging.java,v
retrieving revision 1.31
diff -u -r1.31 TopLogging.java
--- core/src/org/netbeans/core/TopLogging.java 14 Feb 2002 14:22:13 -0000 1.31
+++ core/src/org/netbeans/core/TopLogging.java 24 Oct 2002 17:46:26 -0000
@@ -202,6 +202,7 @@
//ps.println(" System Directory = " + Main.getSystemDir ()); // NOI18N
ps.println(" CLASSPATH = " + System.getProperty("java.class.path", "unknown")); // NOI18N
ps.println(" Boot & ext classpath = " + NbClassPath.createBootClassPath().getClassPath()); // NOI18N
+ ps.println(" Dynamic classpath = " + System.getProperty("netbeans.dynamic.classpath", "unknown")); // NOI18N
}
public void finalize() throws Throwable {
Index: core/src/org/netbeans/core/modules/NbInstaller.java
===================================================================
RCS file: /cvs/core/src/org/netbeans/core/modules/NbInstaller.java,v
retrieving revision 1.54
diff -u -r1.54 NbInstaller.java
--- core/src/org/netbeans/core/modules/NbInstaller.java 24 Oct 2002 17:20:42 -0000 1.54
+++ core/src/org/netbeans/core/modules/NbInstaller.java 24 Oct 2002 17:46:26 -0000
@@ -1056,16 +1056,14 @@
// Move on to "startup classpath", qualified by applicable package deps etc.
// Fixed classpath modules don't get restricted in this way.
Set kosher = m.isFixed() ? null : findKosher(m);
- String home = System.getProperty("netbeans.home"); // NOI18N
- if (home != null) {
- File lib = new File(new File(home), "lib"); // NOI18N
- // Cf. launcher:
- addStartupClasspathEntries(new File(lib, "ext"), l, kosher); // NOI18N
- addStartupClasspathEntries(new File(new File(lib, "ext"), "locale"), l, kosher); // NOI18N
- // Cf. org.netbeans.Main.build_cp():
- addStartupClasspathEntries(new File(lib, "patches"), l, kosher); // NOI18N
- addStartupClasspathEntries(lib, l, kosher);
- addStartupClasspathEntries(new File(lib, "locale"), l, kosher); // NOI18N
+ tok = new StringTokenizer(System.getProperty("java.class.path", ""), File.pathSeparator);
+ while (tok.hasMoreTokens()) {
+ addStartupClasspathEntry(new File(tok.nextToken()), l, kosher);
+ }
+ // See org.netbeans.Main for actual computation of the dynamic classpath.
+ tok = new StringTokenizer(System.getProperty("netbeans.dynamic.classpath", ""), File.pathSeparator);
+ while (tok.hasMoreTokens()) {
+ addStartupClasspathEntry(new File(tok.nextToken()), l, kosher);
}
// Finally include this module and its dependencies recursively.
// Modules whose direct classpath has already been added to the list:
@@ -1098,27 +1096,19 @@
return buf.toString();
}
- /** Add classpath entries from the lib/ or lib/ext/ dirs, if appropriate.
- * @param dir the directory to scan for JAR and ZIP files
+ /** Add a classpath entry from the lib/ or lib/ext/ dirs, if appropriate.
+ * @param entry a classpath entry; either a directory, or a JAR file which might be controlled
* @param cp the classpath (List<String>
) to add to
* @param kosher known packages which may be accessed (Set<String>
), or null for no restrictions
* @see #22466
*/
- private static void addStartupClasspathEntries(File dir, List cp, Set kosher) {
- if (!dir.isDirectory()) {
+ private static void addStartupClasspathEntry(File cpEntry, List cp, Set kosher) {
+ if (cpEntry.isDirectory()) {
+ cp.add(cpEntry.getAbsolutePath());
return;
}
- class JarZipFilter implements FilenameFilter {
- public boolean accept(File dir, String name) {
- String n = name.toLowerCase(Locale.US);
- return !n.startsWith("updater") && (n.endsWith(".jar") || n.endsWith(".zip")); // NOI18N
- }
- }
- File[] exts = dir.listFiles(new JarZipFilter());
- if (exts != null) {
- EXTS:
- for (int i = 0; i < exts.length; i++) {
- String name = exts[i].getName();
+ // JAR or ZIP. Check whether we can access it.
+ String name = cpEntry.getName();
for (int j = 0; j < CLASSPATH_JARS.length; j++) {
if (kosher != null && name.startsWith(CLASSPATH_JARS[j][0])) {
// Restricted JAR.
@@ -1129,7 +1119,7 @@
// Module is permitted to use this package.
if (entry == null) {
entry = new StringBuffer(100);
- entry.append(exts[i].getAbsolutePath());
+ entry.append(cpEntry.getAbsolutePath());
entry.append('['); // NOI18N
} else {
entry.append(','); // NOI18N
@@ -1148,9 +1138,7 @@
}
}
// Did not match any, assumed to be on classpath.
- cp.add(exts[i].getAbsolutePath());
- }
- }
+ cp.add(cpEntry.getAbsolutePath());
}
/** Recursively build a classpath based on the module dependency tree.