diff --git a/api.java.classpath/apichanges.xml b/api.java.classpath/apichanges.xml --- a/api.java.classpath/apichanges.xml +++ b/api.java.classpath/apichanges.xml @@ -73,6 +73,21 @@ + + + Added a constant representing an empty ClassPath + + + + + +

+ Added a constant representing an empty ClassPath like java.util.Collections.EMPTY_LIST. + This ClassPath has no entries and never fires any events. +

+
+ +
Splitting the java API to independent ClassPath API and the rest of the java API diff --git a/api.java.classpath/manifest.mf b/api.java.classpath/manifest.mf --- a/api.java.classpath/manifest.mf +++ b/api.java.classpath/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.java.classpath/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/classpath/Bundle.properties -OpenIDE-Module-Specification-Version: 1.23 +OpenIDE-Module-Specification-Version: 1.24 diff --git a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java b/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java --- a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java +++ b/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java @@ -69,6 +69,7 @@ import org.netbeans.spi.java.classpath.ClassPathProvider; import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation; import org.netbeans.spi.java.classpath.PathResourceImplementation; +import org.netbeans.spi.java.classpath.support.ClassPathSupport; import org.openide.filesystems.FileAttributeEvent; import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileEvent; @@ -204,7 +205,14 @@ * @since org.netbeans.api.java/1 1.13 */ public static final String PROP_INCLUDES = "includes"; - + + /** + * The empty ClassPath. + * Contains no entries and never fires events. + * @since 1.24 + */ + public static final ClassPath EMPTY = ClassPathSupport.createClassPath(new URL[0]); + private static final Logger LOG = Logger.getLogger(ClassPath.class.getName()); private static final Lookup.Result implementations = diff --git a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java b/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 +++ b/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java @@ -706,6 +706,17 @@ assertEquals(cp.toString(), ClassPathSupport.createClassPath(cp.toString()).toString()); // XXX could also test IAE (tricky - need to have a URLMapper in Lookup, etc.) } + + public void testEmptyClassPath() throws Exception { + final ClassPath cp = ClassPath.EMPTY; + assertNotNull(cp); + assertTrue(cp.entries().isEmpty()); + assertEquals(System.identityHashCode(cp), System.identityHashCode(ClassPath.EMPTY)); + java.lang.reflect.Field f = ClassPath.class.getDeclaredField("EMPTY"); + assertNotNull(f); + assertEquals(java.lang.reflect.Modifier.FINAL, f.getModifiers() & java.lang.reflect.Modifier.FINAL); + } + private String massagePath(String path) throws Exception { return path.replace('/', File.separatorChar).replace(':', File.pathSeparatorChar).replace("", getWorkDir().getAbsolutePath()); }