View | Details | Raw Unified | Return to bug 170197 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+74 lines)
Lines 5804-5808 Link Here
5804
		deleteProjects(new String[] {"P1", "P2"});
5804
		deleteProjects(new String[] {"P1", "P2"});
5805
	}
5805
	}
5806
}
5806
}
5807
/**
5808
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5809
 * Disallow null extra attributes
5810
 */
5811
public void testAssertNullExtraAttribute() throws CoreException {
5812
	boolean assertedOnNullExtraAttribute = false;
5813
	try {
5814
		JavaCore.newContainerEntry(new Path("JRE_CONTAINER"), ClasspathEntry.NO_ACCESS_RULES, null, false);
5815
	} catch (ClasspathEntry.AssertionFailedException e) {
5816
		if ("Extra attributes cannot be null".equals(e.getMessage()))
5817
			assertedOnNullExtraAttribute = true;
5818
	} 
5819
	assertTrue("Null check didn't work", assertedOnNullExtraAttribute);
5820
}
5821
5822
/**
5823
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5824
 * Disallow null extra attributes
5825
 */
5826
public void testAssertNullExtraAttribute2() throws CoreException {
5827
	boolean assertedOnNullExtraAttribute = false;
5828
	try {
5829
		JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"), null, null, false);
5830
	} catch (ClasspathEntry.AssertionFailedException e) {
5831
		if ("Extra attributes cannot be null".equals(e.getMessage()))
5832
			assertedOnNullExtraAttribute = true;
5833
	} 
5834
	assertTrue("Null check didn't work", assertedOnNullExtraAttribute);
5835
}
5836
5837
/**
5838
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5839
 * Disallow null extra attributes
5840
 */
5841
public void testAssertNullExtraAttribute3() throws CoreException {
5842
	boolean assertedOnNullExtraAttribute = false;
5843
	try {
5844
		JavaCore.newProjectEntry(new Path("/P2"), ClasspathEntry.NO_ACCESS_RULES, false, null, false);
5845
	} catch (ClasspathEntry.AssertionFailedException e) {
5846
		if ("Extra attributes cannot be null".equals(e.getMessage()))
5847
			assertedOnNullExtraAttribute = true;
5848
	} 
5849
	assertTrue("Null check didn't work", assertedOnNullExtraAttribute);
5850
}
5851
5852
/**
5853
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5854
 * Disallow null extra attributes
5855
 */
5856
public void testAssertNullExtraAttribute4() throws CoreException {
5857
	boolean assertedOnNullExtraAttribute = false;
5858
	try {
5859
		JavaCore.newSourceEntry(new Path("/P"), new IPath[0], new IPath[0], null, null);
5860
	} catch (ClasspathEntry.AssertionFailedException e) {
5861
		if ("Extra attributes cannot be null".equals(e.getMessage()))
5862
			assertedOnNullExtraAttribute = true;
5863
	} 
5864
	assertTrue("Null check didn't work", assertedOnNullExtraAttribute);
5865
}
5866
5867
/**
5868
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5869
 * Disallow null extra attributes
5870
 */
5871
public void testAssertNullExtraAttribute5() throws CoreException {
5872
	boolean assertedOnNullExtraAttribute = false;
5873
	try {
5874
		JavaCore.newVariableEntry(new Path("JCL_LIB"), new Path("JCL_SRC"), null, ClasspathEntry.NO_ACCESS_RULES, null, false);
5875
	} catch (ClasspathEntry.AssertionFailedException e) {
5876
		if ("Extra attributes cannot be null".equals(e.getMessage()))
5877
			assertedOnNullExtraAttribute = true;
5878
	} 
5879
	assertTrue("Null check didn't work", assertedOnNullExtraAttribute);
5880
}
5807
5881
5808
}
5882
}
(-)model/org/eclipse/jdt/core/JavaCore.java (-11 / +15 lines)
Lines 3815-3822 Link Here
3815
	 *
