This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 28259
Collapse All | Expand All

(-)core/src/org/netbeans/Main.java (-12 / +21 lines)
Lines 16-25 Link Here
16
import java.io.File;
16
import java.io.File;
17
import java.net.URL;
17
import java.net.URL;
18
import java.net.URLClassLoader;
18
import java.net.URLClassLoader;
19
import java.util.ArrayList;
19
import java.util.*;
20
import java.util.StringTokenizer;
21
import java.lang.reflect.Method;
20
import java.lang.reflect.Method;
22
import java.util.Collection;
21
import java.util.jar.JarFile;
23
22
24
/** Bootstrap main class.
23
/** Bootstrap main class.
25
 * @author Jaroslav Tulach, Jesse Glick
24
 * @author Jaroslav Tulach, Jesse Glick
Lines 36-47 Link Here
36
            build_cp (new File (home), list);
35
            build_cp (new File (home), list);
37
        }
36
        }
38
        
37
        
39
        java.util.ListIterator it = list.listIterator();
40
        while (it.hasNext()) {
41
            File f = (File)it.next();
42
            it.set(new java.util.jar.JarFile (f));
43
        }
44
        
45
        //
38
        //
46
        // prepend classpath
39
        // prepend classpath
47
        //
40
        //
Lines 52-58 Link Here
52
                list.add (0, new File (tok.nextToken()));
45
                list.add (0, new File (tok.nextToken()));
53
            }
46
            }
54
        }
47
        }
48
49
        // Compute effective dynamic classpath (mostly lib/*.jar) for TopLogging, NbInstaller:
50
        StringBuffer buf = new StringBuffer(1000);
51
        Iterator it = list.iterator();
52
        while (it.hasNext()) {
53
            if (buf.length() > 0) {
54
                buf.append(File.pathSeparatorChar);
55
            }
56
            buf.append(((File)it.next()).getAbsolutePath());
57
        }
58
        System.setProperty("netbeans.dynamic.classpath", buf.toString());
55
        
59
        
60
        // JarClassLoader treats a File as a dir; for a ZIP/JAR, needs JarFile
61
        ListIterator it2 = list.listIterator();
62
        while (it2.hasNext()) {
63
            File f = (File)it2.next();
64
            if (f.isFile()) {
65
                it2.set(new JarFile (f));
66
            }
67
        }
56
        
68
        
57
        // XXX separate openide.jar and core*.jar into different classloaders
69
        // XXX separate openide.jar and core*.jar into different classloaders
58
        ClassLoader loader = new JarClassLoader (list, new ClassLoader[] {
70
        ClassLoader loader = new JarClassLoader (list, new ClassLoader[] {
Lines 95-103 Link Here
95
        
107
        
96
    
108
    
97
    private static void build_cp(File base, Collection toAdd) {
109
    private static void build_cp(File base, Collection toAdd) {
98
        // --> IMPORTANT! <--
99
        // Please keep this logic in synch with impl of NbInstaller.getEffectiveClasspath.
100
        // Otherwise the "effective classpath" will be displayed inaccurately.
101
        append_jars_to_cp (new File (base, "lib/patches"), toAdd);
110
        append_jars_to_cp (new File (base, "lib/patches"), toAdd);
102
        append_jars_to_cp (new File (base, "lib"), toAdd);
111
        append_jars_to_cp (new File (base, "lib"), toAdd);
103
        // XXX a minor optimization: exclude any unused locale JARs
112
        // XXX a minor optimization: exclude any unused locale JARs
(-)core/src/org/netbeans/core/TopLogging.java (+1 lines)
Lines 202-207 Link Here
202
        //ps.println("  System Directory         = " + Main.getSystemDir ()); // NOI18N
202
        //ps.println("  System Directory         = " + Main.getSystemDir ()); // NOI18N
203
        ps.println("  CLASSPATH             = " + System.getProperty("java.class.path", "unknown")); // NOI18N
203
        ps.println("  CLASSPATH             = " + System.getProperty("java.class.path", "unknown")); // NOI18N
204
        ps.println("  Boot & ext classpath  = " + NbClassPath.createBootClassPath().getClassPath()); // NOI18N
204
        ps.println("  Boot & ext classpath  = " + NbClassPath.createBootClassPath().getClassPath()); // NOI18N
205
        ps.println("  Dynamic classpath     = " + System.getProperty("netbeans.dynamic.classpath", "unknown")); // NOI18N
205
    }
206
    }
206
207
207
    public void finalize() throws Throwable {
208
    public void finalize() throws Throwable {
(-)core/src/org/netbeans/core/modules/NbInstaller.java (-29 / +17 lines)
Lines 1056-1071 Link Here
1056
        // Move on to "startup classpath", qualified by applicable package deps etc.
1056
        // Move on to "startup classpath", qualified by applicable package deps etc.
1057
        // Fixed classpath modules don't get restricted in this way.
1057
        // Fixed classpath modules don't get restricted in this way.
1058
        Set kosher = m.isFixed() ? null : findKosher(m);
1058
        Set kosher = m.isFixed() ? null : findKosher(m);
1059
        String home = System.getProperty("netbeans.home"); // NOI18N
1059
        tok = new StringTokenizer(System.getProperty("java.class.path", ""), File.pathSeparator);
1060
        if (home != null) {
1060
        while (tok.hasMoreTokens()) {
1061
            File lib = new File(new File(home), "lib"); // NOI18N
1061
            addStartupClasspathEntry(new File(tok.nextToken()), l, kosher);
1062
            // Cf. launcher:
1062
        }
1063
            addStartupClasspathEntries(new File(lib, "ext"), l, kosher); // NOI18N
1063
        // See org.netbeans.Main for actual computation of the dynamic classpath.
1064
            addStartupClasspathEntries(new File(new File(lib, "ext"), "locale"), l, kosher); // NOI18N
1064
        tok = new StringTokenizer(System.getProperty("netbeans.dynamic.classpath", ""), File.pathSeparator);
1065
            // Cf. org.netbeans.Main.build_cp():
1065
        while (tok.hasMoreTokens()) {
1066
            addStartupClasspathEntries(new File(lib, "patches"), l, kosher); // NOI18N
1066
            addStartupClasspathEntry(new File(tok.nextToken()), l, kosher);
1067
            addStartupClasspathEntries(lib, l, kosher);
1068
            addStartupClasspathEntries(new File(lib, "locale"), l, kosher); // NOI18N
1069
        }
1067
        }
1070
        // Finally include this module and its dependencies recursively.
1068
        // Finally include this module and its dependencies recursively.
1071
        // Modules whose direct classpath has already been added to the list:
1069
        // Modules whose direct classpath has already been added to the list:
Lines 1098-1124 Link Here
1098
        return buf.toString();
1096
        return buf.toString();
1099
    }
1097
    }
1100
    
1098
    
1101
    /** Add classpath entries from the lib/ or lib/ext/ dirs, if appropriate.
1099
    /** Add a classpath entry from the lib/ or lib/ext/ dirs, if appropriate.
1102
     * @param dir the directory to scan for JAR and ZIP files
1100
     * @param entry a classpath entry; either a directory, or a JAR file which might be controlled
1103
     * @param cp the classpath (<code>List&lt;String&gt;</code>) to add to
1101
     * @param cp the classpath (<code>List&lt;String&gt;</code>) to add to
1104
     * @param kosher known packages which may be accessed (<code>Set&lt;String&gt;</code>), or null for no restrictions
1102
     * @param kosher known packages which may be accessed (<code>Set&lt;String&gt;</code>), or null for no restrictions
1105
     * @see #22466
1103
     * @see #22466
1106
     */
