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

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/JavaCore.java (-4 / +33 lines)
Lines 3838-3843 Link Here
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
		}
3840
		}
3841
		if (accessRules == null) {
3842
			accessRules = ClasspathEntry.NO_ACCESS_RULES;
3843
		}
3844
		if (extraAttributes == null) {
3845
			extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES;
3846
		}
3841
		return new ClasspathEntry(
3847
		return new ClasspathEntry(
3842
			IPackageFragmentRoot.K_SOURCE,
3848
			IPackageFragmentRoot.K_SOURCE,
3843
			IClasspathEntry.CPE_CONTAINER,
3849
			IClasspathEntry.CPE_CONTAINER,
Lines 4026-4031 Link Here
4026
			boolean isExported) {
4032
			boolean isExported) {
4027
4033
4028
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$
4034
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$
4035
		if (accessRules == null) {
4036
			accessRules = ClasspathEntry.NO_ACCESS_RULES;
4037
		}
4038
		if (extraAttributes == null) {
4039
			extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES;
4040
		}
4029
		boolean hasDotDot = ClasspathEntry.hasDotDot(path);
4041
		boolean hasDotDot = ClasspathEntry.hasDotDot(path);
4030
		if (!hasDotDot && !path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute: " + path); //$NON-NLS-1$
4042
		if (!hasDotDot && !path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute: " + path); //$NON-NLS-1$
4031
		if (sourceAttachmentPath != null) {
4043
		if (sourceAttachmentPath != null) {
Lines 4147-4153 Link Here
4147
			boolean isExported) {
4159
			boolean isExported) {
4148
4160
4149
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4161
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4150
4162
		if (accessRules == null) {
4163
			accessRules = ClasspathEntry.NO_ACCESS_RULES;
4164
		}
4165
		if (extraAttributes == null) {
4166
			extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES;
4167
		}
4151
		return new ClasspathEntry(
4168
		return new ClasspathEntry(
4152
			IPackageFragmentRoot.K_SOURCE,
4169
			IPackageFragmentRoot.K_SOURCE,
4153
			IClasspathEntry.CPE_PROJECT,
4170
			IClasspathEntry.CPE_PROJECT,
Lines 4350-4358 Link Here
4350
4367
4351
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Source path cannot be null"); //$NON-NLS-1$
4368
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Source path cannot be null"); //$NON-NLS-1$
4352
		if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
4369
		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$
4370
		if (exclusionPatterns == null) {
4354
		if (inclusionPatterns == null) throw new ClasspathEntry.AssertionFailedException("Inclusion pattern set cannot be null"); //$NON-NLS-1$
4371
			exclusionPatterns = ClasspathEntry.EXCLUDE_NONE;
4355
4372
		}
4373
		if (inclusionPatterns == null) {
4374
			inclusionPatterns = ClasspathEntry.INCLUDE_ALL;
4375
		}
4376
		if (extraAttributes == null) {
4377
			extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES;
4378
		}
4356
		return new ClasspathEntry(
4379
		return new ClasspathEntry(
4357
			IPackageFragmentRoot.K_SOURCE,
4380
			IPackageFragmentRoot.K_SOURCE,
4358
			IClasspathEntry.CPE_SOURCE,
4381
			IClasspathEntry.CPE_SOURCE,
Lines 4496-4501 Link Here
4496
		if (variablePath.segmentCount() < 1) {
4519
		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$
4520
			throw new ClasspathEntry.AssertionFailedException("Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
4498
		}
4521
		}
4522
		if (accessRules == null) {
4523
			accessRules = ClasspathEntry.NO_ACCESS_RULES;
4524
		}
4525
		if (extraAttributes == null) {
4526
			extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES;
4527
		}
4499
4528
4500
		return new ClasspathEntry(
4529
		return new ClasspathEntry(
4501
			IPackageFragmentRoot.K_SOURCE,
4530
			IPackageFragmentRoot.K_SOURCE,
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+59 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
 * Make sure null references don't make their way into ClasspathEntry's state
5810
 */
5811
public void testForceNullArgumentsToEmptySet() throws CoreException {
5812
	IClasspathEntry e =	JavaCore.newContainerEntry(new Path("JRE_CONTAINER"), null, null, false);
5813
	assertTrue("Access rule was null", e.getAccessRules() != null);
5814
	assertTrue("Extra attributes was null", e.getExtraAttributes() != null);
5815
	assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null);
5816
	assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null);
5817
}
5818
5819
/**
5820
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5821
 * Make sure null references don't make their way into ClasspathEntry's state
5822
 */
5823
public void testForceNullArgumentsToEmptySet2() throws CoreException {
5824
	IClasspathEntry e = JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"), null, null, false);
5825
	assertTrue("Access rule was null", e.getAccessRules() != null);
5826
	assertTrue("Extra attributes was null", e.getExtraAttributes() != null);
5827
	assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null);
5828
	assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null);
5829
}
5830
5831
/**
5832
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5833
 * Make sure null references don't make their way into ClasspathEntry's state 
5834
 */
5835
public void testForceNullArgumentsToEmptySet3() throws CoreException {
5836
	IClasspathEntry e = JavaCore.newProjectEntry(new Path("/P2"), null, false, null, false);
5837
	assertTrue("Access rule was null", e.getAccessRules() != null);
5838
	assertTrue("Extra attributes was null", e.getExtraAttributes() != null);
5839
	assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null);
5840
	assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null);
5841
}
5842
5843
/**
5844
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5845
 * Make sure null references don't make their way into ClasspathEntry's state
5846
 */
5847
public void testForceNullArgumentsToEmptySet4() throws CoreException {
5848
	IClasspathEntry e = JavaCore.newSourceEntry(new Path("/P"), null, null, null, null);
5849
	assertTrue("Access rule was null", e.getAccessRules() != null);
5850
	assertTrue("Extra attributes was null", e.getExtraAttributes() != null);
5851
	assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null);
5852
	assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null);
5853
}
5854
5855
/**
5856
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=170197"
5857
 * Make sure null references don't make their way into ClasspathEntry's state
5858
 */
5859
public void testForceNullArgumentsToEmptySet5() throws CoreException {
5860
	IClasspathEntry e = JavaCore.newVariableEntry(new Path("JCL_LIB"), new Path("JCL_SRC"), null, null, null, false); 
5861
	assertTrue("Access rule was null", e.getAccessRules() != null);
5862
	assertTrue("Extra attributes was null", e.getExtraAttributes() != null);
5863
	assertTrue("Inclusion pattern was null", e.getInclusionPatterns() != null);
5864
	assertTrue("Exclusion pattern was null", e.getExclusionPatterns() != null);
5865
}
5807
5866
5808
}
5867
}

Return to bug 170197