3815
	 *
3816
	 * @param containerPath the path identifying the container, it must be formed of at least
3816
	 * @param containerPath the path identifying the container, it must be formed of at least
3817
	 * 	one segment (ID+hints)
3817
	 * 	one segment (ID+hints)
3818
	 * @param accessRules the possibly empty list of access rules for this entry
3818
	 * @param accessRules the possibly empty or null list of access rules for this entry
3819
	 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry
3819
	 * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry
3820
	 * @param isExported a boolean indicating whether this entry is contributed to dependent
3820
	 * @param isExported a boolean indicating whether this entry is contributed to dependent
3821
	 *    projects in addition to the output location
3821
	 *    projects in addition to the output location
3822
	 * @return a new container classpath entry
3822
	 * @return a new container classpath entry
Lines 3837-3842 Link Here
3837
			throw new ClasspathEntry.AssertionFailedException("Container path cannot be null"); //$NON-NLS-1$
3837
			throw new ClasspathEntry.AssertionFailedException("Container path cannot be null"); //$NON-NLS-1$
3838
		} else if (containerPath.segmentCount() < 1) {
3838
		} else if (containerPath.segmentCount() < 1) {
3839
			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$
3839
			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$
3840
		} else if (extraAttributes == null) {
3841
			throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$
3840
		}
3842
		}
