--- a/ant.debugger/nbproject/project.xml +++ a/ant.debugger/nbproject/project.xml @@ -121,7 +121,7 @@ - 6.2 + 7.57 --- a/ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java +++ a/ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java @@ -65,7 +65,6 @@ import org.openide.cookies.EditorCookie; import org.openide.cookies.LineCookie; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; @@ -405,11 +404,7 @@ } InputSource in = new InputSource (new StringReader (w.toString ())); if (fo != null) { // #10348 - try { - in.setSystemId (fo.getURL ().toExternalForm ()); - } catch (FileStateInvalidException e) { - assert false : e; - } + in.setSystemId(fo.toURL().toExternalForm()); // [PENDING] Ant's ProjectHelper has an elaborate set of work- // arounds for inconsistent parser behavior, e.g. file:foo.xml // works in Ant but not with Xerces parser. You must use just foo.xml --- a/ant.debugger/src/org/netbeans/modules/ant/debugger/breakpoints/BreakpointsReader.java +++ a/ant.debugger/src/org/netbeans/modules/ant/debugger/breakpoints/BreakpointsReader.java @@ -49,11 +49,9 @@ import java.net.MalformedURLException; import java.net.URL; import org.netbeans.api.debugger.Breakpoint; -import org.netbeans.api.debugger.DebuggerManager; import org.netbeans.api.debugger.Properties; import org.openide.cookies.LineCookie; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.URLMapper; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; @@ -105,8 +103,7 @@ AntBreakpoint b = (AntBreakpoint) object; FileObject fo = (FileObject) b.getLine ().getLookup (). lookup (FileObject.class); - try { - properties.setString ("url", fo.getURL ().toString ()); + properties.setString("url", fo.toURL().toString()); properties.setInt ( "lineNumber", b.getLine ().getLineNumber () @@ -119,9 +116,6 @@ properties.setInt(Breakpoint.PROP_HIT_COUNT_FILTER, b.getHitCountFilter()); Breakpoint.HIT_COUNT_FILTERING_STYLE style = b.getHitCountFilteringStyle(); properties.setInt(Breakpoint.PROP_HIT_COUNT_FILTER+"_style", style != null ? style.ordinal() : 0); // NOI18N - } catch (FileStateInvalidException ex) { - ex.printStackTrace (); - } } --- a/api.debugger.jpda/nbproject/project.xml +++ a/api.debugger.jpda/nbproject/project.xml @@ -106,7 +106,7 @@ - 7.0 + 7.57 --- a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java +++ a/api.debugger.jpda/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java @@ -49,9 +49,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.WeakHashMap; import javax.swing.event.ChangeEvent; @@ -67,7 +65,6 @@ import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileRenameEvent; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.URLMapper; import org.openide.loaders.DataObject; import org.openide.util.NbBundle; @@ -518,11 +515,7 @@ } public void fileRenamed(FileRenameEvent fe) { - try { - this.setURL(((FileObject) fe.getSource()).getURL().toString()); - } catch (FileStateInvalidException ex) { - ErrorManager.getDefault().notify(ex); - } + this.setURL(((FileObject) fe.getSource()).toURL().toString()); } public void fileAttributeChanged(FileAttributeEvent fe) { @@ -562,11 +555,7 @@ FileObject newFO = ((DataObject) evt.getSource()).getPrimaryFile(); fileListener = WeakListeners.create(FileChangeListener.class, this, newFO); newFO.addFileChangeListener(fileListener); - try { - this.setURL(newFO.getURL().toString()); - } catch (FileStateInvalidException ex) { - ErrorManager.getDefault().notify(ex); - } + this.setURL(newFO.toURL().toString()); fo = newFO; DebuggerManager.getDebuggerManager().addBreakpoint(this); firePropertyChange(PROP_GROUP_PROPERTIES, null, null); --- a/api.java.classpath/nbproject/project.xml +++ a/api.java.classpath/nbproject/project.xml @@ -19,7 +19,7 @@ - 1.12 + 1.26 @@ -27,7 +27,7 @@ - 7.9 + 7.57 --- a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassLoaderSupport.java +++ a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassLoaderSupport.java @@ -68,12 +68,7 @@ } static ClassLoader create (final ClassPath cp, final ClassLoader parentClassLoader) { - try { - return new ClassLoaderSupport(cp, parentClassLoader); - } catch (FileStateInvalidException e) { - // Should not happen, we already trimmed unused roots: - throw new AssertionError(e); - } + return new ClassLoaderSupport(cp, parentClassLoader); } /** change listener */ @@ -97,7 +92,7 @@ /** Constructor that attaches itself to the filesystem pool. */ @SuppressWarnings("LeakingThisInConstructor") - private ClassLoaderSupport (final ClassPath cp, final ClassLoader parentClassLoader) throws FileStateInvalidException { + private ClassLoaderSupport (final ClassPath cp, final ClassLoader parentClassLoader) { super(cp.getRoots(), parentClassLoader, null); this.classPath = cp; --- a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java +++ a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java @@ -83,7 +83,6 @@ import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileRenameEvent; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.util.Lookup; @@ -559,11 +558,7 @@ if (f.isFolder()) { path += "/"; // NOI18N } - try { - return filter.includes(root.getURL(), path); - } catch (FileStateInvalidException x) { - throw new AssertionError(x); - } + return filter.includes(root.toURL(), path); } /** @@ -1047,7 +1042,6 @@ f = findPath(roots[ridx], nameComponents); FilteringPathResourceImplementation filter = root2Filter.get(roots[ridx]); if (filter != null) { - try { if (f != null) { String path = FileUtil.getRelativePath(roots[ridx], f); assert path != null : String.format("FileUtil.getRelativePath(%s(%b),%s(%b)) returned null", @@ -1058,13 +1052,10 @@ if (f.isFolder()) { path += "/"; // NOI18N } - if (!filter.includes(roots[ridx].getURL(), path)) { + if (!filter.includes(roots[ridx].toURL(), path)) { f = null; } } - } catch (FileStateInvalidException x) { - throw new AssertionError(x); - } } } rootIndex[0] = ridx; --- a/api.java.classpath/src/org/netbeans/api/java/queries/BinaryForSourceQuery.java +++ a/api.java.classpath/src/org/netbeans/api/java/queries/BinaryForSourceQuery.java @@ -50,10 +50,8 @@ import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.spi.java.queries.BinaryForSourceQueryImplementation; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; -import org.openide.util.Exceptions; import org.openide.util.Lookup; /** @@ -138,13 +136,9 @@ for (ClassPath.Entry e : exec.entries()) { FileObject[] roots = SourceForBinaryQuery.findSourceRoots(e.getURL()).getRoots(); for (FileObject root : roots) { - try { - if (sourceRoot.equals (root.getURL())) { + if (sourceRoot.equals (root.toURL())) { result.add (e.getURL()); } - } catch (FileStateInvalidException fsie) { - Exceptions.printStackTrace(fsie); - } } } return result.toArray(new URL[result.size()]); --- a/api.java.classpath/src/org/netbeans/spi/java/classpath/support/ClassPathSupport.java +++ a/api.java.classpath/src/org/netbeans/spi/java/classpath/support/ClassPathSupport.java @@ -54,9 +54,7 @@ import java.net.URL; import java.util.List; import java.util.ArrayList; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; -import org.openide.util.Exceptions; /** * Convenience factory for creating classpaths of common sorts. @@ -124,12 +122,8 @@ if (root == null || !root.isValid()) { continue; } - try { - URL u = root.getURL(); + URL u = root.toURL(); l.add(createResource(u)); - } catch (FileStateInvalidException e) { - Exceptions.printStackTrace (e); - } } return createClassPath (l); } --- a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java +++ a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java @@ -245,7 +245,7 @@ assertTrue (cp.getRoots().length==1); impl.assertEvents(ClassPath.PROP_ROOTS); FileObject archiveFile = FileUtil.toFileObject(root_3); - impl.addResource(FileUtil.getArchiveRoot(archiveFile.getURL())); + impl.addResource(FileUtil.getArchiveRoot(archiveFile.toURL())); assertEquals (cp.getRoots().length,2); impl.assertEvents(ClassPath.PROP_ENTRIES, ClassPath.PROP_ROOTS); root_3.delete(); @@ -365,8 +365,8 @@ FileObject bd = FileUtil.toFileObject(getBaseDir()); FileObject u1fo = bd.createFolder("u1"); FileObject u2fo = bd.createFolder("u2"); - final URL u1 = u1fo.getURL(); - final URL u2 = u2fo.getURL(); + final URL u1 = u1fo.toURL(); + final URL u2 = u2fo.toURL(); class FPRI implements FilteringPathResourceImplementation { private int modulus = 2; public void changeIncludes(int modulus) { @@ -482,15 +482,15 @@ e1.includes(xx2); fail(); } catch (IllegalArgumentException iae) {} - assertTrue(e1.includes(xx1.getURL())); - assertTrue(e1.includes(x_1.getURL())); - assertFalse(e1.includes(xxx1.getURL())); - assertFalse(e1.includes(cau1.getURL())); - assertFalse(e1.includes(xy1.getURL())); - assertFalse(e1.includes(folder.getURL())); - assertTrue(e1.includes(foldr.getURL())); + assertTrue(e1.includes(xx1.toURL())); + assertTrue(e1.includes(x_1.toURL())); + assertFalse(e1.includes(xxx1.toURL())); + assertFalse(e1.includes(cau1.toURL())); + assertFalse(e1.includes(xy1.toURL())); + assertFalse(e1.includes(folder.toURL())); + assertTrue(e1.includes(foldr.toURL())); try { - e1.includes(xx2.getURL()); + e1.includes(xx2.toURL()); fail(); } catch (IllegalArgumentException iae) {} cp.addPropertyChangeListener(impl); @@ -522,11 +522,11 @@ assertTrue(e1.includes(xxx1)); assertTrue(e1.includes(cau1)); assertTrue(e1.includes(xy1)); - assertFalse(e1.includes(xx1.getURL())); - assertFalse(e1.includes(x_1.getURL())); - assertTrue(e1.includes(xxx1.getURL())); - assertTrue(e1.includes(cau1.getURL())); - assertTrue(e1.includes(xy1.getURL())); + assertFalse(e1.includes(xx1.toURL())); + assertFalse(e1.includes(x_1.toURL())); + assertTrue(e1.includes(xxx1.toURL())); + assertTrue(e1.includes(cau1.toURL())); + assertTrue(e1.includes(xy1.toURL())); } public void testFpriChangeFiring() throws Exception { --- a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/GlobalPathRegistryTest.java +++ a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/GlobalPathRegistryTest.java @@ -159,7 +159,7 @@ public void testGetSourceRoots () throws Exception { SFBQImpl query = Lookup.getDefault().lookup(SFBQImpl.class); assertNotNull ("SourceForBinaryQueryImplementation not found in lookup",query); - query.addPair(cp3.getRoots()[0].getURL(),new FileObject[0]); + query.addPair(cp3.getRoots()[0].toURL(),new FileObject[0]); ClassPathTest.TestClassPathImplementation cpChangingImpl = new ClassPathTest.TestClassPathImplementation(); ClassPath cpChanging = ClassPathFactory.createClassPath(cpChangingImpl); assertEquals("cpChangingImpl is empty", 0, cpChanging.getRoots().length); @@ -179,7 +179,7 @@ assertTrue ("Missing roots from cp2",result.containsAll (Arrays.asList(cp2.getRoots()))); cpChangingImpl.removeResource(u); - query.addPair(cp3.getRoots()[0].getURL(),cp4.getRoots()); + query.addPair(cp3.getRoots()[0].toURL(),cp4.getRoots()); result = r.getSourceRoots(); assertEquals ("Wrong number of source roots",result.size(),cp1.getRoots().length + cp2.getRoots().length+cp4.getRoots().length); assertTrue ("Missing roots from cp1",result.containsAll (Arrays.asList(cp1.getRoots()))); @@ -222,11 +222,7 @@ FileObject src2excluded1 = FileUtil.createData(src2, "excluded/file1"); class PRI extends PathResourceBase implements FilteringPathResourceImplementation { public URL[] getRoots() { - try { - return new URL[] {src1.getURL()}; - } catch (FileStateInvalidException x) { - throw new AssertionError(x); - } + return new URL[] {src1.toURL()}; } public boolean includes(URL root, String resource) { return resource.startsWith("incl"); @@ -256,7 +252,7 @@ assertEquals(Collections.emptySet(), reg.getSourceRoots()); r.register(ClassPath.COMPILE, new ClassPath[] {cp3}); SFBQImpl query = Lookup.getDefault().lookup(SFBQImpl.class); - query.addPair(cp3.getRoots()[0].getURL(),cp4.getRoots()); + query.addPair(cp3.getRoots()[0].toURL(),cp4.getRoots()); //There should be one translated source root assertEquals(1, reg.getSourceRoots().size()); assertEquals(1, reg.getResults().size()); --- a/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/BinaryForSourceQueryTest.java +++ a/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/BinaryForSourceQueryTest.java @@ -90,17 +90,17 @@ assertNotNull(binaryRoot2); SFBQImpl.clear(); CPProvider.clear(); - SFBQImpl.register(srcRoot2.getURL(), binaryRoot2.getURL()); + SFBQImpl.register(srcRoot2.toURL(), binaryRoot2.toURL()); CPProvider.register(srcRoot2, ClassPath.SOURCE, ClassPathSupport.createClassPath(new FileObject[] {srcRoot2})); CPProvider.register(srcRoot2, ClassPath.EXECUTE, ClassPathSupport.createClassPath(new FileObject[] {binaryRoot2})); } public void testQuery() throws Exception { - BinaryForSourceQuery.Result result = BinaryForSourceQuery.findBinaryRoots(srcRoot1.getURL()); + BinaryForSourceQuery.Result result = BinaryForSourceQuery.findBinaryRoots(srcRoot1.toURL()); assertEquals(0,result.getRoots().length); - result = BinaryForSourceQuery.findBinaryRoots(srcRoot2.getURL()); + result = BinaryForSourceQuery.findBinaryRoots(srcRoot2.toURL()); assertEquals(1,result.getRoots().length); - assertEquals(binaryRoot2.getURL(), result.getRoots()[0]); + assertEquals(binaryRoot2.toURL(), result.getRoots()[0]); } public static class SFBQImpl implements SourceForBinaryQueryImplementation { --- a/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java +++ a/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java @@ -97,19 +97,19 @@ zos.closeEntry(); zos.close(); sr2 = FileUtil.getArchiveRoot(FileUtil.toFileObject(zf)); - map.put(br1.getURL(), Collections.singletonList(sr1)); - map.put(br2.getURL(), Collections.singletonList(sr2)); + map.put(br1.toURL(), Collections.singletonList(sr1)); + map.put(br2.toURL(), Collections.singletonList(sr2)); } public void testSFBQImpl () throws Exception { MockServices.setServices(LegacySFBQImpl.class); - SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); assertTrue(res.preferSources()); - res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + res = SourceForBinaryQuery.findSourceRoots2(br2.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); @@ -123,13 +123,13 @@ public void testSFBQImpl2 () throws Exception { MockServices.setServices(LeafSFBQImpl.class); - SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); assertFalse(res.preferSources()); - res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + res = SourceForBinaryQuery.findSourceRoots2(br2.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); @@ -146,13 +146,13 @@ public void testSFBQDelegatingImpl () throws Exception { DelegatingSFBImpl.impl = new LegacySFBQImpl(); MockServices.setServices(DelegatingSFBImpl.class); - SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); assertTrue(res.preferSources()); - res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + res = SourceForBinaryQuery.findSourceRoots2(br2.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); @@ -169,13 +169,13 @@ public void testSFBQDelegatingImpl2 () throws Exception { DelegatingSFBImpl.impl = new LeafSFBQImpl(); MockServices.setServices(DelegatingSFBImpl.class); - SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr1), Arrays.asList(res.getRoots())); assertFalse(res.preferSources()); - res = SourceForBinaryQuery.findSourceRoots2(br2.getURL()); + res = SourceForBinaryQuery.findSourceRoots2(br2.toURL()); assertNotNull(res); assertEquals(1, res.getRoots().length); assertEquals(Collections.singletonList(sr2), Arrays.asList(res.getRoots())); @@ -191,7 +191,7 @@ public void testListening () throws Exception { DelegatingSFBImpl.impl = new LeafSFBQImpl(); MockServices.setServices(DelegatingSFBImpl.class); - SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.getURL()); + SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(br1.toURL()); final AtomicBoolean fired = new AtomicBoolean (); ChangeListener l; res.addChangeListener( l = new ChangeListener() { --- a/api.xml/nbproject/project.xml +++ a/api.xml/nbproject/project.xml @@ -50,17 +50,33 @@ org.netbeans.api.xml + org.openide.filesystems + + + + 7.57 + + + org.openide.loaders - org.openide.filesystems + org.openide.nodes - 6.2 + 7.23 + + + + org.openide.text + + + + 6.16 @@ -79,22 +95,6 @@ 8.0 - - org.openide.nodes - - - - 7.23 - - - - org.openide.text - - - - 6.16 - - --- a/api.xml/src/org/netbeans/api/xml/parsers/DocumentInputSource.java +++ a/api.xml/src/org/netbeans/api/xml/parsers/DocumentInputSource.java @@ -46,7 +46,6 @@ import java.io.*; import java.net.URL; -import java.util.*; import javax.swing.text.Document; @@ -112,15 +111,10 @@ if (system == null) { Object obj = doc.getProperty(Document.StreamDescriptionProperty); if (obj instanceof DataObject) { - try { DataObject dobj = (DataObject) obj; FileObject fo = dobj.getPrimaryFile(); - URL url = fo.getURL(); + URL url = fo.toURL(); system = url.toExternalForm(); - } catch (IOException io) { - ErrorManager emgr = (ErrorManager) Lookup.getDefault().lookup(ErrorManager.class); - emgr.notify(io); - } } else { ErrorManager emgr = (ErrorManager) Lookup.getDefault().lookup(ErrorManager.class); emgr.log("XML:DocumentInputSource:Unknown stream description:" + obj); --- a/api.xml/src/org/netbeans/spi/xml/cookies/DataObjectAdapters.java +++ a/api.xml/src/org/netbeans/spi/xml/cookies/DataObjectAdapters.java @@ -45,9 +45,6 @@ package org.netbeans.spi.xml.cookies; import java.io.Reader; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; import javax.swing.text.Document; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -57,8 +54,6 @@ import org.netbeans.api.xml.parsers.DocumentInputSource; import org.netbeans.api.xml.services.UserCatalog; import org.openide.cookies.EditorCookie; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.loaders.DataObject; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -179,24 +174,7 @@ * @return system Id of dataObject */ private static String getSystemId (DataObject dataObject) { - String systemId = null; - try { - FileObject fileObject = dataObject.getPrimaryFile(); - URL url = fileObject.getURL(); - try { - systemId = new URI(url.toString()).toASCIIString(); - } catch (URISyntaxException ex) { - // if cannot be converted to URI, return at least external form - // instead of returning null - systemId = url.toExternalForm(); - Util.THIS.debug(ex); - } - } catch (FileStateInvalidException exc) { - if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (exc); - - // nothing to do -> return null; //??? - } - return systemId; + return dataObject.getPrimaryFile().toURI().toASCIIString(); } private static synchronized SAXParserFactory getSAXParserFactory () throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { --- a/api.xml/src/org/netbeans/spi/xml/cookies/SharedXMLSupport.java +++ a/api.xml/src/org/netbeans/spi/xml/cookies/SharedXMLSupport.java @@ -54,7 +54,6 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.openide.filesystems.FileStateInvalidException; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; @@ -239,11 +238,6 @@ // same as one catched by ErrorHandler // because we do not have content handler - } catch (FileStateInvalidException ex) { - - // bad luck report as fatal error - handler.fatalError(new SAXParseException(ex.getLocalizedMessage(), locator, ex)); - } catch (IOException ex) { // bad luck probably because cannot resolve entity --- a/apisupport.ant/nbproject/project.xml +++ a/apisupport.ant/nbproject/project.xml @@ -259,7 +259,7 @@ - 7.46 + 7.57 --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java +++ a/apisupport.ant/src/org/netbeans/modules/apisupport/project/NbModuleProviderImpl.java @@ -194,7 +194,7 @@ if (src != null) { FileObject layerXml = src.getFileObject(layer); if (layerXml != null) { - otherLayerURLs.add(layerXml.getURL()); + otherLayerURLs.add(layerXml.toURL()); } } } --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java +++ a/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java @@ -72,9 +72,7 @@ import org.netbeans.spi.project.support.ant.AntProjectEvent; import org.netbeans.spi.project.support.ant.AntProjectListener; import org.netbeans.spi.project.support.ant.PropertyUtils; -import org.openide.ErrorManager; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.WeakListeners; import org.openide.xml.XMLUtil; @@ -128,13 +126,7 @@ URL generatedClasses = FileUtil.urlForArchiveOrDir(project.getGeneratedClassesDirectory()); URL generatedUnitTestClasses = FileUtil.urlForArchiveOrDir(project.getTestGeneratedClassesDirectory("unit")); URL generatedFunctionalTestClasses = FileUtil.urlForArchiveOrDir(project.getTestGeneratedClassesDirectory("qa-functional")); - String fileU; - try { - fileU = file.getURL().toString(); - } catch (FileStateInvalidException x) { - LOG.log(Level.INFO, null, x); - return null; - } + String fileU = file.toURL().toString(); if (srcDir != null && (FileUtil.isParentOf(srcDir, file) || file == srcDir || fileU.startsWith(generatedClasses.toString()))) { // Regular sources. @@ -151,11 +143,7 @@ return execute; } else if (type.equals(ClassPath.SOURCE)) { if (source == null) { - try { - source = ClassPathSupport.createClassPath(srcDir.getURL(), generatedClasses); - } catch (FileStateInvalidException x) { - LOG.log(Level.INFO, null, x); - } + source = ClassPathSupport.createClassPath(srcDir.toURL(), generatedClasses); } return source; } @@ -177,11 +165,7 @@ return testExecute; } else if (type.equals(ClassPath.SOURCE)) { if (testSource == null) { - try { - testSource = ClassPathSupport.createClassPath(testSrcDir.getURL(), generatedUnitTestClasses); - } catch (FileStateInvalidException x) { - LOG.log(Level.INFO, null, x); - } + testSource = ClassPathSupport.createClassPath(testSrcDir.toURL(), generatedUnitTestClasses); } return testSource; } @@ -190,11 +174,7 @@ // Functional tests. if (type.equals(ClassPath.SOURCE)) { if (funcTestSource == null) { - try { - funcTestSource = ClassPathSupport.createClassPath(funcTestSrcDir.getURL(), generatedFunctionalTestClasses); - } catch (FileStateInvalidException x) { - LOG.log(Level.INFO, null, x); - } + funcTestSource = ClassPathSupport.createClassPath(funcTestSrcDir.toURL(), generatedFunctionalTestClasses); } return funcTestSource; } else if (type.equals(ClassPath.COMPILE)) { @@ -212,15 +192,10 @@ } } else if (classesDir != null && (classesDir.equals(file) || FileUtil.isParentOf(classesDir,file))) { if (ClassPath.EXECUTE.equals(type)) { - try { - List roots = new ArrayList(); - roots.add ( ClassPathSupport.createResource(classesDir.getURL())); - roots.addAll(createCompileClasspath().getResources()); - return ClassPathSupport.createClassPath (roots); - } catch (FileStateInvalidException e) { - ErrorManager.getDefault().notify (e); - return null; - } + List roots = new ArrayList(); + roots.add ( ClassPathSupport.createResource(classesDir.toURL())); + roots.addAll(createCompileClasspath().getResources()); + return ClassPathSupport.createClassPath (roots); } } else if (testClassesDir != null && (testClassesDir.equals(file) || FileUtil.isParentOf(testClassesDir,file))) { if (ClassPath.EXECUTE.equals(type)) { --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ActionFilterNode.java +++ a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ActionFilterNode.java @@ -50,13 +50,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Action; -import org.openide.ErrorManager; import org.openide.actions.EditAction; import org.openide.actions.FindAction; import org.openide.loaders.DataObject; import org.openide.actions.OpenAction; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.nodes.FilterNode; import org.openide.nodes.Node; @@ -204,19 +202,14 @@ } public boolean hasJavadoc() { - try { - boolean rNotNull = resource != null; - int jLength = JavadocForBinaryQuery.findJavadoc(cpRoot.getURL()).getRoots().length; - return rNotNull && jLength > 0; - } catch (FileStateInvalidException fsi) { - return false; - } + boolean rNotNull = resource != null; + int jLength = JavadocForBinaryQuery.findJavadoc(cpRoot.toURL()).getRoots().length; + return rNotNull && jLength > 0; } public void showJavadoc() { - try { String relativeName = FileUtil.getRelativePath(cpRoot, resource); - URL[] urls = JavadocForBinaryQuery.findJavadoc(cpRoot.getURL()).getRoots(); + URL[] urls = JavadocForBinaryQuery.findJavadoc(cpRoot.toURL()).getRoots(); URL pageURL; if (relativeName.length() == 0) { pageURL = ShowJavadocAction.findJavadoc("overview-summary.html",urls); //NOI18N @@ -231,9 +224,6 @@ pageURL = ShowJavadocAction.findJavadoc(javadocFileName, urls); } ShowJavadocAction.showJavaDoc(pageURL,relativeName.replace('/','.')); //NOI18N - } catch (FileStateInvalidException fsi) { - ErrorManager.getDefault().notify(fsi); - } } } --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/LibrariesSourceGroup.java +++ a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/LibrariesSourceGroup.java @@ -47,9 +47,7 @@ import java.beans.PropertyChangeListener; import javax.swing.Icon; import org.netbeans.api.project.SourceGroup; -import org.openide.ErrorManager; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; // XXX this class is more or less copy-pasted from j2seproject. @@ -88,12 +86,7 @@ } public String getName() { - try { - return root.getURL().toExternalForm(); - } catch (FileStateInvalidException fsi) { - ErrorManager.getDefault().notify(fsi); - return root.toString(); - } + return root.toURL().toExternalForm(); } public String getDisplayName() { --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/PlatformNode.java +++ a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/PlatformNode.java @@ -58,13 +58,11 @@ import java.util.Set; import javax.swing.Action; import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.queries.JavadocForBinaryQuery; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.nodes.Children; import org.openide.nodes.AbstractNode; @@ -72,7 +70,6 @@ import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; -import org.openide.util.Utilities; import org.openide.util.WeakListeners; import org.openide.ErrorManager; import org.netbeans.api.java.platform.JavaPlatform; @@ -205,10 +202,9 @@ FileObject[] roots = platform.getBootstrapLibraries().getRoots(); List result = new ArrayList(roots.length); for (int i=0; i actual = new TreeSet(); for (Project sp : spp.getSubprojects()) { - actual.add(sp.getProjectDirectory().getURL().toExternalForm()); + actual.add(sp.getProjectDirectory().toURL().toExternalForm()); } assertEquals("correct subprojects for " + project, expected.toString(), actual.toString()); } --- a/apisupport.project/nbproject/project.xml +++ a/apisupport.project/nbproject/project.xml @@ -219,7 +219,7 @@ - 7.43 + 7.57 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/api/LayerHandle.java +++ a/apisupport.project/src/org/netbeans/modules/apisupport/project/api/LayerHandle.java @@ -67,7 +67,6 @@ import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileRenameEvent; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileUtil; import org.openide.filesystems.MultiFileSystem; @@ -151,11 +150,7 @@ return fs = FileUtil.createMemoryFileSystem(); } } - try { - fs = new DualLayers(new WritableXMLFileSystem(xml.getURL(), cookie = LayerUtils.cookieForFile(xml), LayerUtils.findResourceCP(project))); - } catch (FileStateInvalidException e) { - throw new AssertionError(e); - } + fs = new DualLayers(new WritableXMLFileSystem(xml.toURL(), cookie = LayerUtils.cookieForFile(xml), LayerUtils.findResourceCP(project))); cookie.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { //System.err.println("changed in mem"); --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/LayerUtils.java +++ a/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/LayerUtils.java @@ -64,7 +64,6 @@ import org.netbeans.api.project.ProjectUtils; import org.netbeans.api.project.SourceGroup; import org.netbeans.api.project.Sources; -import org.netbeans.modules.apisupport.project.api.Util; import org.netbeans.modules.apisupport.project.api.LayerHandle; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.xml.tax.cookies.TreeEditorCookie; @@ -74,13 +73,11 @@ import org.netbeans.tax.TreeException; import org.netbeans.tax.TreeObject; import org.netbeans.tax.io.TreeStreamResult; -import org.openide.ErrorManager; import org.openide.filesystems.FileAttributeEvent; import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileRenameEvent; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileSystem.AtomicAction; import org.openide.filesystems.FileUtil; @@ -125,13 +122,12 @@ if (cp == null) { return new URL[] {u}; } - try { if (u.getProtocol().equals("nbres")) { // NOI18N String path = u.getFile(); if (path.startsWith("/")) path = path.substring(1); // NOI18N FileObject fo = cp.findResource(path); if (fo != null) { - return new URL[] {fo.getURL()}; + return new URL[] {fo.toURL()}; } } else if (u.getProtocol().equals("nbresloc")) { // NOI18N List urls = new ArrayList(); @@ -164,16 +160,13 @@ String trypath = folder + name + trysuffix + ext; FileObject fo = cp.findResource(trypath); if (fo != null) { - urls.add(fo.getURL()); + urls.add(fo.toURL()); } } if (!urls.isEmpty()) { return urls.toArray(new URL[urls.size()]); } } - } catch (FileStateInvalidException fsie) { - Util.err.notify(ErrorManager.WARNING, fsie); - } return new URL[] {u}; } @@ -259,7 +252,7 @@ //System.err.println("openDocumentRoot: really opening"); boolean oldDirty = dirty; int oldStatus = getStatus(); - root = new XMLParsingSupport().parse(new InputSource(f.getURL().toExternalForm())); + root = new XMLParsingSupport().parse(new InputSource(f.toURL().toExternalForm())); problem = null; dirty = false; pcs.firePropertyChange(PROP_DIRTY, oldDirty, false); --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/OpenLayerFilesAction.java +++ a/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/OpenLayerFilesAction.java @@ -68,7 +68,6 @@ import org.openide.cookies.EditorCookie; import org.openide.cookies.LineCookie; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.loaders.DataObject; @@ -96,17 +95,13 @@ protected @Override void performAction(final Node[] activatedNodes) { RequestProcessor.getDefault().post(new Runnable() { public @Override void run() { - try { FileObject f = activatedNodes[0].getCookie(DataObject.class).getPrimaryFile(); openLayersForFile(f); - } catch (FileStateInvalidException ex) { - Exceptions.printStackTrace(ex); - } } }); } - private void openLayersForFile(FileObject f) throws FileStateInvalidException { + private void openLayersForFile(FileObject f) { URL[] location = (URL[]) f.getAttribute("layers"); // NOI18N if (location != null) { for (URL u : location) { @@ -124,7 +119,7 @@ private static void openLayerFileAndFind(DataObject layerDataObject, final FileObject originalF) { try { - InputSource in = new InputSource(layerDataObject.getPrimaryFile().getURL().toExternalForm()); + InputSource in = new InputSource(layerDataObject.getPrimaryFile().toURL().toExternalForm()); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); final AtomicInteger line = new AtomicInteger(); --- a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/layers/WritableXMLFileSystemTest.java +++ a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/layers/WritableXMLFileSystemTest.java @@ -122,7 +122,7 @@ assertEquals(5L, x.getSize()); assertEquals("stuff", x.asText("UTF-8")); assertEquals("x.txt", x.getAttribute("WritableXMLFileSystem.url")); - assertEquals("[" + l.f.getURL() + "]", Arrays.toString((URL[]) x.getAttribute("layers"))); + assertEquals("[" + l.f.toURL() + "]", Arrays.toString((URL[]) x.getAttribute("layers"))); fs = new Layer("", Collections.singletonMap("subdir/x.txt", "more stuff")).read(); x = fs.findResource("x"); assertNotNull(x); @@ -138,7 +138,7 @@ FileObject orgTest = FileUtil.createFolder(new File(orig.folder, "org/test")); FileObject lf = orig.f.copy(orgTest, "layer", "xml"); SavableTreeEditorCookie cookie = LayerUtils.cookieForFile(lf); - FileSystem fs = new WritableXMLFileSystem(lf.getURL(), cookie, + FileSystem fs = new WritableXMLFileSystem(lf.toURL(), cookie, ClassPathSupport.createClassPath(new FileObject[] { FileUtil.toFileObject(orig.folder) } )); FileObject x = fs.findResource("x"); assertNotNull(x); @@ -779,7 +779,7 @@ */ public WritableXMLFileSystem read() throws Exception { cookie = LayerUtils.cookieForFile(f); - return new WritableXMLFileSystem(f.getURL(), cookie, ClassPathSupport.createClassPath(System.getProperty("java.class.path"))); + return new WritableXMLFileSystem(f.toURL(), cookie, ClassPathSupport.createClassPath(System.getProperty("java.class.path"))); } /** * Write the filesystem to the layer and retrieve the new contents. --- a/apisupport.refactoring/nbproject/project.xml +++ a/apisupport.refactoring/nbproject/project.xml @@ -202,7 +202,7 @@ - 6.2 + 7.57 --- a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/LayerHints.java +++ a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/LayerHints.java @@ -73,7 +73,6 @@ import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; @@ -181,14 +180,7 @@ cancelAll(); return; } - final URL layerURL; - try { - layerURL = handle.getLayerFile().getURL(); - } catch (FileStateInvalidException x) { - LOG.log(Level.INFO, null, x); - cancelAll(); - return; - } + final URL layerURL = handle.getLayerFile().toURL(); String expectedLayers = "[" + layerURL + "]"; List errors = new ArrayList(); RunnableFuture> linesFuture = new FutureTask>(new Callable>() { --- a/apisupport.refactoring/src/org/netbeans/modules/apisupport/refactoring/NbWhereUsedRefactoringPlugin.java +++ a/apisupport.refactoring/src/org/netbeans/modules/apisupport/refactoring/NbWhereUsedRefactoringPlugin.java @@ -214,7 +214,7 @@ String text = doc.getText(0, doc.getLength()); assert text.indexOf('\r') == -1; // should be in newline format only when a Document InputSource in = new InputSource(new StringReader(text)); - in.setSystemId(parentFile.getURL().toExternalForm()); + in.setSystemId(parentFile.toURL().toExternalForm()); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); final int[] lineAndColStartAndEnd = new int[4]; --- a/apisupport.refactoring/test/qa-functional/src/org/netbeans/modules/apisupport/refactoring/TestUtility.java +++ a/apisupport.refactoring/test/qa-functional/src/org/netbeans/modules/apisupport/refactoring/TestUtility.java @@ -45,11 +45,10 @@ package org.netbeans.modules.apisupport.refactoring; import java.io.File; -import org.openide.filesystems.FileStateInvalidException; public class TestUtility { - public static File getFile(File dataDir,String projectName, String fileName) throws FileStateInvalidException { + public static File getFile(File dataDir,String projectName, String fileName) { String result = dataDir.getAbsolutePath() +"/" + projectName + "/" + fileName; System.out.println("looking for file: " + result); return new File(result); --- a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/DummyModuleInfo.java +++ a/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/DummyModuleInfo.java @@ -73,12 +73,7 @@ // List urls = new ArrayList(Math.max(kids.length, 1)); // List // for (int i = 0; i < kids.length; i++) { // if (kids[i].hasExt("xml")) { -// try { -// urls.add(kids[i].getURL()); -// } -// catch (FileStateInvalidException e) { -// Exceptions.printStackTrace(e); -// } +// urls.add(kids[i].toURL()); // } // } // try { --- a/core.startup/nbproject/project.xml +++ a/core.startup/nbproject/project.xml @@ -63,7 +63,7 @@ - 7.55 + 7.57 --- a/core.startup/src/org/netbeans/core/startup/Main.java +++ a/core.startup/src/org/netbeans/core/startup/Main.java @@ -58,7 +58,6 @@ import org.netbeans.Stamps; import org.netbeans.Util; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.Repository; import org.openide.modules.InstalledFileLocator; @@ -133,11 +132,7 @@ themeURL = null; } } else { - try { - themeURL = fo.getURL(); - } catch (FileStateInvalidException fsie) { - //do nothing - } + themeURL = fo.toURL(); } } } finally { --- a/core.startup/src/org/netbeans/core/startup/ModuleList.java +++ a/core.startup/src/org/netbeans/core/startup/ModuleList.java @@ -1275,7 +1275,7 @@ InputStream is = xmlfile.getInputStream(); try { InputSource src = new InputSource(is); - src.setSystemId(xmlfile.getURL().toString()); + src.setSystemId(xmlfile.toURL().toString()); try { dirtyprops.put(cnb, readStatus(src, null)); } catch (SAXException saxe) { @@ -1619,7 +1619,7 @@ is = f.getInputStream(); InputSource src = new InputSource(is); // Make sure any includes etc. are handled properly: - src.setSystemId(f.getURL().toExternalForm()); + src.setSystemId(f.toURL().toExternalForm()); if (reader == null) { try { reader = XMLUtil.createXMLReader(); --- a/core.startup/src/org/netbeans/core/startup/NbInstaller.java +++ a/core.startup/src/org/netbeans/core/startup/NbInstaller.java @@ -48,7 +48,6 @@ import java.io.DataOutputStream; import java.io.File; import java.io.IOException; -import java.lang.reflect.Method; import java.net.URL; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -78,12 +77,10 @@ import org.netbeans.Module; import org.netbeans.ModuleInstaller; import org.netbeans.ModuleManager; -import org.netbeans.ProxyClassLoader; import org.netbeans.Stamps; import org.netbeans.Util; import org.netbeans.core.startup.layers.ModuleLayeredFileSystem; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.modules.Dependency; import org.openide.modules.ModuleInstall; @@ -92,7 +89,6 @@ import org.openide.util.NbCollections; import org.openide.util.SharedClassObject; import org.openide.util.NbBundle; -import org.openide.util.Utilities; import org.openide.util.lookup.InstanceContent; import org.xml.sax.SAXException; @@ -734,11 +730,7 @@ List urls = new ArrayList(Math.max(kids.length, 1)); for (FileObject kid : kids) { if (kid.hasExt("xml")) { // NOI18N - try { - urls.add(kid.getURL()); - } catch (FileStateInvalidException e) { - Util.err.log(Level.WARNING, null, e); - } + urls.add(kid.toURL()); } } try { --- a/java.api.common/nbproject/project.xml +++ a/java.api.common/nbproject/project.xml @@ -174,7 +174,7 @@ - 7.20 + 7.57 --- a/java.api.common/src/org/netbeans/modules/java/api/common/applet/AppletSupport.java +++ a/java.api.common/src/org/netbeans/modules/java/api/common/applet/AppletSupport.java @@ -164,7 +164,7 @@ path = path.substring(0, path.length()-5); String codebase = FileUtil.getRelativePath(buildDir, classesDir); if (codebase == null) { - codebase = classesDir.getURL().toString(); + codebase = classesDir.toURL().toString(); } fillInFile(writer, path + "." + CLASS_EXT, "codebase=\"" + codebase + "\""); // NOI18N } finally { @@ -205,7 +205,7 @@ /** * @return URL of the html file with the same name as sibling */ - public static URL generateHtmlFileURL(FileObject appletFile, FileObject buildDir, FileObject classesDir, String activePlatform) throws FileStateInvalidException { + public static URL generateHtmlFileURL(FileObject appletFile, FileObject buildDir, FileObject classesDir, String activePlatform) { FileObject html = null; IOException ex = null; if ((appletFile == null) || (buildDir == null) || (classesDir == null)) { @@ -252,11 +252,7 @@ } } else { - try { - url = htmlFile.getURL(); - } catch (FileStateInvalidException f) { - ErrorManager.getDefault().notify(f); - } + url = htmlFile.toURL(); } return url; } --- a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathExtender.java +++ a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathExtender.java @@ -46,7 +46,6 @@ import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; @@ -90,13 +89,7 @@ } URI[] archiveFileURIs = new URI[archiveFiles.length]; for (int i = 0; i < archiveFiles.length; i++) { - try { - archiveFileURIs[i] = archiveFiles[i].getURL().toURI(); - } catch (URISyntaxException ex) { - IOException ioe = new IOException(); - ioe.initCause(ex); - throw ioe; - } + archiveFileURIs[i] = archiveFiles[i].toURI(); } return this.delegate.handleRoots(archiveFileURIs, classPathId, projectXMLElementName, ClassPathModifier.ADD); } --- a/java.api.common/src/org/netbeans/modules/java/api/common/project/BaseActionProvider.java +++ a/java.api.common/src/org/netbeans/modules/java/api/common/project/BaseActionProvider.java @@ -1668,8 +1668,6 @@ } String activePlatformName = evaluator.getProperty("platform.active"); //NOI18N url = AppletSupport.generateHtmlFileURL(file, buildDir, classesDir, activePlatformName); - } catch (FileStateInvalidException fe) { - //ingore } catch (IOException ioe) { ErrorManager.getDefault().notify(ioe); return null; @@ -1707,8 +1705,6 @@ String activePlatformName = evaluator.getProperty("platform.active"); //NOI18N url = AppletSupport.getHTMLPageURL(targetHtml, activePlatformName); } - } catch (FileStateInvalidException fe) { - //ingore } catch (IOException ioe) { ErrorManager.getDefault().notify(ioe); return null; --- a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/ActionFilterNode.java +++ a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/ActionFilterNode.java @@ -59,7 +59,6 @@ import org.openide.loaders.DataObject; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.nodes.FilterNode; import org.openide.nodes.Node; @@ -391,11 +390,7 @@ RP.execute(new Runnable() { @Override public void run() { - try { - JavadocForBinaryQuery.findJavadoc(cpRoot.getURL()); - } catch (FileStateInvalidException ex) { - Exceptions.printStackTrace(ex); - } + JavadocForBinaryQuery.findJavadoc(cpRoot.toURL()); } }); } @@ -403,18 +398,13 @@ @Override public boolean hasJavadoc() { - try { - return resource != null && JavadocForBinaryQuery.findJavadoc(cpRoot.getURL()).getRoots().length>0; - } catch (FileStateInvalidException fsi) { - return false; - } + return resource != null && JavadocForBinaryQuery.findJavadoc(cpRoot.toURL()).getRoots().length>0; } @Override public void showJavadoc() { - try { String relativeName = FileUtil.getRelativePath(cpRoot,resource); - URL[] urls = JavadocForBinaryQuery.findJavadoc(cpRoot.getURL()).getRoots(); + URL[] urls = JavadocForBinaryQuery.findJavadoc(cpRoot.toURL()).getRoots(); URL pageURL; if (relativeName.length()==0) { pageURL = ShowJavadocAction.findJavadoc ("overview-summary.html",urls); //NOI18N @@ -431,9 +421,6 @@ pageURL = ShowJavadocAction.findJavadoc (javadocFileName,urls); } ShowJavadocAction.showJavaDoc(pageURL,relativeName.replace('/','.')); //NOI18N - } catch (FileStateInvalidException fsi) { - Exceptions.printStackTrace(fsi); - } } } --- a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/LibrariesSourceGroup.java +++ a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/LibrariesSourceGroup.java @@ -47,10 +47,8 @@ import java.beans.PropertyChangeListener; import javax.swing.Icon; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.netbeans.api.project.SourceGroup; -import org.openide.util.Exceptions; /** @@ -96,12 +94,7 @@ } public String getName() { - try { - return root.getURL().toExternalForm(); - } catch (FileStateInvalidException fsi) { - Exceptions.printStackTrace(fsi); - return root.toString(); - } + return root.toURL().toExternalForm(); } public String getDisplayName() { --- a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/PlatformNode.java +++ a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/PlatformNode.java @@ -65,7 +65,6 @@ import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.queries.JavadocForBinaryQuery; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObjectNotFoundException; import org.openide.nodes.Children; @@ -84,7 +83,6 @@ import org.openide.loaders.DataFolder; import org.openide.loaders.DataObject; import org.openide.util.ChangeSupport; -import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.Parameters; import org.openide.util.actions.SystemAction; @@ -240,11 +238,10 @@ FileObject[] roots = platform.getBootstrapLibraries().getRoots(); List result = new ArrayList(roots.length); for (int i = 0; i < roots.length; i++) { - try { FileObject file; Icon icon; Icon openedIcon; - if ("jar".equals(roots[i].getURL().getProtocol())) { //NOI18N + if ("jar".equals(roots[i].toURL().getProtocol())) { //NOI18N file = FileUtil.getArchiveFile (roots[i]); icon = openedIcon = ImageUtilities.loadImageIcon(ARCHIVE_ICON, false); } @@ -257,9 +254,6 @@ if (file.isValid()) { result.add (new LibrariesSourceGroup(roots[i],file.getNameExt(),icon, openedIcon)); } - } catch (FileStateInvalidException e) { - Exceptions.printStackTrace(e); - } } return result; } --- a/java.api.common/test/unit/src/org/netbeans/modules/java/api/common/queries/GeneratedSourceRootTest.java +++ a/java.api.common/test/unit/src/org/netbeans/modules/java/api/common/queries/GeneratedSourceRootTest.java @@ -142,16 +142,16 @@ FileObject src = d.getFileObject("src"); FileObject test = d.getFileObject("test"); FileObject stuff = d.getFileObject("build/generated-sources/stuff"); - URL classes = new URL(d.getURL(), "build/classes/"); - URL testClasses = new URL(d.getURL(), "build/test/classes/"); + URL classes = new URL(d.toURL(), "build/classes/"); + URL testClasses = new URL(d.toURL(), "build/test/classes/"); FileObject xgen = stuff.getFileObject("net/nowhere/XGen.java"); assertEquals(Arrays.asList(src, stuff), Arrays.asList(SourceForBinaryQuery.findSourceRoots(classes).getRoots())); assertEquals(Arrays.asList(test), Arrays.asList(SourceForBinaryQuery.findSourceRoots(testClasses).getRoots())); - assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(src.getURL()).getRoots())); - assertEquals(Collections.singletonList(testClasses), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(test.getURL()).getRoots())); - assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(stuff.getURL()).getRoots())); - assertEquals(Collections.singletonList(src.getURL()), Arrays.asList(UnitTestForSourceQuery.findSources(test))); - assertEquals(Collections.singletonList(test.getURL()), Arrays.asList(UnitTestForSourceQuery.findUnitTests(src))); + assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(src.toURL()).getRoots())); + assertEquals(Collections.singletonList(testClasses), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(test.toURL()).getRoots())); + assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(stuff.toURL()).getRoots())); + assertEquals(Collections.singletonList(src.toURL()), Arrays.asList(UnitTestForSourceQuery.findSources(test))); + assertEquals(Collections.singletonList(test.toURL()), Arrays.asList(UnitTestForSourceQuery.findUnitTests(src))); assertEquals("1.5", SourceLevelQuery.getSourceLevel(stuff)); FileBuiltQuery.Status status = FileBuiltQuery.getStatus(xgen); assertNotNull(status); @@ -164,7 +164,7 @@ FileObject ygen = FileUtil.createData(moreStuff, "net/nowhere/YGen.java"); assertEquals(new HashSet(Arrays.asList(src, stuff, moreStuff)), new HashSet(Arrays.asList(SourceForBinaryQuery.findSourceRoots(classes).getRoots()))); - assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(moreStuff.getURL()).getRoots())); + assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(moreStuff.toURL()).getRoots())); // XXX should previously created Result objects fire changes? ideally yes, but probably unnecessary assertEquals("1.5", SourceLevelQuery.getSourceLevel(moreStuff)); status = FileBuiltQuery.getStatus(ygen); @@ -181,7 +181,7 @@ Project p = createTestProject(false); FileObject d = p.getProjectDirectory(); FileObject src = d.getFileObject("src"); - URL classes = new URL(d.getURL(), "build/classes/"); + URL classes = new URL(d.toURL(), "build/classes/"); ClassPath sourcePath = ClassPath.getClassPath(src, ClassPath.SOURCE); assertEquals(Arrays.asList(src), Arrays.asList(sourcePath.getRoots())); assertEquals(Arrays.asList(src), Arrays.asList(SourceForBinaryQuery.findSourceRoots(classes).getRoots())); @@ -191,7 +191,7 @@ assertEquals(Arrays.asList(src, stuff), Arrays.asList(sourcePath.getRoots())); assertEquals(ClassPath.getClassPath(src, ClassPath.COMPILE), ClassPath.getClassPath(stuff, ClassPath.COMPILE)); assertEquals(Arrays.asList(src, stuff), Arrays.asList(SourceForBinaryQuery.findSourceRoots(classes).getRoots())); - assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(stuff.getURL()).getRoots())); + assertEquals(Collections.singletonList(classes), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(stuff.toURL()).getRoots())); FileBuiltQuery.Status status = FileBuiltQuery.getStatus(xgen); assertNotNull(status); assertFalse(status.isBuilt()); --- a/java.api.common/test/unit/src/org/netbeans/modules/java/api/common/queries/JavadocForBinaryQueryImplTest.java +++ a/java.api.common/test/unit/src/org/netbeans/modules/java/api/common/queries/JavadocForBinaryQueryImplTest.java @@ -55,7 +55,6 @@ import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.EditableProperties; import org.netbeans.spi.project.support.ant.ProjectGenerator; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.Mutex; import org.openide.util.test.MockLookup; @@ -107,7 +106,7 @@ QuerySupport.createJavadocForBinaryQuery(helper, eval); setProjectDirectory(JAVADOC_DIR, projdir.createFolder(JAVADOC_1)); - Result javadoc = javadocForBinaryQuery.findJavadoc(builddir.getURL()); + Result javadoc = javadocForBinaryQuery.findJavadoc(builddir.toURL()); assertNotNull(javadoc); URL[] roots = javadoc.getRoots(); @@ -121,8 +120,8 @@ assertEquals(getJavadocUrl(JAVADOC_2), roots[0]); } - private URL getJavadocUrl(String javadoc) throws FileStateInvalidException { - return projdir.getFileObject(javadoc).getURL(); + private URL getJavadocUrl(String javadoc) { + return projdir.getFileObject(javadoc).toURL(); } private void setProjectDirectory(final String property, final FileObject directory) throws Exception { --- a/java.j2seproject/nbproject/project.xml +++ a/java.j2seproject/nbproject/project.xml @@ -269,7 +269,7 @@ - 7.19 + 7.57 --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/J2SESourcesTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/J2SESourcesTest.java @@ -138,14 +138,14 @@ } public void testSourceRoots () throws Exception { - FileObject[] roots = SourceForBinaryQuery.findSourceRoots(classes.getURL()).getRoots(); + FileObject[] roots = SourceForBinaryQuery.findSourceRoots(classes.toURL()).getRoots(); assertNotNull (roots); assertEquals("There should be 1 src root",1,roots.length); assertTrue ("The source root is not valid", sources.isValid()); assertEquals("Invalid src root", sources, roots[0]); FileObject src2 = projdir.createFolder("src2"); addSourceRoot (helper, src2, "src2"); - roots = SourceForBinaryQuery.findSourceRoots(classes.getURL()).getRoots(); + roots = SourceForBinaryQuery.findSourceRoots(classes.toURL()).getRoots(); assertNotNull (roots); assertEquals("There should be 2 src roots", 2, roots.length); assertTrue ("The source root is not valid", sources.isValid()); @@ -199,7 +199,7 @@ //test: adding of src root should fire once URL[] newRootUrls = new URL[oldRootUrls.length+1]; System.arraycopy(oldRootUrls, 0, newRootUrls, 0, oldRootUrls.length); - newRootUrls[newRootUrls.length-1] = newRoot.getURL(); + newRootUrls[newRootUrls.length-1] = newRoot.toURL(); String[] newRootLabels = new String[oldRootLabels.length+1]; for (int i=0; i< oldRootLabels.length; i++) { newRootLabels[i] = roots.getRootDisplayName(oldRootLabels[i], oldRootProps[i]); --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/SourceRootsTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/SourceRootsTest.java @@ -125,7 +125,7 @@ URL[] srcURLs = srcs.getRootURLs(); assertNotNull ("Root URLs can not be null",srcURLs); assertEquals ("Root URLs length must be 1",1,srcURLs.length); - assertEquals("Root URLs should be "+this.sources.getURL(),this.sources.getURL(),srcURLs[0]); + assertEquals("Root URLs should be "+this.sources.toURL(),this.sources.toURL(),srcURLs[0]); SourceRoots tsts = pp.getTestSourceRoots(); srcProps = tsts.getRootProperties(); assertNotNull ("Source properties can not be null",srcProps); @@ -138,7 +138,7 @@ srcURLs = tsts.getRootURLs(); assertNotNull ("Root URLs can not be null",srcURLs); assertEquals ("Root URLs length must be 1",1,srcURLs.length); - assertEquals("Root URLs should be "+this.tests.getURL(),this.tests.getURL(),srcURLs[0]); + assertEquals("Root URLs should be "+this.tests.toURL(),this.tests.toURL(),srcURLs[0]); //Now add new source root TestListener tl = new TestListener(); srcs.addPropertyChangeListener (tl); @@ -156,8 +156,8 @@ srcURLs = srcs.getRootURLs(); assertNotNull ("Root URLs can not be null",srcURLs); assertEquals ("Root URLs length must be 2",2,srcURLs.length); - assertEquals("The first root URLs should be "+this.sources.getURL(),this.sources.getURL(),srcURLs[0]); - assertEquals("The second root URLs should be "+newRoot.getURL(),newRoot.getURL(),srcURLs[1]); + assertEquals("The first root URLs should be "+this.sources.toURL(),this.sources.toURL(),srcURLs[0]); + assertEquals("The second root URLs should be "+newRoot.toURL(),newRoot.toURL(),srcURLs[1]); Set events = tl.getEvents(); assertTrue ("PROP_ROOT_PROPERTIES has to be fired",events.contains(SourceRoots.PROP_ROOT_PROPERTIES)); assertTrue ("PROP_ROOTS has to be fired",events.contains(SourceRoots.PROP_ROOTS)); @@ -176,8 +176,8 @@ srcURLs = srcs.getRootURLs(); assertNotNull ("Root URLs can not be null",srcURLs); assertEquals ("Root URLs length must be 2",2,srcURLs.length); - assertEquals("The first root URLs should be "+this.sources.getURL(),this.sources.getURL(),srcURLs[0]); - assertEquals("The second root URLs should be "+newRoot.getURL(),newRoot.getURL(),srcURLs[1]); + assertEquals("The first root URLs should be "+this.sources.toURL(),this.sources.toURL(),srcURLs[0]); + assertEquals("The second root URLs should be "+newRoot.toURL(),newRoot.toURL(),srcURLs[1]); events = tl.getEvents(); assertEquals(Collections.singleton(SourceRoots.PROP_ROOTS), events); srcs.removePropertyChangeListener(tl); --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/classpath/BootClassPathImplementationTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/classpath/BootClassPathImplementationTest.java @@ -92,8 +92,8 @@ scratch = TestUtil.makeScratchDir(this); this.defaultPlatformBootRoot = scratch.createFolder("DefaultPlatformBootRoot"); this.explicitPlatformBootRoot = scratch.createFolder("ExplicitPlatformBootRoot"); - ClassPath defBCP = ClassPathSupport.createClassPath(new URL[]{defaultPlatformBootRoot.getURL()}); - ClassPath expBCP = ClassPathSupport.createClassPath(new URL[]{explicitPlatformBootRoot.getURL()}); + ClassPath defBCP = ClassPathSupport.createClassPath(new URL[]{defaultPlatformBootRoot.toURL()}); + ClassPath expBCP = ClassPathSupport.createClassPath(new URL[]{explicitPlatformBootRoot.toURL()}); tp = new TestPlatformProvider (defBCP, expBCP); MockLookup.setLayersAndInstances( new org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation(), --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/classpath/J2SEProjectClassPathModifierTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/classpath/J2SEProjectClassPathModifierTest.java @@ -117,20 +117,20 @@ final FileObject rootFolder = this.scratch.createFolder("Root"); final FileObject jarFile = TestFileUtils.writeZipFile(scratch, "archive.jar", "Test.properties:"); final FileObject jarRoot = FileUtil.getArchiveRoot(jarFile); - ProjectClassPathModifier.addRoots (new URL[] {rootFolder.getURL()}, this.src, ClassPath.COMPILE); + ProjectClassPathModifier.addRoots (new URL[] {rootFolder.toURL()}, this.src, ClassPath.COMPILE); String cp = this.eval.getProperty("javac.classpath"); assertNotNull (cp); String[] cpRoots = PropertyUtils.tokenizePath (cp); assertNotNull (cpRoots); assertEquals(1,cpRoots.length); assertEquals(rootFolder,this.helper.resolveFileObject(cpRoots[0])); - ProjectClassPathModifier.removeRoots (new URL[] {rootFolder.getURL()},this.src, ClassPath.COMPILE); + ProjectClassPathModifier.removeRoots (new URL[] {rootFolder.toURL()},this.src, ClassPath.COMPILE); cp = this.eval.getProperty("javac.classpath"); assertNotNull (cp); cpRoots = PropertyUtils.tokenizePath (cp); assertNotNull (cpRoots); assertEquals(0,cpRoots.length); - ProjectClassPathModifier.addRoots(new URL[] {jarRoot.getURL()},this.test,ClassPath.EXECUTE); + ProjectClassPathModifier.addRoots(new URL[] {jarRoot.toURL()},this.test,ClassPath.EXECUTE); cp = this.eval.getProperty("run.test.classpath"); assertNotNull (cp); cpRoots = PropertyUtils.tokenizePath (cp); @@ -162,7 +162,7 @@ String[] cpRoots = PropertyUtils.tokenizePath (cp); assertNotNull (cpRoots); assertEquals(1,cpRoots.length); - URI projectURI = URI.create(output.getProject().getProjectDirectory().getURL().toExternalForm()); + URI projectURI = URI.create(output.getProject().getProjectDirectory().toURL().toExternalForm()); URI expected = projectURI.resolve(output.getArtifactLocations()[0]); assertEquals(expected,this.helper.resolveFile(cpRoots[0]).toURI()); ProjectClassPathModifier.removeAntArtifacts(new AntArtifact[] {output}, new URI[] {output.getArtifactLocations()[0]},this.src, ClassPath.COMPILE); @@ -180,7 +180,7 @@ assertNotNull (impls); assertEquals(1,impls.length); FileObject libRoot = this.scratch.createFolder("libRoot"); - impls[0].setContent("classpath",Collections.singletonList(libRoot.getURL())); + impls[0].setContent("classpath",Collections.singletonList(libRoot.toURL())); Library[] libs =LibraryManager.getDefault().getLibraries(); assertNotNull (libs); assertEquals(1,libs.length); @@ -248,7 +248,7 @@ final File jar = FileUtil.toFile(jarFile); assertNotNull(jar); final FileObject jarRoot = FileUtil.getArchiveRoot(jarFile); - final URL rootFolderURL = rootFolder.getURL(); + final URL rootFolderURL = rootFolder.toURL(); ProjectClassPathModifier.addRoots (new URL[] {rootFolderURL}, this.src, ClassPath.COMPILE); String cp = this.eval.getProperty("javac.classpath"); assertNotNull (cp); @@ -264,7 +264,7 @@ cpRoots = PropertyUtils.tokenizePath (cp); assertNotNull (cpRoots); assertEquals(0,cpRoots.length); - final URL jarRootURL = jarRoot.getURL(); + final URL jarRootURL = jarRoot.toURL(); ProjectClassPathModifier.addRoots(new URL[] {jarRootURL},this.test,ClassPath.EXECUTE); cp = this.eval.getProperty("run.test.classpath"); assertNotNull (cp); @@ -303,7 +303,7 @@ final ClassPath cp = ClassPath.getClassPath(srcGrp.getRootFolder(), JavaClassPathConstants.PROCESSOR_PATH); assertFalse(Arrays.asList(cp.getRoots()).contains(libRoot)); ProjectClassPathModifier.addRoots( - new URI[] {libRoot.getURL().toURI()}, + new URI[] {libRoot.toURI()}, srcGrp.getRootFolder(), JavaClassPathConstants.PROCESSOR_PATH); assertTrue("No lib on processor path!", Arrays.asList(cp.getRoots()).contains(libRoot)); //NOI18N --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/queries/BinaryForSourceQueryImplTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/queries/BinaryForSourceQueryImplTest.java @@ -105,15 +105,15 @@ public void testBinaryForSourceQuery() throws Exception { this.prepareProject(); FileObject folder = scratch.createFolder("SomeFolder"); - BinaryForSourceQuery.Result result = BinaryForSourceQuery.findBinaryRoots(folder.getURL()); + BinaryForSourceQuery.Result result = BinaryForSourceQuery.findBinaryRoots(folder.toURL()); assertEquals("Non-project folder does not have any source folder", 0, result.getRoots().length); folder = projdir.createFolder("SomeFolderInProject"); - result = BinaryForSourceQuery.findBinaryRoots(folder.getURL()); + result = BinaryForSourceQuery.findBinaryRoots(folder.toURL()); assertEquals("Project non build folder does not have any source folder", 0, result.getRoots().length); - result = BinaryForSourceQuery.findBinaryRoots(sources.getURL()); + result = BinaryForSourceQuery.findBinaryRoots(sources.toURL()); assertEquals("Project build folder must have source folder", 1, result.getRoots().length); - assertEquals("Project build folder must have source folder",buildClasses.getURL(),result.getRoots()[0]); - BinaryForSourceQuery.Result result2 = BinaryForSourceQuery.findBinaryRoots(sources.getURL()); + assertEquals("Project build folder must have source folder",buildClasses.toURL(),result.getRoots()[0]); + BinaryForSourceQuery.Result result2 = BinaryForSourceQuery.findBinaryRoots(sources.toURL()); assertTrue (result == result2); } --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/queries/CompiledSourceForBinaryQueryTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/queries/CompiledSourceForBinaryQueryTest.java @@ -116,12 +116,12 @@ public void testSourceForBinaryQuery() throws Exception { this.prepareProject(); FileObject folder = scratch.createFolder("SomeFolder"); - SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(folder.getURL()); + SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(folder.toURL()); assertEquals("Non-project folder does not have any source folder", 0, result.getRoots().length); folder = projdir.createFolder("SomeFolderInProject"); - result = SourceForBinaryQuery.findSourceRoots(folder.getURL()); + result = SourceForBinaryQuery.findSourceRoots(folder.toURL()); assertEquals("Project non build folder does not have any source folder", 0, result.getRoots().length); - result = SourceForBinaryQuery.findSourceRoots(buildClasses.getURL()); + result = SourceForBinaryQuery.findSourceRoots(buildClasses.toURL()); assertEquals("Project build folder must have source folder", 1, result.getRoots().length); assertEquals("Project build folder must have source folder",sources,result.getRoots()[0]); } @@ -129,7 +129,7 @@ public void testSourceForBinaryQueryListening () throws Exception { this.prepareProject(); - SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(buildClasses.getURL()); + SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(buildClasses.toURL()); assertEquals("Project build folder must have source folder", 1, result.getRoots().length); assertEquals("Project build folder must have source folder",sources,result.getRoots()[0]); TestListener tl = new TestListener (); @@ -145,7 +145,7 @@ public void testSourceForBinaryQueryMultipleSourceRoots () throws Exception { this.prepareProject(); - SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(buildClasses.getURL()); + SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(buildClasses.toURL()); assertEquals("Project build folder must have source folder", 1, result.getRoots().length); assertEquals("Project build folder must have source folder",sources,result.getRoots()[0]); TestListener tl = new TestListener (); --- a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/queries/UnitTestForSourceQueryImplTest.java +++ a/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/queries/UnitTestForSourceQueryImplTest.java @@ -122,7 +122,7 @@ assertEquals(result, u); //Test the case when the tests folder does not exist - result = tests.getURL(); + result = tests.toURL(); tests.delete(); u = UnitTestForSourceQuery.findUnitTest (sources); assertEquals (result, u); @@ -133,8 +133,8 @@ URL[] urls = UnitTestForSourceQuery.findSources(tests); assertNotNull(urls); assertEquals(2,urls.length); - assertEquals(sources.getURL(), urls[0]); - assertEquals(newRoot.getURL(), urls[1]); + assertEquals(sources.toURL(), urls[0]); + assertEquals(newRoot.toURL(), urls[1]); } } --- a/o.n.core/test/qa-functional/src/org/netbeans/core/validation/ValidateLayerConsistencyTest.java +++ a/o.n.core/test/qa-functional/src/org/netbeans/core/validation/ValidateLayerConsistencyTest.java @@ -946,7 +946,7 @@ FileObject libs = FileUtil.getConfigFile("org-netbeans-api-project-libraries/Libraries"); if (libs != null) { for (FileObject lib : libs.getChildren()) { - Document doc = XMLUtil.parse(new InputSource(lib.getURL().toString()), true, false, XMLUtil.defaultErrorHandler(), EntityCatalog.getDefault()); + Document doc = XMLUtil.parse(new InputSource(lib.toURL().toString()), true, false, XMLUtil.defaultErrorHandler(), EntityCatalog.getDefault()); NodeList nl = doc.getElementsByTagName("resource"); for (int i = 0; i < nl.getLength(); i++) { Element resource = (Element) nl.item(i); --- a/o.n.core/test/qa-functional/src/org/netbeans/core/validation/ValidateModulesTest.java +++ a/o.n.core/test/qa-functional/src/org/netbeans/core/validation/ValidateModulesTest.java @@ -175,7 +175,7 @@ public void testAutomaticDependenciesUnused() throws Exception { List urls = new ArrayList(); for (FileObject kid : FileUtil.getConfigFile("ModuleAutoDeps").getChildren()) { - urls.add(kid.getURL()); + urls.add(kid.toURL()); } StringBuilder problems = new StringBuilder(); AutomaticDependencies ad = AutomaticDependencies.parse(urls.toArray(new URL[urls.size()])); --- a/openide.execution/apichanges.xml +++ a/openide.execution/apichanges.xml @@ -57,6 +57,26 @@ + + + NbClassLoader(FileObject[], ...) does not throw FileStateInvalidException + + + + +

+ No NbClassLoader constructor throws FileStateInvalidException any longer, + which can cause some existing source code to not compile. +

+
+ +

+ NbClassLoader(FileObject[], ClassLoader, InputOutput) does not throw FileStateInvalidException any more. +

+
+ + +
No need to require ExecutionEngine token anymore --- a/openide.execution/manifest.mf +++ a/openide.execution/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.execution -OpenIDE-Module-Specification-Version: 1.25 +OpenIDE-Module-Specification-Version: 1.26 OpenIDE-Module-Localizing-Bundle: org/openide/execution/Bundle.properties OpenIDE-Module-Recommends: org.openide.execution.ExecutionEngine AutoUpdate-Essential-Module: true --- a/openide.execution/nbproject/project.xml +++ a/openide.execution/nbproject/project.xml @@ -54,7 +54,15 @@ - 6.2 + 7.57 + +
+ + org.openide.io + + + + 1.0 @@ -73,14 +81,6 @@ 8.0 - - org.openide.io - - - - 1.0 - - --- a/openide.execution/src/org/openide/execution/NbClassLoader.java +++ a/openide.execution/src/org/openide/execution/NbClassLoader.java @@ -54,13 +54,12 @@ import java.security.PermissionCollection; import java.util.Enumeration; import java.util.HashMap; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.jar.Manifest; import java.util.logging.Level; import java.util.logging.Logger; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; +import org.openide.filesystems.FileSystemCapability; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.util.Exceptions; @@ -115,11 +114,10 @@ * @param roots a set of package roots * @param parent a parent loader * @param io an I/O tab in the Output Window, or null - * @throws FileStateInvalidException if some of the roots are not valid * @since XXX */ static ThreadLocal f = new ThreadLocal(); - public NbClassLoader(FileObject[] roots, ClassLoader parent, InputOutput io) throws FileStateInvalidException { + public NbClassLoader(FileObject[] roots, ClassLoader parent, InputOutput io) { super(createRootURLs(roots), parent); fast = canOptimize(getURLs()); inout = io; @@ -286,10 +284,10 @@ * @param roots file roots * @return array of URLs */ - private static URL[] createRootURLs(FileObject[] roots) throws FileStateInvalidException { + private static URL[] createRootURLs(FileObject[] roots) { URL[] urls = new URL[roots.length]; for (int i = 0; i < roots.length; i++) { - urls[i] = roots[i].getURL(); + urls[i] = roots[i].toURL(); } return urls; } --- a/openide.filesystems/apichanges.xml +++ a/openide.filesystems/apichanges.xml @@ -49,6 +49,32 @@ Filesystems API + + + Introduced FileObject.toURI + + + + +

+ FileObject.getURL should be replaced with toURL (or toURI), + which also throw no checked exceptions. +

+
+ +

+ Added FileObject.toURI for convenience. +

+

+ Also deprecated FileObject.getURL in favor of toURL + which is the same but does not throw FileStateInvalidException, + and clarified that URLMapper.findURL(fo, INTERNAL) + will never return null. +

+
+ + +
Provides default line separator --- a/openide.filesystems/manifest.mf +++ a/openide.filesystems/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.filesystems OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml -OpenIDE-Module-Specification-Version: 7.56 +OpenIDE-Module-Specification-Version: 7.57 --- a/openide.filesystems/src/META-INF/upgrade/FileObject.hint +++ a/openide.filesystems/src/META-INF/upgrade/FileObject.hint @@ -2,3 +2,33 @@ => !$f.canWrite() ;; + +$f.getURL().toURI() :: $f instanceof org.openide.filesystems.FileObject +=> +$f.toURI() +;; + +java.net.URI.create($f.getURL().toString()) :: $f instanceof org.openide.filesystems.FileObject +=> +$f.toURI() +;; + +new java.net.URI($f.getURL().toString()) :: $f instanceof org.openide.filesystems.FileObject +=> +$f.toURI() +;; + +java.net.URI.create($f.getURL().toExternalForm()) :: $f instanceof org.openide.filesystems.FileObject +=> +$f.toURI() +;; + +new java.net.URI($f.getURL().toExternalForm()) :: $f instanceof org.openide.filesystems.FileObject +=> +$f.toURI() +;; + +$f.getURL() :: $f instanceof org.openide.filesystems.FileObject +=> +$f.toURL() +;; --- a/openide.filesystems/src/org/netbeans/modules/openide/filesystems/declmime/DefaultParser.java +++ a/openide.filesystems/src/org/netbeans/modules/openide/filesystems/declmime/DefaultParser.java @@ -133,7 +133,7 @@ InputSource in = new InputSource(); is = fo.getInputStream(); in.setByteStream(is); - in.setSystemId(fo.getURL().toExternalForm()); + in.setSystemId(fo.toURL().toExternalForm()); customizeInputSource(in); parser.parse(in); --- a/openide.filesystems/src/org/openide/filesystems/AbstractFolder.java +++ a/openide.filesystems/src/org/openide/filesystems/AbstractFolder.java @@ -1022,7 +1022,7 @@ throws IOException { fsname = f.getFileSystem().getSystemName(); path = f.getPath(); - url = f.getURL(); + url = f.toURL(); assert url != null : "No URL for " + path; oos.defaultWriteObject(); } --- a/openide.filesystems/src/org/openide/filesystems/FileObject.java +++ a/openide.filesystems/src/org/openide/filesystems/FileObject.java @@ -51,6 +51,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; import java.util.Arrays; @@ -1128,21 +1130,46 @@ refresh(false); } + /** + * @throws FileStateInvalidException never + * @deprecated Use {@link #toURL} instead. + */ + @Deprecated + public final URL getURL() throws FileStateInvalidException { + return toURL(); + } + /** Get URL that can be used to access this file. * If the file object does not correspond to a disk file or JAR entry, * the URL will only be usable within NetBeans as it uses a special protocol handler. * Otherwise an attempt is made to produce an external URL. * @return URL of this file object - * @exception FileStateInvalidException if the file is not valid * @see URLMapper#findURL * @see URLMapper#INTERNAL + * @since 7.57 */ - public final URL getURL() throws FileStateInvalidException { - // XXX why does this still throw FSIE? need not + public final URL toURL() { return URLMapper.findURL(this, URLMapper.INTERNAL); } /** + * Gets a URI for this file. + * Similar to {@link #toURL}. + * @return an absolute URI representing this file location + * @since 7.57 + */ + public final URI toURI() { + try { + URI uri = toURL().toURI(); + assert uri.isAbsolute() : uri; + assert uri.equals(uri.normalize()) : uri; + return uri; + } catch (URISyntaxException x) { + throw new IllegalStateException(x); + } + } + + /** * Tests if file really exists or is missing. Some operation on it may be restricted. * @return true indicates that the file is missing. * @since 1.9 --- a/openide.filesystems/src/org/openide/filesystems/FileURL.java +++ a/openide.filesystems/src/org/openide/filesystems/FileURL.java @@ -99,9 +99,8 @@ /** Provides a URL to access a file object. * @param fo the file object * @return a URL using the correct syntax and {@link #PROTOCOL protocol} - * @exception FileStateInvalidException if the file object is not valid (typically, if its filesystem is inconsistent or no longer present) */ - public static URL encodeFileObject(FileObject fo) throws FileStateInvalidException { + public static URL encodeFileObject(FileObject fo) { return NbfsUtil.getURL(fo); } --- a/openide.filesystems/src/org/openide/filesystems/NbfsUtil.java +++ a/openide.filesystems/src/org/openide/filesystems/NbfsUtil.java @@ -65,10 +65,14 @@ * Gets URL with nbfs protocol for passes fo * @param fo * @return url with nbfs protocol - * @throws FileStateInvalidException if FileObject somehow corrupted */ - static URL getURL(FileObject fo) throws FileStateInvalidException { - final String fsPart = encodeFsPart(fo); + static URL getURL(FileObject fo) { + String fsPart; + try { + fsPart = encodeFsPart(fo); + } catch (FileStateInvalidException x) { + fsPart = "invalid"; + } final String foPart = encodeFoPart(fo); final String host = "nbhost"; //NOI18N --- a/openide.filesystems/src/org/openide/filesystems/URLMapper.java +++ a/openide.filesystems/src/org/openide/filesystems/URLMapper.java @@ -130,7 +130,7 @@ *
  • inside this machine *
  • from networked machines * - * @return a suitable URL, or null + * @return a suitable URL, or (only if not {@link #INTERNAL}) null */ public static URL findURL(FileObject fo, int type) { @@ -146,11 +146,7 @@ // if not resolved yet then internal URL with nbfs protocol is returned // XXX this would be better handled by making DefaultURLMapper just return nbfs for INTERNAL when necessary! if (type == INTERNAL) { - try { - return FileURL.encodeFileObject(fo); - } catch (FileStateInvalidException iex) { - // ignore - } + return FileURL.encodeFileObject(fo); } return null; --- a/openide.filesystems/test/unit/src/META-INF/upgrade/FileObject.test +++ a/openide.filesystems/test/unit/src/META-INF/upgrade/FileObject.test @@ -0,0 +1,41 @@ +%%TestCase toURI +package test; +class C { + org.openide.filesystems.FileObject f; + java.net.URI u() throws Exception { + return f.getURL().toURI(); + } +} +%%=> +package test; +class C { + org.openide.filesystems.FileObject f; + java.net.URI u() throws Exception { + return f.toURI(); + } +} +%%=> +package test; +class C { + org.openide.filesystems.FileObject f; + java.net.URI u() throws Exception { + return f.toURL().toURI(); + } +} + +%%TestCase toURL +package test; +class C { + org.openide.filesystems.FileObject f; + java.net.URL u() throws IOException { + return f.getURL(); + } +} +%%=> +package test; +class C { + org.openide.filesystems.FileObject f; + java.net.URL u() throws IOException { + return f.toURL(); + } +} --- a/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java +++ a/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java @@ -1697,7 +1697,7 @@ } - public void testNbfsTransformation () throws FileStateInvalidException{ + public void testNbfsTransformation () { checkSetUp(); // additional check String sysName = fs.getSystemName(); @@ -1716,7 +1716,7 @@ } } - public void testNbfsTransformation2() throws FileStateInvalidException, IOException, SAXException, ParserConfigurationException { + public void testNbfsTransformation2() throws IOException, SAXException, ParserConfigurationException { checkSetUp(); // additional check if (fs.isReadOnly() || root.isReadOnly()) return; @@ -1736,7 +1736,7 @@ pFactory.setValidating (false); Parser p = pFactory.newSAXParser().getParser(); p.setDocumentHandler(new HandlerBase()); - URL u = f.getURL(); + URL u = f.toURL(); p.parse(u.toExternalForm()); // byte[] b = new byte[10]; @@ -3086,15 +3086,15 @@ } } - /** Test of getURL method, of class org.openide.filesystems.FileObject. */ - public void testGetURL() throws Exception { + public void testToURL() throws Exception { checkSetUp(); FileObject fo1 = getTestFile1 (root); URL url = null; - url = fo1.getURL(); + url = fo1.toURL(); /** Only invalid files may fire FileStateInvalidException*/ - fsAssert ("Expected valid url",url != null); + fsAssert ("Expected valid url",url != null); + fsAssert("same URI", url.toURI().equals(fo1.toURI())); // #39613: check that it actually works! // Note that since getURL now produces a file: URL for files with File's, @@ -3102,7 +3102,7 @@ FileObject f2 = getTestFile1(root); FileObject f1 = f2.getParent(); assertNotNull("had a parent of " + f2, f1); - URL u1 = f1.getURL(); + URL u1 = f1.toURL(); assertNotNull("had a URL for " + f1, u1); URI uri1 = new URI(u1.toExternalForm()); String path1 = uri1.getPath(); --- a/openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java +++ a/openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java @@ -140,7 +140,7 @@ clearWorkDir(); lfs.setRootDirectory(getWorkDir()); MockLookup.setInstances(new URLMapper() { - String rootURL = lfs.getRoot().getURL().toString(); + String rootURL = lfs.getRoot().toURL().toString(); @Override public FileObject[] getFileObjects(URL url) { String u = url.toString(); @@ -220,7 +220,7 @@ final File wd = getWorkDir(); lfs.setRootDirectory(wd); MockLookup.setInstances(new URLMapper() { - String rootURL = lfs.getRoot().getURL().toString(); + String rootURL = lfs.getRoot().toURL().toString(); @Override public FileObject[] getFileObjects(URL url) { String u = url.toString(); --- a/openide.filesystems/test/unit/src/org/openide/filesystems/FilesystemBugsTest.java +++ a/openide.filesystems/test/unit/src/org/openide/filesystems/FilesystemBugsTest.java @@ -205,7 +205,7 @@ */ public void testURLContract() throws Exception { FileObject fo = getWriteFolder(); - URL u = fo.getURL(); + URL u = fo.toURL(); assertEquals(u, new URL(u.toExternalForm())); } @@ -260,7 +260,7 @@ is now always searched in parent folder. */ public void testFolderSlashUrl() throws Exception { - URL u = getWriteFolder().getURL(); + URL u = getWriteFolder().toURL(); assertTrue("invalid url of directory", u.getPath().endsWith("/")); } --- a/openide.filesystems/test/unit/src/org/openide/filesystems/JarFileSystemHidden.java +++ a/openide.filesystems/test/unit/src/org/openide/filesystems/JarFileSystemHidden.java @@ -67,7 +67,7 @@ JarFileSystem fs = new JarFileSystem(f); - URL u = fs.getRoot().getURL(); + URL u = fs.getRoot().toURL(); assertNotNull("URL is OK", u); if (!u.toExternalForm().startsWith("jar:file") || !u.toExternalForm().endsWith("broken.jar!/")) { fail("Unexpected URL: " + u); @@ -106,7 +106,7 @@ fail("The file " + f + " shall not be opened when fs created:\n" + log); } - URL u = fs.getRoot().getURL(); + URL u = fs.getRoot().toURL(); assertNotNull("URL is OK", u); if (!u.toExternalForm().startsWith("jar:file") || !u.toExternalForm().endsWith("ok.jar!/")) { fail("Unexpected URL: " + u); --- a/openide.filesystems/test/unit/src/org/openide/filesystems/MemoryFSTestHid.java +++ a/openide.filesystems/test/unit/src/org/openide/filesystems/MemoryFSTestHid.java @@ -93,7 +93,7 @@ os.write("hello".getBytes()); os.close(); file.setAttribute("mimeType", "text/x-hello"); - URL u = file.getURL(); + URL u = file.toURL(); assertEquals("/folder/file", u.getPath()); URLConnection conn = u.openConnection(); conn.connect(); @@ -106,7 +106,7 @@ assertEquals(file, URLMapper.findFileObject(u)); assertEquals(null, URLMapper.findURL(file, URLMapper.EXTERNAL)); assertEquals(null, URLMapper.findURL(file, URLMapper.NETWORK)); - assertEquals(u, new URL(file.getParent().getURL(), file.getNameExt())); + assertEquals(u, new URL(file.getParent().toURL(), file.getNameExt())); } } --- a/project.ant/nbproject/project.xml +++ a/project.ant/nbproject/project.xml @@ -140,7 +140,7 @@ - 7.50 + 7.57 --- a/project.ant/src/org/netbeans/modules/project/ant/ProjectLibraryProvider.java +++ a/project.ant/src/org/netbeans/modules/project/ant/ProjectLibraryProvider.java @@ -1178,13 +1178,7 @@ URI u; FileObject newFO; String name; - URI libEntryU; - try { - libEntryU = libEntryFO.getURL().toURI(); - } catch (Exception x) { - libEntryU = null; - } - if (libEntryU != null && CollocationQuery.areCollocated(libBaseFolder.toURI(), libEntryU)) { + if (CollocationQuery.areCollocated(libBaseFolder.toURI(), libEntryFO.toURI())) { // if the jar/folder is in relation to the library folder (parent+child/same vcs) // don't replicate it but reference the original file. newFO = libEntryFO; --- a/project.ant/src/org/netbeans/modules/project/ant/ProjectXMLCatalogReader.java +++ a/project.ant/src/org/netbeans/modules/project/ant/ProjectXMLCatalogReader.java @@ -63,7 +63,6 @@ import org.netbeans.modules.xml.catalog.spi.CatalogListener; import org.netbeans.modules.xml.catalog.spi.CatalogReader; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; @@ -96,11 +95,7 @@ if (name.startsWith(PREFIX)) { FileObject rsrc = FileUtil.getConfigFile(CATALOG + "/" + name.substring(PREFIX.length()) + "." + EXTENSION); if (rsrc != null) { - try { - return rsrc.getURL().toString(); - } catch (FileStateInvalidException x) { - Exceptions.printStackTrace(x); - } + return rsrc.toURL().toString(); } } return null; @@ -179,7 +174,7 @@ try { InputStream is = f.getInputStream(); streams.add(is); - sources.add(new StreamSource(is, f.getURL().toString())); + sources.add(new StreamSource(is, f.toURL().toString())); } catch (IOException x) { Exceptions.printStackTrace(x); } @@ -192,7 +187,7 @@ // Try to determine the culprit and report appropriately. for (FileObject f : schemas) { try { - schemaFactory.newSchema(new StreamSource(f.getURL().toString())); + schemaFactory.newSchema(new StreamSource(f.toURL().toString())); } catch (Exception x2) { Exceptions.attachMessage(x2, "While parsing: " + f.getPath()); // NOI18N Exceptions.printStackTrace(x2); --- a/project.ant/src/org/netbeans/spi/project/support/ant/GeneratedFilesHelper.java +++ a/project.ant/src/org/netbeans/spi/project/support/ant/GeneratedFilesHelper.java @@ -691,7 +691,7 @@ /** Find (maybe cached) CRC for a file, using a preexisting input stream (not closed by this method). */ private static String getCrc32(InputStream is, FileObject fo) throws IOException { - URL u = fo.getURL(); + URL u = fo.toURL(); fo.refresh(); // in case was written on disk and we did not notice yet... long footprint = fo.lastModified().getTime() ^ fo.getSize(); String crc = findCachedCrc32(u, footprint); @@ -730,7 +730,7 @@ /** Find (maybe cached) CRC for a file. Will open its own input stream. */ private static String getCrc32(FileObject fo) throws IOException { - URL u = fo.getURL(); + URL u = fo.toURL(); fo.refresh(); long footprint = fo.lastModified().getTime() ^ fo.getSize(); String crc = findCachedCrc32(u, footprint); --- a/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java +++ a/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java @@ -69,6 +69,7 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectUtils; import org.netbeans.api.project.SourceGroup; +import org.netbeans.api.project.SourceGroupModifier; import org.netbeans.api.project.Sources; import org.netbeans.api.queries.SharabilityQuery; import org.netbeans.modules.project.ant.AntBasedProjectFactorySingleton; @@ -78,7 +79,6 @@ import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileRenameEvent; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.ChangeSupport; import org.openide.util.Parameters; @@ -1019,11 +1019,7 @@ // Remember what we computed here so we know whether to fire changes later. List rootURLs = new ArrayList(groups.size()); for (SourceGroup g : groups) { - try { - rootURLs.add(g.getRootFolder().getURL()); - } catch (FileStateInvalidException e) { - assert false : e; // should be a valid file object! - } + rootURLs.add(g.getRootFolder().toURL()); } lastComputedRoots.put(type, rootURLs); return groups.toArray(new SourceGroup[groups.size()]); --- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java +++ a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java @@ -171,7 +171,7 @@ assertNotNull("found ref helper for " + p, r); sisterprojdir = FileUtil.createFolder(scratch, "proj2"); assertTrue("projdir and sisterprojdir collocated", - CollocationQuery.areCollocated(projdir.getURL().toURI(), sisterprojdir.getURL().toURI())); + CollocationQuery.areCollocated(projdir.toURI(), sisterprojdir.toURI())); sisterh = ProjectGenerator.createProject(sisterprojdir, "test"); setCodeNameOfTestProject(sisterh, "proj2"); EditableProperties props = sisterh.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); @@ -183,7 +183,7 @@ sisterprojdir2 = FileUtil.createFolder(scratch, "proj2-copy"); assertTrue("projdir and sisterprojdir2 collocated", - CollocationQuery.areCollocated(projdir.getURL().toURI(), sisterprojdir2.getURL().toURI())); + CollocationQuery.areCollocated(projdir.toURI(), sisterprojdir2.toURI())); sisterh2 = ProjectGenerator.createProject(sisterprojdir2, "test"); setCodeNameOfTestProject(sisterh2, "proj2"); props = sisterh2.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); @@ -198,7 +198,7 @@ // similarly as it is done for SampleCVSCollocationQueryImpl // in META-INF/services. assertFalse("" + projdir + " and " + sepprojdir + " cannot be collocated", - CollocationQuery.areCollocated(projdir.getURL().toURI(), sepprojdir.getURL().toURI())); + CollocationQuery.areCollocated(projdir.toURI(), sepprojdir.toURI())); seph = ProjectGenerator.createProject(sepprojdir, "test"); setCodeNameOfTestProject(seph, "proj3"); props = seph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); --- a/projectapi/nbproject/project.xml +++ a/projectapi/nbproject/project.xml @@ -63,7 +63,7 @@ - 7.50 + 7.57 --- a/projectapi/src/org/netbeans/api/project/ProjectUtils.java +++ a/projectapi/src/org/netbeans/api/project/ProjectUtils.java @@ -67,7 +67,6 @@ import org.netbeans.spi.project.SubprojectProvider; import org.netbeans.spi.project.support.GenericSources; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.ImageUtilities; import org.openide.util.Lookup; @@ -235,11 +234,7 @@ } public String getName() { - try { - return p.getProjectDirectory().getURL().toExternalForm(); - } catch (FileStateInvalidException e) { - return e.toString(); - } + return p.getProjectDirectory().toURL().toExternalForm(); } public String getDisplayName() { --- a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java +++ a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java @@ -103,7 +103,7 @@ InputStream is = config.getInputStream(); try { InputSource input = new InputSource(is); - input.setSystemId(config.getURL().toString()); + input.setSystemId(config.toURL().toString()); Element root = XMLUtil.parse(input, false, true, /*XXX*/null, null).getDocumentElement(); return XMLUtil.findElement(root, elementName, namespace); } finally { @@ -160,7 +160,7 @@ InputStream is = config.getInputStream(); try { InputSource input = new InputSource(is); - input.setSystemId(config.getURL().toString()); + input.setSystemId(config.toURL().toString()); doc = XMLUtil.parse(input, false, true, /*XXX*/ null, null); } finally { is.close(); @@ -231,7 +231,7 @@ InputStream is = config.getInputStream(); try { InputSource input = new InputSource(is); - input.setSystemId(config.getURL().toString()); + input.setSystemId(config.toURL().toString()); doc = XMLUtil.parse(input, false, true, /*XXX*/ null, null); } finally { is.close(); --- a/projectapi/src/org/netbeans/modules/projectapi/SimpleFileOwnerQueryImplementation.java +++ a/projectapi/src/org/netbeans/modules/projectapi/SimpleFileOwnerQueryImplementation.java @@ -51,13 +51,10 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.Map; import java.util.Set; -import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; import java.util.prefs.BackingStoreException; @@ -66,7 +63,6 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.spi.project.FileOwnerQueryImplementation; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.URLMapper; import org.openide.util.NbPreferences; import org.openide.util.Utilities; @@ -146,7 +142,7 @@ } if (!externalOwners.isEmpty() && (folder || externalRootsIncludeNonFolders)) { - URI externalOwnersURI = externalOwners.get(fileObject2URI(f)); + URI externalOwnersURI = externalOwners.get(f.toURI()); if (externalOwnersURI != null) { FileObject externalOwner = uri2FileObject(externalOwnersURI); @@ -169,7 +165,7 @@ } } if (!deserializedExternalOwners.isEmpty() && (folder || externalRootsIncludeNonFolders)) { - FileObject externalOwner = deserializedExternalOwners.get(fileObject2URI(f)); + FileObject externalOwner = deserializedExternalOwners.get(f.toURI()); if (externalOwner != null && externalOwner.isValid()) { try { // Note: will be null if there is no such project. @@ -241,17 +237,9 @@ externalOwners.clear(); } - private static URI fileObject2URI(FileObject f) { - try { - return URI.create(f.getURL().toString()); - } catch (FileStateInvalidException e) { - throw (IllegalArgumentException) new IllegalArgumentException(e.toString()).initCause(e); - } - } - /** @see FileOwnerQuery#markExternalOwner */ public static void markExternalOwnerTransient(FileObject root, Project owner) { - markExternalOwnerTransient(fileObject2URI(root), owner); + markExternalOwnerTransient(root.toURI(), owner); } /** @see FileOwnerQuery#markExternalOwner */ @@ -259,7 +247,7 @@ externalRootsIncludeNonFolders |= !root.getPath().endsWith("/"); if (owner != null) { FileObject fo = owner.getProjectDirectory(); - externalOwners.put(root, fileObject2URI(fo)); + externalOwners.put(root, fo.toURI()); deserializedExternalOwners.remove(root); } else { externalOwners.remove(root); --- a/projectapi/test/unit/src/org/netbeans/api/project/FileOwnerQueryTest.java +++ a/projectapi/test/unit/src/org/netbeans/api/project/FileOwnerQueryTest.java @@ -143,9 +143,9 @@ public void testJarOwners() throws Exception { assertEquals("correct owner of a ZIPped file", p, FileOwnerQuery.getOwner(zippedfile)); - assertEquals("correct owner of a ZIPped file URL", p, FileOwnerQuery.getOwner(URI.create(zippedfile.getURL().toExternalForm()))); + assertEquals("correct owner of a ZIPped file URL", p, FileOwnerQuery.getOwner(URI.create(zippedfile.toURL().toExternalForm()))); assertEquals("correct owner of a ZIPped file", p, FileOwnerQuery.getOwner(hashedFile)); - assertEquals("correct owner of a ZIPped file URL", p, FileOwnerQuery.getOwner(URI.create(hashedFile.getURL().toExternalForm()))); + assertEquals("correct owner of a ZIPped file URL", p, FileOwnerQuery.getOwner(URI.create(hashedFile.toURL().toExternalForm()))); } public void testExternalOwner() throws Exception { @@ -203,68 +203,68 @@ FileObject extfile1 = ext1.getFileObject("subdir/file"); assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile1)); assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(extfile1)); - FileOwnerQuery.markExternalOwner(fileObject2URI(ext1), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + FileOwnerQuery.markExternalOwner(ext1.toURI(), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("now have an owner through FileObjects", p, FileOwnerQuery.getOwner(extfile1)); - assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1))); + assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(extfile1.toURI())); assertEquals("even for the projdir throught FileObjects", p, FileOwnerQuery.getOwner(ext1)); - assertEquals("even for the projdir throught URI", p, FileOwnerQuery.getOwner(fileObject2URI(ext1))); + assertEquals("even for the projdir throught URI", p, FileOwnerQuery.getOwner(ext1.toURI())); assertEquals("but not for something else throught FileObjects", null, FileOwnerQuery.getOwner(scratch)); - assertEquals("but not for something else throught URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch))); + assertEquals("but not for something else throught URI", null, FileOwnerQuery.getOwner(scratch.toURI())); FileObject ext2 = scratch.getFileObject("external2"); FileObject extfile2 = ext2.getFileObject("subdir/file"); assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile2)); - assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(extfile2))); + assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(extfile2.toURI())); Project p2 = ProjectManager.getDefault().findProject(subprojdir); - FileOwnerQuery.markExternalOwner(fileObject2URI(ext2), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + FileOwnerQuery.markExternalOwner(ext2.toURI(), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("now have an owner through FileObjects", p2, FileOwnerQuery.getOwner(extfile2)); - assertEquals("now have an owner through URI", p2, FileOwnerQuery.getOwner(fileObject2URI(extfile2))); + assertEquals("now have an owner through URI", p2, FileOwnerQuery.getOwner(extfile2.toURI())); assertEquals("even for the projdir through FileObjects", p2, FileOwnerQuery.getOwner(ext2)); assertEquals("even for the projdir through URI", p2, FileOwnerQuery.getOwner(ext2)); assertEquals("but not for something else through FileObjects", null, FileOwnerQuery.getOwner(scratch)); - assertEquals("but not for something else through URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch))); + assertEquals("but not for something else through URI", null, FileOwnerQuery.getOwner(scratch.toURI())); assertEquals("still correct for first proj through FileObjects", p, FileOwnerQuery.getOwner(extfile1)); - assertEquals("still correct for first proj through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1))); + assertEquals("still correct for first proj through URI", p, FileOwnerQuery.getOwner(extfile1.toURI())); FileObject ext3 = scratch.getFileObject("external3"); assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(ext3)); - assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext3))); - FileOwnerQuery.markExternalOwner(fileObject2URI(ext3), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(ext3.toURI())); + FileOwnerQuery.markExternalOwner(ext3.toURI(), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("now have an owner through FileObjects", p, FileOwnerQuery.getOwner(ext3)); - assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(fileObject2URI(ext3))); + assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(ext3.toURI())); FileObject ext3subproj = ext3.getFileObject("subproject"); Project p3 = FileOwnerQuery.getOwner(ext3subproj); assertNotSame("different project", p, p3); assertEquals("but subprojects are not part of it", ProjectManager.getDefault().findProject(ext3subproj), p3); - FileOwnerQuery.markExternalOwner(fileObject2URI(ext3), null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + FileOwnerQuery.markExternalOwner(ext3.toURI(), null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("unmarking an owner works through FileObjects", null, FileOwnerQuery.getOwner(ext3)); - assertEquals("unmarking an owner works through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext3))); + assertEquals("unmarking an owner works through URI", null, FileOwnerQuery.getOwner(ext3.toURI())); } public void testExternalOwnerFileURI() throws Exception { FileObject ext1 = scratch.getFileObject("external1"); FileObject extfile1 = ext1.getFileObject("subdir/file"); assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile1)); - assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(extfile1))); - FileOwnerQuery.markExternalOwner(fileObject2URI(extfile1), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(extfile1.toURI())); + FileOwnerQuery.markExternalOwner(extfile1.toURI(), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("now have an owner through FileObjects", p, FileOwnerQuery.getOwner(extfile1)); - assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1))); + assertEquals("now have an owner through URI", p, FileOwnerQuery.getOwner(extfile1.toURI())); assertEquals("not for the projdir through FileObjects", null, FileOwnerQuery.getOwner(ext1)); - assertEquals("not for the projdir through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext1))); + assertEquals("not for the projdir through URI", null, FileOwnerQuery.getOwner(ext1.toURI())); assertEquals("and not for something else through FileObjects", null, FileOwnerQuery.getOwner(scratch)); - assertEquals("and not for something else through URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch))); + assertEquals("and not for something else through URI", null, FileOwnerQuery.getOwner(scratch.toURI())); FileObject ext2 = scratch.getFileObject("external2"); FileObject extfile2 = ext2.getFileObject("subdir/file"); assertEquals("no owner yet through FileObjects", null, FileOwnerQuery.getOwner(extfile2)); - assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(fileObject2URI(extfile2))); + assertEquals("no owner yet through URI", null, FileOwnerQuery.getOwner(extfile2.toURI())); Project p2 = ProjectManager.getDefault().findProject(subprojdir); - FileOwnerQuery.markExternalOwner(fileObject2URI(extfile2), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + FileOwnerQuery.markExternalOwner(extfile2.toURI(), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("now have an owner through FileObjects", p2, FileOwnerQuery.getOwner(extfile2)); - assertEquals("now have an owner through URI", p2, FileOwnerQuery.getOwner(fileObject2URI(extfile2))); + assertEquals("now have an owner through URI", p2, FileOwnerQuery.getOwner(extfile2.toURI())); assertEquals("not for the projdir through FileObjects", null, FileOwnerQuery.getOwner(ext2)); - assertEquals("not for the projdir through URI", null, FileOwnerQuery.getOwner(fileObject2URI(ext2))); + assertEquals("not for the projdir through URI", null, FileOwnerQuery.getOwner(ext2.toURI())); assertEquals("and not for something else through FileObjects", null, FileOwnerQuery.getOwner(scratch)); - assertEquals("and not for something else through URI", null, FileOwnerQuery.getOwner(fileObject2URI(scratch))); + assertEquals("and not for something else through URI", null, FileOwnerQuery.getOwner(scratch.toURI())); assertEquals("still correct for first proj through FileObjects", p, FileOwnerQuery.getOwner(extfile1)); - assertEquals("still correct for first proj through URI", p, FileOwnerQuery.getOwner(fileObject2URI(extfile1))); + assertEquals("still correct for first proj through URI", p, FileOwnerQuery.getOwner(extfile1.toURI())); //XXX: unmarking files. } @@ -275,7 +275,7 @@ FileObject tempPrjDir = tempPrjMarker.getParent(); Project tempPrj = ProjectManager.getDefault().findProject(tempPrjDir); assertNotNull(tempPrj); - FileOwnerQuery.markExternalOwner(fileObject2URI(ext1), tempPrj, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + FileOwnerQuery.markExternalOwner(ext1.toURI(), tempPrj, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); assertEquals("now have an owner", tempPrj, FileOwnerQuery.getOwner(ext1)); Reference r = new WeakReference(tempPrjDir); tempPrjMarker = tempPrjDir = null; @@ -290,7 +290,7 @@ FileObject ext2 = scratch.getFileObject("external2"); FileObject extfile2 = ext2.getFileObject("subdir/file"); - FileOwnerQuery.markExternalOwner(fileObject2URI(extfile2), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); + FileOwnerQuery.markExternalOwner(extfile2.toURI(), p2, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); Reference p2WR = new WeakReference(p2); Reference rootWR = new WeakReference(root); @@ -325,15 +325,11 @@ assertEquals("still correct for the first external root", p, FileOwnerQuery.getOwner(ext1)); } - private static URI fileObject2URI(FileObject f) throws Exception { - return URI.create(f.getURL().toString()); - } - // XXX test URI usage of external owner // XXX test GC of roots and projects used in external ownership: // - the owning Project is not held strongly (just PM's soft cache) // - the root is not held strongly (note - FOQ won't be accurate after it is collected) // XXX test IAE from illegal calls to FOQ.markExternalOwner // XXX test an owner which is above the project directory - + } --- a/projectapi/test/unit/src/org/netbeans/modules/projectapi/FileOwnerCollocationQueryImplTest.java +++ a/projectapi/test/unit/src/org/netbeans/modules/projectapi/FileOwnerCollocationQueryImplTest.java @@ -74,7 +74,7 @@ //root/prj1/foo FileOwnerCollocationQueryImpl instance = new FileOwnerCollocationQueryImpl(); - assertEquals(projdir.getURL().toURI(), instance.findRoot(projdir.createData("foo").getURL().toURI())); + assertEquals(projdir.toURI(), instance.findRoot(projdir.createData("foo").toURI())); //root/prj2/foo/prj3/bar projdir = root.createFolder("prj2"); @@ -82,10 +82,10 @@ projdir.createFolder("testproject"); projdir = projdir.createFolder("foo").createFolder("prj3"); projdir.createFolder("testproject"); - assertEquals(expected.getURL().toURI(), instance.findRoot(projdir.createData("bar").getURL().toURI())); + assertEquals(expected.toURI(), instance.findRoot(projdir.createData("bar").toURI())); //root - assertEquals(null, instance.findRoot(root.getURL().toURI())); + assertEquals(null, instance.findRoot(root.toURI())); } /** @@ -101,14 +101,14 @@ FileObject file1 = lib.createData("pron"); FileObject file2 = projdir.createData("xxx"); FileOwnerCollocationQueryImpl instance = new FileOwnerCollocationQueryImpl(); - assertFalse(instance.areCollocated(file1.getURL().toURI(), file2.getURL().toURI())); + assertFalse(instance.areCollocated(file1.toURI(), file2.toURI())); file1 = projdir.createData("pron"); - assertTrue(instance.areCollocated(file1.getURL().toURI(), file2.getURL().toURI())); + assertTrue(instance.areCollocated(file1.toURI(), file2.toURI())); file1 = projdir; file2 = lib; - assertFalse(instance.areCollocated(file1.getURL().toURI(), file2.getURL().toURI())); + assertFalse(instance.areCollocated(file1.toURI(), file2.toURI())); projdir = root.createFolder("noproj").createFolder("proj1"); projdir.createFolder("testproject"); @@ -118,7 +118,7 @@ file2 = projdir2.createData("bar"); // System.out.println("root1=" + instance.findRoot(file1.getURL().toURI())); // System.out.println("root2=" + instance.findRoot(file2.getURL().toURI())); - assertFalse(instance.areCollocated(file1.getURL().toURI(), file2.getURL().toURI())); + assertFalse(instance.areCollocated(file1.toURI(), file2.toURI())); } --- a/projectui/nbproject/project.xml +++ a/projectui/nbproject/project.xml @@ -167,7 +167,7 @@ - 7.49 + 7.57 --- a/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java +++ a/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java @@ -103,7 +103,6 @@ import org.openide.filesystems.FileChangeAdapter; import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.loaders.DataObject; @@ -399,15 +398,10 @@ for (Project p : toOpenProjects) { INSTANCE.addModuleInfo(p); // Set main project - try { if ( mainProjectURL != null && - mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) { + mainProjectURL.equals( p.getProjectDirectory().toURL() ) ) { lazyMainProject = p; } - } - catch( FileStateInvalidException e ) { - // Not a main project - } } return toOpenProjects.size(); } @@ -1115,15 +1109,10 @@ private static List projects2URLs( Collection projects ) { ArrayList URLs = new ArrayList( projects.size() ); for(Project p: projects) { - try { - URL root = p.getProjectDirectory().getURL(); + URL root = p.getProjectDirectory().toURL(); if ( root != null ) { URLs.add( root ); } - } - catch( FileStateInvalidException e ) { - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); - } } return URLs; @@ -1263,13 +1252,8 @@ } private static void saveMainProject( Project mainProject ) { - try { - URL mainRoot = mainProject == null ? null : mainProject.getProjectDirectory().getURL(); + URL mainRoot = mainProject == null ? null : mainProject.getProjectDirectory().toURL(); OpenProjectListSettings.getInstance().setMainProjectURL( mainRoot ); - } - catch ( FileStateInvalidException e ) { - OpenProjectListSettings.getInstance().setMainProjectURL((String) null); - } } private ArrayList getTemplateNamesLRU( final Project project, PrivilegedTemplates priv ) { @@ -1391,15 +1375,11 @@ public void add(final Project p) { final UnloadedProjectInformation projectInfo; - try { // #183681: call outside of lock + // #183681: call outside of lock projectInfo = ProjectInfoAccessor.DEFAULT.getProjectInfo( ProjectUtils.getInformation(p).getDisplayName(), ProjectUtils.getInformation(p).getIcon(), - p.getProjectDirectory().getURL()); - } catch(FileStateInvalidException ex) { - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); - return; - } + p.getProjectDirectory().toURL()); ProjectManager.mutex().writeAccess(new Mutex.Action() { public @Override Void run() { int index = getIndex(p); @@ -1576,17 +1556,10 @@ } private int getIndex( Project p ) { - - URL pURL; - try { - if ( p == null || p.getProjectDirectory() == null ) { - return -1; - } - pURL = p.getProjectDirectory().getURL(); - } - catch( FileStateInvalidException e ) { + if (p == null || p.getProjectDirectory() == null) { return -1; } + URL pURL = p.getProjectDirectory().toURL(); int i = 0; @@ -1623,14 +1596,7 @@ public ProjectReference( Project p ) { this.projectReference = new WeakReference( p ); - try { - projectURL = p.getProjectDirectory().getURL(); - } - catch( FileStateInvalidException e ) { - if (LOGGER.isLoggable(Level.FINE)) { - log(Level.FINE, "FSIE getting URL for project: " + p.getProjectDirectory()); - } - } + projectURL = p.getProjectDirectory().toURL(); } public Project getProject() { --- a/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java +++ a/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java @@ -71,7 +71,6 @@ import org.openide.cookies.EditCookie; import org.openide.cookies.OpenCookie; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.loaders.DataObject; @@ -179,16 +178,7 @@ // add project wr.urls4project.put(owner, new LinkedHashSet()); } - URL url = null; - - try { - url = dobj.getPrimaryFile().getURL(); - wr.urls4project.get(owner).add(url.toExternalForm()); - } - catch (FileStateInvalidException fsie) { - assert false : "FileStateInvalidException in " + - dobj.getPrimaryFile(); - } + wr.urls4project.get(owner).add(dobj.getPrimaryFile().toURL().toExternalForm()); } } else { ERR.log(Level.FINE, "#194243: no DataObject in lookup of {0} of {1}", new Object[] {tc.getName(), tc.getClass()}); --- a/projectui/src/org/netbeans/modules/project/ui/groups/AdHocGroup.java +++ a/projectui/src/org/netbeans/modules/project/ui/groups/AdHocGroup.java @@ -57,7 +57,6 @@ import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.project.Project; import org.netbeans.api.project.ui.OpenProjects; -import org.openide.filesystems.FileStateInvalidException; /** * Arbitrary collection of projects, with an optional main project. @@ -117,11 +116,7 @@ public void setProjects(Set projects) { Set projectPaths = new TreeSet(); for (Project prj : projects) { - try { - projectPaths.add(prj.getProjectDirectory().getURL().toExternalForm()); - } catch (FileStateInvalidException x) { - LOG.log(Level.WARNING, null, x); - } + projectPaths.add(prj.getProjectDirectory().toURL().toExternalForm()); } prefs().put(KEY_PATH, joinPaths(projectPaths)); LOG.log(Level.FINE, "updating projects for {0} to {1}", new Object[] {id, projects}); --- a/projectui/src/org/netbeans/modules/project/ui/groups/DirectoryGroup.java +++ a/projectui/src/org/netbeans/modules/project/ui/groups/DirectoryGroup.java @@ -44,7 +44,6 @@ package org.netbeans.modules.project.ui.groups; -import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -58,8 +57,6 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.api.queries.SharabilityQuery; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; -import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.util.Exceptions; @@ -76,8 +73,8 @@ /** * Create a new group derived from a directory. */ - public static DirectoryGroup create(String name, FileObject dir) throws FileStateInvalidException { - String path = dir.getURL().toExternalForm(); + public static DirectoryGroup create(String name, FileObject dir) { + String path = dir.toURL().toExternalForm(); String id = sanitizeNameAndUniquifyForId(name); LOG.log(Level.FINE, "Creating: {0}", id); Preferences p = NODE.node(id); --- a/projectui/src/org/netbeans/modules/project/ui/groups/Group.java +++ a/projectui/src/org/netbeans/modules/project/ui/groups/Group.java @@ -76,7 +76,6 @@ import org.netbeans.modules.project.ui.ProjectUtilities; import static org.netbeans.modules.project.ui.groups.Bundle.*; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.URLMapper; import org.openide.util.Exceptions; import org.openide.util.NbBundle; @@ -325,11 +324,7 @@ protected List projectPaths() { List urls = new ArrayList(); for (Project p : getProjects()) { - try { - urls.add(p.getProjectDirectory().getURL().toString()); - } catch (FileStateInvalidException x) { - Exceptions.printStackTrace(x); - } + urls.add(p.getProjectDirectory().toURL().toString()); } return urls; } @@ -354,11 +349,7 @@ LOG.log(Level.FINE, "updating main project for {0} to {1}", new Object[] {id, mainProject}); URL f = null; if (mainProject != null && getProjects().contains(mainProject)) { - try { - f = mainProject.getProjectDirectory().getURL(); - } catch (FileStateInvalidException x) { - LOG.log(Level.WARNING, null, x); - } + f = mainProject.getProjectDirectory().toURL(); } if (f != null) { prefs().put(KEY_MAIN, f.toExternalForm()); --- a/projectui/src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java +++ a/projectui/src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java @@ -60,7 +60,6 @@ import org.netbeans.spi.project.ui.support.ProjectChooser; import org.openide.NotificationLineSupport; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; import org.openide.util.NbBundle.Messages; @@ -171,11 +170,7 @@ } else { assert directoryKindRadio.isSelected(); FileObject f = FileUtil.toFileObject(FileUtil.normalizeFile(new File(directoryField.getText().trim()))); - try { - return DirectoryGroup.create(nameField.getText().trim(), f); - } catch (FileStateInvalidException x) { - throw new AssertionError(x); - } + return DirectoryGroup.create(nameField.getText().trim(), f); } } --- a/projectui/src/org/netbeans/modules/project/ui/groups/SubprojectsGroup.java +++ a/projectui/src/org/netbeans/modules/project/ui/groups/SubprojectsGroup.java @@ -55,7 +55,6 @@ import org.netbeans.api.project.ProjectUtils; import org.netbeans.spi.project.SubprojectProvider; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.URLMapper; /** @@ -74,8 +73,8 @@ * but this could be changed later. * The display name is by default that of the superproject. */ - public static SubprojectsGroup create(String name, Project project) throws FileStateInvalidException { - String path = project.getProjectDirectory().getURL().toExternalForm(); + public static SubprojectsGroup create(String name, Project project) { + String path = project.getProjectDirectory().toURL().toExternalForm(); String id = sanitizeNameAndUniquifyForId(name); LOG.log(Level.FINE, "Creating: {0}", id); Preferences p = NODE.node(id); --- a/projectui/test/unit/src/org/netbeans/modules/project/ui/OpenProjectListTest.java +++ a/projectui/test/unit/src/org/netbeans/modules/project/ui/OpenProjectListTest.java @@ -72,7 +72,6 @@ import org.netbeans.spi.project.SubprojectProvider; import org.netbeans.spi.project.ui.ProjectOpenedHook; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.filesystems.URLMapper; import org.openide.loaders.DataObject; @@ -144,8 +143,8 @@ fail("There should be TestProject\n" + log.toString()); } - assertTrue ("Document f1_1_open is loaded.", handler.openFiles.contains (f1_1_open.getURL ().toExternalForm ())); - assertTrue ("Document f1_2_open is loaded.", handler.openFiles.contains (f1_2_open.getURL ().toExternalForm ())); + assertTrue ("Document f1_1_open is loaded.", handler.openFiles.contains (f1_1_open.toURL ().toExternalForm ())); + assertTrue ("Document f1_2_open is loaded.", handler.openFiles.contains (f1_2_open.toURL ().toExternalForm ())); /* XXX always fails; what was this testing? assertFalse ("Document f2_1_open isn't loaded.", handler.openFiles.contains (f2_1_open.getURL ().toExternalForm ())); */ @@ -186,8 +185,8 @@ if (!m.find()) { fail("There should be TestProject\n" + log); } - assertFalse ("Document f1_1_open isn't loaded.", handler.openFiles.contains (f1_1_open.getURL ().toExternalForm ())); - assertFalse ("Document f1_2_open isn't loaded.", handler.openFiles.contains (f1_2_open.getURL ().toExternalForm ())); + assertFalse ("Document f1_1_open isn't loaded.", handler.openFiles.contains (f1_1_open.toURL ().toExternalForm ())); + assertFalse ("Document f1_2_open isn't loaded.", handler.openFiles.contains (f1_2_open.toURL ().toExternalForm ())); /* XXX fails, see above assertFalse ("Document f2_1_open isn't loaded.", handler.openFiles.contains (f2_1_open.getURL ().toExternalForm ())); */ @@ -196,16 +195,16 @@ OpenProjectList.getDefault ().open (project2); // close all project1's documents - handler.openFiles.remove (f1_1_open.getURL ().toExternalForm ()); - handler.openFiles.remove (f1_2_open.getURL ().toExternalForm ()); + handler.openFiles.remove (f1_1_open.toURL ().toExternalForm ()); + handler.openFiles.remove (f1_2_open.toURL ().toExternalForm ()); ProjectUtilities.closeAllDocuments(new Project[] {project1}, false); OpenProjectList.getDefault().close(new Project[] {project1}, false); OpenProjectList.getDefault ().open (project1); - assertFalse ("Document f1_1_open isn't loaded.", handler.openFiles.contains (f1_1_open.getURL ().toExternalForm ())); - assertFalse ("Document f1_2_open isn't loaded.", handler.openFiles.contains (f1_2_open.getURL ().toExternalForm ())); - assertTrue ("Document f2_1_open is still loaded.", handler.openFiles.contains (f2_1_open.getURL ().toExternalForm ())); + assertFalse ("Document f1_1_open isn't loaded.", handler.openFiles.contains (f1_1_open.toURL ().toExternalForm ())); + assertFalse ("Document f1_2_open isn't loaded.", handler.openFiles.contains (f1_2_open.toURL ().toExternalForm ())); + assertTrue ("Document f2_1_open is still loaded.", handler.openFiles.contains (f2_1_open.toURL ().toExternalForm ())); } public void testSerialize() throws Exception { @@ -242,9 +241,9 @@ fail("There should be TestProject\n" + log); } - assertTrue ("Document f1_1_open is loaded.", handler.openFiles.contains (f1_1_open.getURL ().toExternalForm ())); - assertTrue ("Document f1_2_open is loaded.", handler.openFiles.contains (f1_2_open.getURL ().toExternalForm ())); - assertTrue ("Document f2_1_open is loaded.", handler.openFiles.contains (f2_1_open.getURL ().toExternalForm ())); + assertTrue ("Document f1_1_open is loaded.", handler.openFiles.contains (f1_1_open.toURL ().toExternalForm ())); + assertTrue ("Document f1_2_open is loaded.", handler.openFiles.contains (f1_2_open.toURL ().toExternalForm ())); + assertTrue ("Document f2_1_open is loaded.", handler.openFiles.contains (f2_1_open.toURL ().toExternalForm ())); } public void testCloseProjectWithoutOpenDocuments () throws Exception { @@ -253,9 +252,9 @@ assertFalse ("Project1 isn't opened.", OpenProjectList.getDefault ().isOpen (project1)); assertTrue ("Project2 is opened.", OpenProjectList.getDefault ().isOpen (project2)); - handler.openFiles.remove (f2_1_open.getURL ().toExternalForm ()); + handler.openFiles.remove (f2_1_open.toURL ().toExternalForm ()); - assertFalse ("Document f2_1_open isn't loaded.", handler.openFiles.contains (f2_1_open.getURL ().toExternalForm ())); + assertFalse ("Document f2_1_open isn't loaded.", handler.openFiles.contains (f2_1_open.toURL ().toExternalForm ())); ProjectUtilities.closeAllDocuments(new Project[] {project2}, false); OpenProjectList.getDefault().close(new Project[] {project2}, false); @@ -398,11 +397,9 @@ DataObject dobj = null; try { dobj = DataObject.find (fo); - url = dobj.getPrimaryFile ().getURL (); + url = dobj.getPrimaryFile ().toURL (); urls4project.get(owner).add(url.toExternalForm()); - openFiles.add (fo.getURL ().toExternalForm ()); - } catch (FileStateInvalidException fsie) { - fail ("FileStateInvalidException in " + dobj.getPrimaryFile ()); + openFiles.add (fo.toURL ().toExternalForm ()); } catch (DataObjectNotFoundException donfe) { fail ("DataObjectNotFoundException on " + fo); } @@ -420,11 +417,9 @@ FileObject fo = null; try { fo = URLMapper.findFileObject (new URL (url)); - openFiles.remove (fo.getURL ().toExternalForm ()); + openFiles.remove (fo.toURL ().toExternalForm ()); } catch (MalformedURLException mue) { fail ("MalformedURLException in " + url); - } catch (FileStateInvalidException fsie) { - fail ("FileStateInvalidException in " + fo); } } } --- a/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeTest.java +++ a/projectui/test/unit/src/org/netbeans/modules/project/ui/ProjectsRootNodeTest.java @@ -412,7 +412,7 @@ public @Override void addChangeListener(ChangeListener listener) {} public @Override void removeChangeListener(ChangeListener listener) {} })); - final LazyProject lp = new LazyProject(d.getURL(), "p", new ExtIcon()); + final LazyProject lp = new LazyProject(d.toURL(), "p", new ExtIcon()); Children ch = new ProjectsRootNode.ProjectChildren(ProjectsRootNode.PHYSICAL_VIEW) { public @Override void addNotify() { setKeys(Collections.singleton(new ProjectsRootNode.ProjectChildren.Pair(lp))); --- a/projectui/test/unit/src/org/netbeans/modules/project/ui/api/RecentProjectsTest.java +++ a/projectui/test/unit/src/org/netbeans/modules/project/ui/api/RecentProjectsTest.java @@ -89,7 +89,7 @@ tp.setLookup(Lookups.fixed(new TestProjectInfo(prjName))); testProjects[i] = tp; tpDisplayNames[i] = ProjectUtils.getInformation(tp).getDisplayName(); - tpURLs[i] = tp.getProjectDirectory().getURL(); + tpURLs[i] = tp.getProjectDirectory().toURL(); } } --- a/queries/nbproject/project.xml +++ a/queries/nbproject/project.xml @@ -54,7 +54,7 @@ - 7.19 + 7.57 --- a/queries/src/org/netbeans/api/queries/SharabilityQuery.java +++ a/queries/src/org/netbeans/api/queries/SharabilityQuery.java @@ -46,12 +46,9 @@ import java.io.File; import java.net.URI; -import java.net.URISyntaxException; -import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.spi.queries.SharabilityQueryImplementation2; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import org.openide.util.Parameters; @@ -232,13 +229,6 @@ * @since 1.27 */ public static Sharability getSharability(FileObject fo) { - try { - return getSharability(fo.getURL().toURI()); - } catch (URISyntaxException ex) { - LOG.log(Level.FINE, null, ex); - } catch (FileStateInvalidException ex) { - LOG.log(Level.FINE, null, ex); - } - return Sharability.UNKNOWN; + return getSharability(fo.toURI()); } }