### Eclipse Workspace Patch 1.0 #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 8 May 2009 06:36:36 -0000 @@ -5804,5 +5804,79 @@ deleteProjects(new String[] {"P1", "P2"}); } } +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Disallow null extra attributes + */ +public void testAssertNullExtraAttribute() throws CoreException { + boolean assertedOnNullExtraAttribute = false; + try { + JavaCore.newContainerEntry(new Path("JRE_CONTAINER"), ClasspathEntry.NO_ACCESS_RULES, null, false); + } catch (ClasspathEntry.AssertionFailedException e) { + if ("Extra attributes cannot be null".equals(e.getMessage())) + assertedOnNullExtraAttribute = true; + } + assertTrue("Null check didn't work", assertedOnNullExtraAttribute); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Disallow null extra attributes + */ +public void testAssertNullExtraAttribute2() throws CoreException { + boolean assertedOnNullExtraAttribute = false; + try { + JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"), null, null, false); + } catch (ClasspathEntry.AssertionFailedException e) { + if ("Extra attributes cannot be null".equals(e.getMessage())) + assertedOnNullExtraAttribute = true; + } + assertTrue("Null check didn't work", assertedOnNullExtraAttribute); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Disallow null extra attributes + */ +public void testAssertNullExtraAttribute3() throws CoreException { + boolean assertedOnNullExtraAttribute = false; + try { + JavaCore.newProjectEntry(new Path("/P2"), ClasspathEntry.NO_ACCESS_RULES, false, null, false); + } catch (ClasspathEntry.AssertionFailedException e) { + if ("Extra attributes cannot be null".equals(e.getMessage())) + assertedOnNullExtraAttribute = true; + } + assertTrue("Null check didn't work", assertedOnNullExtraAttribute); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Disallow null extra attributes + */ +public void testAssertNullExtraAttribute4() throws CoreException { + boolean assertedOnNullExtraAttribute = false; + try { + JavaCore.newSourceEntry(new Path("/P"), new IPath[0], new IPath[0], null, null); + } catch (ClasspathEntry.AssertionFailedException e) { + if ("Extra attributes cannot be null".equals(e.getMessage())) + assertedOnNullExtraAttribute = true; + } + assertTrue("Null check didn't work", assertedOnNullExtraAttribute); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197" + * Disallow null extra attributes + */ +public void testAssertNullExtraAttribute5() throws CoreException { + boolean assertedOnNullExtraAttribute = false; + try { + JavaCore.newVariableEntry(new Path("JCL_LIB"), new Path("JCL_SRC"), null, ClasspathEntry.NO_ACCESS_RULES, null, false); + } catch (ClasspathEntry.AssertionFailedException e) { + if ("Extra attributes cannot be null".equals(e.getMessage())) + assertedOnNullExtraAttribute = true; + } + assertTrue("Null check didn't work", assertedOnNullExtraAttribute); +} } #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 8 May 2009 06:36:42 -0000 @@ -3815,8 +3815,8 @@ * * @param containerPath the path identifying the container, it must be formed of at least * one segment (ID+hints) - * @param accessRules the possibly empty list of access rules for this entry - * @param extraAttributes the possibly empty list of extra attributes to persist with this entry + * @param accessRules the possibly empty or null list of access rules for this entry + * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry * @param isExported a boolean indicating whether this entry is contributed to dependent * projects in addition to the output location * @return a new container classpath entry @@ -3837,6 +3837,8 @@ throw new ClasspathEntry.AssertionFailedException("Container path cannot be null"); //$NON-NLS-1$ } 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$ + } else if (extraAttributes == null) { + throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$ } return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, @@ -4010,8 +4012,8 @@ * to the workspace. * @param sourceAttachmentRootPath the location of the root of the source files within the source archive or folder * or null if this location should be automatically detected. - * @param accessRules the possibly empty list of access rules for this entry - * @param extraAttributes the possibly empty list of extra attributes to persist with this entry + * @param accessRules the possibly empty or null list of access rules for this entry + * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry * @param isExported indicates whether this entry is contributed to dependent * projects in addition to the output location * @return a new library classpath entry @@ -4026,6 +4028,7 @@ boolean isExported) { if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$ + if (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$ 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) { @@ -4131,9 +4134,9 @@ *

* * @param path the absolute path of the prerequisite project - * @param accessRules the possibly empty list of access rules for this entry + * @param accessRules the possibly empty or null list of access rules for this entry * @param combineAccessRules whether the access rules of the project's exported entries should be combined with the given access rules - * @param extraAttributes the possibly empty list of extra attributes to persist with this entry + * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry * @param isExported indicates whether this entry is contributed to dependent * projects in addition to the output location * @return a new project classpath entry @@ -4147,7 +4150,7 @@ boolean isExported) { if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ - + if (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$ return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_PROJECT, @@ -4339,7 +4342,7 @@ * @param exclusionPatterns the possibly empty list of exclusion patterns * represented as relative paths * @param specificOutputLocation the specific output location for this source entry (null if using project default ouput location) - * @param extraAttributes the possibly empty list of extra attributes to persist with this entry + * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry * @return a new source classpath entry with the given exclusion patterns * @see IClasspathEntry#getInclusionPatterns() * @see IClasspathEntry#getExclusionPatterns() @@ -4352,7 +4355,7 @@ 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 (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$ return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, @@ -4477,8 +4480,8 @@ * as the one that begins variablePath) * @param variableSourceAttachmentRootPath the location of the root of the source files within the source archive * or null if variableSourceAttachmentPath is also null - * @param accessRules the possibly empty list of access rules for this entry - * @param extraAttributes the possibly empty list of extra attributes to persist with this entry + * @param accessRules the possibly empty or null list of access rules for this entry + * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry * @param isExported indicates whether this entry is contributed to dependent * projects in addition to the output location * @return a new variable classpath entry @@ -4496,6 +4499,7 @@ 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 (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$ return new ClasspathEntry( IPackageFragmentRoot.K_SOURCE,