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 27330
Collapse All | Expand All

(-)core/bootstrap/src/org/netbeans/JarClassLoader.java (-5 / +28 lines)
Lines 7-13 Link Here
7
 * http://www.sun.com/
7
 * http://www.sun.com/
8
 * 
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
12
 */
13
13
Lines 25-30 Link Here
25
import java.security.cert.Certificate;
25
import java.security.cert.Certificate;
26
import java.util.*;
26
import java.util.*;
27
import java.lang.reflect.Field;
27
import java.lang.reflect.Field;
28
import java.lang.reflect.InvocationTargetException;
29
import java.lang.reflect.Method;
28
import java.lang.reflect.Modifier;
30
import java.lang.reflect.Modifier;
29
31
30
/**
32
/**
Lines 352-358 Link Here
352
        JarFile src;
354
        JarFile src;
353
        
355
        
354
        public JarSource(JarFile file) throws MalformedURLException {
356
        public JarSource(JarFile file) throws MalformedURLException {
355
            super(new URL("file:" + file.getName()));
357
            super(fileToURL(new File(file.getName())));
356
            src = file;
358
            src = file;
357
        }
359
        }
358
360
Lines 374-380 Link Here
374
                if (ze != null)
376
                if (ze != null)
375
                    System.err.println("Loading " + name + " from " + src.getName()); // NOI18N
377
                    System.err.println("Loading " + name + " from " + src.getName()); // NOI18N
376
            }
378
            }
377
            return ze == null ? null : new URL("jar:file:" + src.getName() + "!/" + ze.getName()); // NOI18N
379
            return ze == null ? null : new URL("jar:" + fileToURL(new File(src.getName())).toExternalForm() + "!/" + ze.getName()); // NOI18N
378
        }
380
        }
379
        
381
        
380
        protected byte[] readClass(String name, String path) throws IOException {
382
        protected byte[] readClass(String name, String path) throws IOException {
Lines 399-411 Link Here
399
        File dir;
401
        File dir;
400
        
402
        
401
        public DirSource(File file) throws MalformedURLException {
403
        public DirSource(File file) throws MalformedURLException {
402
            super(file.toURL());
404
            super(fileToURL(file));
403
            dir = file;
405
            dir = file;
404
        }
406
        }
405
407
406
        protected URL doGetResource(String name) throws MalformedURLException {
408
        protected URL doGetResource(String name) throws MalformedURLException {
407
            File resFile = new File(dir, name);
409
            File resFile = new File(dir, name);
408
            return resFile.exists() ? resFile.toURL() : null;
410
            return resFile.exists() ? fileToURL(resFile) : null;
409
        }
411
        }
410
        
412
        
411
        protected byte[] readClass(String name, String path) throws IOException {
413
        protected byte[] readClass(String name, String path) throws IOException {
Lines 424-429 Link Here
424
        
426
        
425
    }
427
    }
426
    
428
    
429
    /** Convert a file to a URL as safely as possible.
430
     * Under JDK 1.4, handle hash marks etc.
431
     * Unfortunately it was decided not to fix the major bugs
432
     * in the JDK 1.3 implementation, so a separate API is needed.
433
     * @see #27330
434
     */
435
    private static URL fileToURL(File f) throws MalformedURLException {
436
        if (!System.getProperty("java.specification.version").startsWith("1.3")) { // NOI18N
437
            try {
438
                Method m = File.class.getMethod("toURI", null); // NOI18N
439
                Object o = m.invoke(f, null);
440
                m = o.getClass().getMethod("toURL", null); // NOI18N
441
                return (URL)m.invoke(o, null);
442
            } catch (InvocationTargetException e) {
443
                throw (MalformedURLException)e.getTargetException();
444
            } catch (Exception e) {
445
                e.printStackTrace();
446
            }
447
        }
448
        return f.toURL();
449
    }
427
    
450
    
428
    //
451
    //
429
    // ErrorManager's methods
452
    // ErrorManager's methods
(-)core/src/org/netbeans/core/modules/HelpHelper.java (-1 / +25 lines)
Lines 14-19 Link Here
14
package org.netbeans.core.modules;
14
package org.netbeans.core.modules;
15
15
16
import java.io.*;
16
import java.io.*;
17
import java.lang.reflect.InvocationTargetException;
18
import java.lang.reflect.Method;
17
import java.net.*;
19
import java.net.*;
18
20
19
import org.xml.sax.*;
21
import org.xml.sax.*;
Lines 152-158 Link Here
152
                File helpset = new File(dir, res.replace('/', File.separatorChar));
154
                File helpset = new File(dir, res.replace('/', File.separatorChar));
153
                if (helpset.isFile()) {
155
                if (helpset.isFile()) {
154
                    try {
156
                    try {
155
                        return helpset.toURL();
157
                        return fileToURL(helpset);
156
                    } catch (MalformedURLException mfue) {
158
                    } catch (MalformedURLException mfue) {
157
                        ErrorManager.getDefault().notify(mfue);
159
                        ErrorManager.getDefault().notify(mfue);
158
                        return null;
160
                        return null;
Lines 162-167 Link Here
162
        }
164
        }
163
        return null;
165
        return null;
164
    }
166
    }
167
    /** Convert a file to a URL as safely as possible.
168
     * Under JDK 1.4, handle hash marks etc.
169
     * Unfortunately it was decided not to fix the major bugs
170
     * in the JDK 1.3 implementation, so a separate API is needed.
171
     * @see #27330
172
     */