3841
		return new ClasspathEntry(
3843
		return new ClasspathEntry(
3842
			IPackageFragmentRoot.K_SOURCE,
3844
			IPackageFragmentRoot.K_SOURCE,
Lines 4010-4017 Link Here
4010
	 *   to the workspace.
4012
	 *   to the workspace.
4011
	 * @param sourceAttachmentRootPath the location of the root of the source files within the source archive or folder
4013
	 * @param sourceAttachmentRootPath the location of the root of the source files within the source archive or folder
4012
	 *    or <code>null</code> if this location should be automatically detected.
4014
	 *    or <code>null</code> if this location should be automatically detected.
4013
	 * @param accessRules the possibly empty list of access rules for this entry
4015
	 * @param accessRules the possibly empty or null list of access rules for this entry
4014
	 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry
4016
	 * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry
4015
	 * @param isExported indicates whether this entry is contributed to dependent
4017
	 * @param isExported indicates whether this entry is contributed to dependent
4016
	 * 	  projects in addition to the output location
4018
	 * 	  projects in addition to the output location
4017
	 * @return a new library classpath entry
4019
	 * @return a new library classpath entry
Lines 4026-4031 Link Here
4026
			boolean isExported) {
4028
			boolean isExported) {
4027
4029
4028
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$
4030
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$
4031
		if (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$
4029
		boolean hasDotDot = ClasspathEntry.hasDotDot(path);
4032
		boolean hasDotDot = ClasspathEntry.hasDotDot(path);
4030
		if (!hasDotDot && !path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute: " + path); //$NON-NLS-1$
4033
		if (!hasDotDot && !path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute: " + path); //$NON-NLS-1$
4031
		if (sourceAttachmentPath != null) {
4034
		if (sourceAttachmentPath != null) {
Lines 4131-4139 Link Here
4131
	 * </p>
4134
	 * </p>
4132
	 *
4135
	 *
4133
	 * @param path the absolute path of the prerequisite project
4136
	 * @param path the absolute path of the prerequisite project
4134
	 * @param accessRules the possibly empty list of access rules for this entry
4137
	 * @param accessRules the possibly empty or null list of access rules for this entry
4135
	 * @param combineAccessRules whether the access rules of the project's exported entries should be combined with the given access rules
4138
	 * @param combineAccessRules whether the access rules of the project's exported entries should be combined with the given access rules
4136
	 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry
4139
	 * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry
4137
	 * @param isExported indicates whether this entry is contributed to dependent
4140
	 * @param isExported indicates whether this entry is contributed to dependent
4138
	 * 	  projects in addition to the output location
4141
	 * 	  projects in addition to the output location
4139
	 * @return a new project classpath entry
4142
	 * @return a new project classpath entry
Lines 4147-4153 Link Here
4147
			boolean isExported) {
4150
			boolean isExported) {
4148
4151
4149
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4152
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4150
4153
		if (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$
4151
		return new ClasspathEntry(
4154
		return new ClasspathEntry(
4152
			IPackageFragmentRoot.K_SOURCE,
4155
			IPackageFragmentRoot.K_SOURCE,
4153
			IClasspathEntry.CPE_PROJECT,
4156
			IClasspathEntry.CPE_PROJECT,
Lines 4339-4345 Link Here
4339
	 * @param exclusionPatterns the possibly empty list of exclusion patterns
4342
	 * @param exclusionPatterns the possibly empty list of exclusion patterns
4340
	 *    represented as relative paths
4343
	 *    represented as relative paths
4341
	 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
4344
	 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
4342
	 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry
4345
	 * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry
4343
	 * @return a new source classpath entry with the given exclusion patterns
4346
	 * @return a new source classpath entry with the given exclusion patterns
4344
	 * @see IClasspathEntry#getInclusionPatterns()
4347
	 * @see IClasspathEntry#getInclusionPatterns()
4345
	 * @see IClasspathEntry#getExclusionPatterns()
4348
	 * @see IClasspathEntry#getExclusionPatterns()
Lines 4352-4358 Link Here
4352
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4355
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4353
		if (exclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Exclusion pattern set cannot be null"); //$NON-NLS-1$
4356
		if (exclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Exclusion pattern set cannot be null"); //$NON-NLS-1$
4354
		if (inclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Inclusion pattern set cannot be null"); //$NON-NLS-1$
4357
		if (inclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Inclusion pattern set cannot be null"); //$NON-NLS-1$
4355
4358
		if (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$
4356
		return new ClasspathEntry(
4359
		return new ClasspathEntry(
4357
			IPackageFragmentRoot.K_SOURCE,
4360
			IPackageFragmentRoot.K_SOURCE,
4358
			IClasspathEntry.CPE_SOURCE,
4361
			IClasspathEntry.CPE_SOURCE,
Lines 4477-4484 Link Here
4477
	 *    as the one that begins <code>variablePath</code>)
4480
	 *    as the one that begins <code>variablePath</code>)
4478
	 * @param variableSourceAttachmentRootPath the location of the root of the source files within the source archive
4481
	 * @param variableSourceAttachmentRootPath the location of the root of the source files within the source archive
4479
	 *    or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code>
4482
	 *    or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code>
4480
	 * @param accessRules the possibly empty list of access rules for this entry
4483
	 * @param accessRules the possibly empty or null list of access rules for this entry
4481
	 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry
4484
	 * @param extraAttributes the possibly empty, non null list of extra attributes to persist with this entry
4482
	 * @param isExported indicates whether this entry is contributed to dependent
4485
	 * @param isExported indicates whether this entry is contributed to dependent
4483
	 * 	  projects in addition to the output location
4486
	 * 	  projects in addition to the output location
4484
	 * @return a new variable classpath entry
4487
	 * @return a new variable classpath entry
Lines 4496-4501 Link Here
4496
		if (variablePath.segmentCount() < 1) {
4499
		if (variablePath.segmentCount() < 1) {
4497
			throw new ClasspathEntry.AssertionFailedException("Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
4500
			throw new ClasspathEntry.AssertionFailedException("Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
4498
		}
4501
		}
4502
		if (extraAttributes == null) throw new ClasspathEntry.AssertionFailedException("Extra attributes cannot be null"); //$NON-NLS-1$
4499
4503
4500
		return new ClasspathEntry(
4504
		return new ClasspathEntry(
4501
			IPackageFragmentRoot.K_SOURCE,
4505
			IPackageFragmentRoot.K_SOURCE,

Return to bug 170197