1104
     */
1107
    private static void addStartupClasspathEntries(File dir, List cp, Set kosher) {
1105
    private static void addStartupClasspathEntry(File cpEntry, List cp, Set kosher) {
1108
        if (!dir.isDirectory()) {
1106
        if (cpEntry.isDirectory()) {
1107
            cp.add(cpEntry.getAbsolutePath());
1109
            return;
1108
            return;
1110
        }
1109
        }
1111
        class JarZipFilter implements FilenameFilter {
1110
        // JAR or ZIP. Check whether we can access it.
1112
            public boolean accept(File dir, String name) {
1111
                String name = cpEntry.getName();
1113
                String n = name.toLowerCase(Locale.US);
1114
                return !n.startsWith("updater") && (n.endsWith(".jar") || n.endsWith(".zip")); // NOI18N
1115
            }
1116
        }
1117
        File[] exts = dir.listFiles(new JarZipFilter());
1118
        if (exts != null) {
1119
        EXTS:
1120
            for (int i = 0; i < exts.length; i++) {
1121
                String name = exts[i].getName();
1122
                for (int j = 0; j < CLASSPATH_JARS.length; j++) {
1112
                for (int j = 0; j < CLASSPATH_JARS.length; j++) {
1123
                    if (kosher != null && name.startsWith(CLASSPATH_JARS[j][0])) {
1113
                    if (kosher != null && name.startsWith(CLASSPATH_JARS[j][0])) {
1124
                        // Restricted JAR.
1114
                        // Restricted JAR.
Lines 1129-1135 Link Here
1129
                                // Module is permitted to use this package.
1119
                                // Module is permitted to use this package.
1130
                                if (entry == null) {
1120
                                if (entry == null) {
1131
                                    entry = new StringBuffer(100);
1121
                                    entry = new StringBuffer(100);
1132
                                    entry.append(exts[i].getAbsolutePath());
1122
                                    entry.append(cpEntry.getAbsolutePath());
1133
                                    entry.append('['); // NOI18N
1123
                                    entry.append('['); // NOI18N
1134
                                } else {
1124
                                } else {
1135
                                    entry.append(','); // NOI18N
1125
                                    entry.append(','); // NOI18N
Lines 1148-1156 Link Here
1148
                    }
1138
                    }
1149
                }
1139
                }
1150
                // Did not match any, assumed to be on classpath.
1140
                // Did not match any, assumed to be on classpath.
1151
                cp.add(exts[i].getAbsolutePath());
1141
                cp.add(cpEntry.getAbsolutePath());
1152
            }
1153
        }
1154
    }
1142
    }
1155
1143
1156
    /** Recursively build a classpath based on the module dependency tree.
1144
    /** Recursively build a classpath based on the module dependency tree.

Return to bug 28259