173
    private static URL fileToURL(File f) throws MalformedURLException {
174
        if (!System.getProperty("java.specification.version").startsWith("1.3")) { // NOI18N
175
            try {
176
                Method m = File.class.getMethod("toURI", null); // NOI18N
177
                Object o = m.invoke(f, null);
178
                m = o.getClass().getMethod("toURL", null); // NOI18N
179
                return (URL)m.invoke(o, null);
180
            } catch (InvocationTargetException e) {
181
                throw (MalformedURLException)e.getTargetException();
182
            } catch (Exception e) {
183
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
184
            }
185
        }
186
        return f.toURL();
187
    }
188
    
165
    
189
    
166
    /** Quick parser for helpsets.
190
    /** Quick parser for helpsets.
167
     * Just does enough work to extract the home ID
191
     * Just does enough work to extract the home ID
(-)core/src/org/netbeans/core/projects/ModuleLayeredFileSystem.java (-3 / +1 lines)
Lines 361-369 Link Here
361
            }
361
            }
362
            hash = x;
362
            hash = x;
363
        }
363
        }
364
        // XXX #20830: module URLs on Windows have illegal backslash; the URI constructor rejects it
364
        private static final boolean isJDK14 = Dependency.JAVA_SPEC.compareTo(new SpecificationVersion("1.4")) >= 0; // NOI18N
365
        //private static final boolean isJDK14 = Dependency.JAVA_SPEC.compareTo(new SpecificationVersion("1.4")) >= 0; // NOI18N
366
        private static final boolean isJDK14 = false;
367
        private static File findFile(String u) throws IOException {
365
        private static File findFile(String u) throws IOException {
368
            if (u.startsWith("jar:") && u.lastIndexOf("!/") != -1) { // NOI18N
366
            if (u.startsWith("jar:") && u.lastIndexOf("!/") != -1) { // NOI18N
369
                u = u.substring(4, u.lastIndexOf("!/"));
367
                u = u.substring(4, u.lastIndexOf("!/"));
(-)core/src/org/netbeans/core/projects/cache/XMLLayerCacheManagerImpl.java (-3 / +29 lines)
Lines 14-23 Link Here
14
package org.netbeans.core.projects.cache;
14
package org.netbeans.core.projects.cache;
15
15
16
import java.io.*;
16
import java.io.*;
17
import java.lang.reflect.InvocationTargetException;
18
import java.lang.reflect.Method;
19
import java.net.MalformedURLException;
17
import java.net.URL;
20
import java.net.URL;
18
import java.util.Iterator;
21
import java.util.Iterator;
19
import java.util.List;
22
import java.util.List;
20
import java.util.zip.CRC32;
23
import java.util.zip.CRC32;
24
import org.openide.ErrorManager;
21
25
22
import org.xml.sax.SAXException;
26
import org.xml.sax.SAXException;
23
27
Lines 58-64 Link Here
58
    public FileSystem createLoadedFileSystem() throws IOException {
62
    public FileSystem createLoadedFileSystem() throws IOException {
59
        if (cacheFile.exists()) {
63
        if (cacheFile.exists()) {
60
            try {
64
            try {
61
                return new XMLFileSystem(cacheFile.toURL());
65
                return new XMLFileSystem(fileToURL(cacheFile));
62
            } catch (SAXException saxe) {
66
            } catch (SAXException saxe) {
63
                IOException ioe = new IOException(saxe.toString());
67
                IOException ioe = new IOException(saxe.toString());
64
                LayerCacheManager.err.annotate(ioe, saxe);
68
                LayerCacheManager.err.annotate(ioe, saxe);
Lines 71-77 Link Here
71
    
75
    
72
    public void load(FileSystem fs) throws IOException {
76
    public void load(FileSystem fs) throws IOException {
73
        try {
77
        try {
74
            ((XMLFileSystem)fs).setXmlUrl(cacheFile.toURL());
78
            ((XMLFileSystem)fs).setXmlUrl(fileToURL(cacheFile));
75
        } catch (Exception e) {
79
        } catch (Exception e) {
76
            IOException ioe = new IOException(e.toString());
80
            IOException ioe = new IOException(e.toString());
77
            LayerCacheManager.err.annotate(ioe, e);
81
            LayerCacheManager.err.annotate(ioe, e);
Lines 165-171 Link Here
165
                        hex = "0" + hex; // NOI18N
169
                        hex = "0" + hex; // NOI18N
166
                    }
170
                    }
167
                    File data = new File(datadir, "data_" + hex); // NOI18N
171
                    File data = new File(datadir, "data_" + hex); // NOI18N
168
                    url = data.toURL().toString();
172
                    url = fileToURL(data).toExternalForm();
169
                    if (!data.isFile()) {
173
                    if (!data.isFile()) {
170
                        OutputStream os = new FileOutputStream(data);
174
                        OutputStream os = new FileOutputStream(data);
171
                        try {
175
                        try {
Lines 220-225 Link Here
220
        }
224
        }
221
        
225
        
222
        return false;
226
        return false;
227
    }
228
    
229
    /** Convert a file to a URL as safely as possible.
230
     * Under JDK 1.4, handle hash marks etc.
231
     * Unfortunately it was decided not to fix the major bugs
232
     * in the JDK 1.3 implementation, so a separate API is needed.
233
     * @see #27330
234
     */
235
    private static URL fileToURL(File f) throws MalformedURLException {
236
        if (!System.getProperty("java.specification.version").startsWith("1.3")) { // NOI18N
237
            try {
238
                Method m = File.class.getMethod("toURI", null); // NOI18N
239
                Object o = m.invoke(f, null);
240
                m = o.getClass().getMethod("toURL", null); // NOI18N
241
                return (URL)m.invoke(o, null);
242
            } catch (InvocationTargetException e) {
243
                throw (MalformedURLException)e.getTargetException();
244
            } catch (Exception e) {
245
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
246
            }
247
        }
248
        return f.toURL();
223
    }
249
    }
224
    
250
    
225
}
251
}

Return to bug 27330