### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/JavaCore.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v retrieving revision 1.635 diff -u -r1.635 JavaCore.java --- model/org/eclipse/jdt/core/JavaCore.java 21 Apr 2009 15:34:36 -0000 1.635 +++ model/org/eclipse/jdt/core/JavaCore.java 12 May 2009 10:08:09 -0000 @@ -3838,6 +3838,12 @@ } else if (containerPath.segmentCount() < 1) { throw new ClasspathEntry.AssertionFailedException("Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$ } + if (accessRules == null) { + accessRules = ClasspathEntry.NO_ACCESS_RULES; + } + if (extraAttributes == null) { + extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; + } return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_CONTAINER, @@ -4026,6 +4032,12 @@ boolean isExported) { if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$ + if (accessRules == null) { + accessRules = ClasspathEntry.NO_ACCESS_RULES; + } + if (extraAttributes == null) { + extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; + } boolean hasDotDot = ClasspathEntry.hasDotDot(path); if (!hasDotDot && !path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute: " + path); //$NON-NLS-1$ if (sourceAttachmentPath != null) { @@ -4147,7 +4159,12 @@ boolean isExported) { if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ - + if (accessRules == null) { + accessRules = ClasspathEntry.NO_ACCESS_RULES; + } + if (extraAttributes == null) { + extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; + } return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_PROJECT, @@ -4350,9 +4367,15 @@ if (path == null) throw new ClasspathEntry.AssertionFailedException("Source path cannot be null"); //$NON-NLS-1$ if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ - if (exclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Exclusion pattern set cannot be null"); //$NON-NLS-1$ - if (inclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Inclusion pattern set cannot be null"); //$NON-NLS-1$ - + if (exclusionPatterns == null) { + exclusionPatterns = ClasspathEntry.EXCLUDE_NONE; + } + if (inclusionPatterns == null) { + inclusionPatterns = ClasspathEntry.INCLUDE_ALL; + } + if (extraAttributes == null) { + extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; + } return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, @@ -4496,6 +4519,12 @@ if (variablePath.segmentCount() < 1) { throw new ClasspathEntry.AssertionFailedException("Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$ } + if (accessRules == null) { + accessRules = ClasspathEntry.NO_ACCESS_RULES; + } + if (extraAttributes == null) { + extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; + } return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v retrieving revision 1.199 diff -u -r1.199 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 4 May 2009 21:12:19 -0000 1.199 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 12 May 2009 10:08:16 -0000 @@ -5804,5 +5804,64 @@ deleteProjects(new String[] {"P1", "P2"}); } } +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Make sure null references don't make their way into ClasspathEntry's state + */ +public void testForceNullArgumentsToEmptySet() throws CoreException { + IClasspathEntry e = JavaCore.newContainerEntry(new Path("JRE_CONTAINER"), null, null, false); + assertTrue("Access rule was null", e.getAccessRules() != null); + assertTrue("Extra attributes was null", e.getExtraAttributes() != null); + assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null); + assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Make sure null references don't make their way into ClasspathEntry's state + */ +public void testForceNullArgumentsToEmptySet2() throws CoreException { + IClasspathEntry e = JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"), null, null, false); + assertTrue("Access rule was null", e.getAccessRules() != null); + assertTrue("Extra attributes was null", e.getExtraAttributes() != null); + assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null); + assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Make sure null references don't make their way into ClasspathEntry's state + */ +public void testForceNullArgumentsToEmptySet3() throws CoreException { + IClasspathEntry e = JavaCore.newProjectEntry(new Path("/P2"), null, false, null, false); + assertTrue("Access rule was null", e.getAccessRules() != null); + assertTrue("Extra attributes was null", e.getExtraAttributes() != null); + assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null); + assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Make sure null references don't make their way into ClasspathEntry's state + */ +public void testForceNullArgumentsToEmptySet4() throws CoreException { + IClasspathEntry e = JavaCore.newSourceEntry(new Path("/P"), null, null, null, null); + assertTrue("Access rule was null", e.getAccessRules() != null); + assertTrue("Extra attributes was null", e.getExtraAttributes() != null); + assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null); + assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Make sure null references don't make their way into ClasspathEntry's state + */ +public void testForceNullArgumentsToEmptySet5() throws CoreException { + IClasspathEntry e = JavaCore.newVariableEntry(new Path("JCL_LIB"), new Path("JCL_SRC"), null, null, null, false); + assertTrue("Access rule was null", e.getAccessRules() != null); + assertTrue("Extra attributes was null", e.getExtraAttributes() != null); + assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null); + assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null); +} }