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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+69 lines)
Lines 336-341 Link Here
336
	suite.addTest(new ClasspathTests("testBug229042"));
336
	suite.addTest(new ClasspathTests("testBug229042"));
337
	suite.addTest(new ClasspathTests("testBug274737"));
337
	suite.addTest(new ClasspathTests("testBug274737"));
338
	suite.addTest(new ClasspathTests("testBug357425"));
338
	suite.addTest(new ClasspathTests("testBug357425"));
339
	suite.addTest(new ClasspathTests("testBug287164"));
339
	return suite;
340
	return suite;
340
}
341
}
341
public void setUpSuite() throws Exception {
342
public void setUpSuite() throws Exception {
Lines 2022-2027 Link Here
2022
public void testClasspathValidation22() throws CoreException {
2023
public void testClasspathValidation22() throws CoreException {
2023
	try {
2024
	try {
2024
		IJavaProject proj =  this.createJavaProject("P", new String[] {}, "");
2025
		IJavaProject proj =  this.createJavaProject("P", new String[] {}, "");
2026
		proj.setOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.ERROR);
2025
		IClasspathEntry[] originalCP = proj.getRawClasspath();
2027
		IClasspathEntry[] originalCP = proj.getRawClasspath();
2026
2028
2027
		IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+2];
2029
		IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+2];
Lines 2047-2052 Link Here
2047
public void testClasspathValidation23() throws CoreException {
2049
public void testClasspathValidation23() throws CoreException {
2048
	try {
2050
	try {
2049
		IJavaProject proj =  this.createJavaProject("P", new String[] {}, "");
2051
		IJavaProject proj =  this.createJavaProject("P", new String[] {}, "");
2052
		proj.setOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.IGNORE);
2050
		IClasspathEntry[] originalCP = proj.getRawClasspath();
2053
		IClasspathEntry[] originalCP = proj.getRawClasspath();
2051
2054
2052
		IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+2];
2055
		IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+2];
Lines 7268-7272 Link Here
7268
		deleteExternalResource("lib357425_b.jar");
7271
		deleteExternalResource("lib357425_b.jar");
7269
	}
7272
	}
7270
}
7273
}
7274
/**
7275
 * @bug287164: Report build path error if source folder has other source folder as output folder
7276
 * 
7277
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=287164"
7278
 */
7279
public void testBug287164() throws CoreException {
7280
	try {
7281
		IJavaProject proj =  this.createJavaProject("P", new String[] {}, "");
7282
		
7283
		// Test that with the option set to IGNORE, the Java model status returns OK
7284
		proj.setOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.IGNORE);
7285
		IClasspathEntry[] originalCP = proj.getRawClasspath();
7286
7287
		IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+2];
7288
		System.arraycopy(originalCP, 0, newCP, 0, originalCP.length);
7289
		newCP[originalCP.length] = JavaCore.newSourceEntry(new Path("/P/src"), new IPath[0], new Path("/P/src2"));
7290
		newCP[originalCP.length+1] = JavaCore.newSourceEntry(new Path("/P/src2"), new IPath[0], new Path("/P/src"));
7291
7292
		createFolder("/P/src");
7293
		createFolder("/P/src2");
7294
7295
		IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation());
7296
		assertTrue(status.isOK());
7297
		assertStatus(
7298
			"OK",
7299
			status);
7300
		
7301
		proj.setRawClasspath(newCP, null);
7302
		assertMarkers("Unexpected markers", "", proj);
7303
		
7304
		// Test that with the option set to WARNING, status.isOK() returns true
7305
		proj.setOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.WARNING);
7306
7307
		status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation());
7308
		assertTrue(status.isOK());
7309
		assertStatus(
7310
			"Source folder \'src\' in project \'P\' cannot output to distinct source folder \'src2\'",
7311
			status);
7312
7313
		assertMarkers("Unexpected markers", 
7314
				"Source folder \'src\' in project \'P\' cannot output to distinct source folder \'src2\'", proj);
7315
		
7316
		// Test that with the option set to WARNING and the presence of a more severe error scenario, the error status
7317
		// is returned
7318
		IClasspathEntry[] newCP2 = new IClasspathEntry[newCP.length+1];
7319
		System.arraycopy(newCP, 0, newCP2, 0, newCP.length-1);
7320
		newCP2[newCP.length] = JavaCore.newLibraryEntry(new Path("/P/lib2"), null, null);
7321
		newCP2[newCP.length-1] = JavaCore.newSourceEntry(new Path("/P/src2"), new IPath[0], new Path("/P/lib2"));
7322
7323
		status = JavaConventions.validateClasspath(proj, newCP2, proj.getOutputLocation());
7324
		assertFalse(status.isOK());
7325
		assertStatus(
7326
			"Source folder \'src2\' in project 'P' cannot output to library \'lib2\'",
7327
			status);
7328
		
7329
		proj.setOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.ERROR);
7330
7331
		status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation());
7332
		assertStatus(
7333
			"Source folder \'src\' in project \'P\' cannot output to distinct source folder \'src2\'",
7334
			status);
7335
		
7336
	} finally {
7337
		this.deleteProject("P");
7338
	}
7339
}
7271
7340
7272
}
7341
}
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java (-1 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 114-117 Link Here
114
	 * @since 2.0
114
	 * @since 2.0
115
	 */
115
	 */
116
	String CLASSPATH_FILE_FORMAT = "classpathFileFormat"; //$NON-NLS-1$
116
	String CLASSPATH_FILE_FORMAT = "classpathFileFormat"; //$NON-NLS-1$
117
	
118
	/**
119
	 * Output overlapping another source attribute (value <code>"outputOverlappingSource"</code>). 
120
	 * Used only on buildpath problem markers. The value of this attribute is 
121
	 * either "true" or "false".
122
	 * 
123
	 * @since 3.8
124
	 */
125
	String OUTPUT_OVERLAPPING_SOURCE = "outputOverlappingSource"; //$NON-NLS-1$
117
}
126
}
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java (+7 lines)
Lines 345-348 Link Here
345
	 * @since 3.7
345
	 * @since 3.7
346
	 */
346
	 */
347
	public static final int CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT = 1012;
347
	public static final int CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT = 1012;
348
	
349
	/**
350
	 * <p>Status constant indicating that the default or specific output folder is overlapping
351
	 * with another source location. </p>
352
	 * @since 3.8 
353
	 */
354
	public static final int OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE = 1013;
348
}
355
}
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java (-5 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 581-591 Link Here
581
	 *   <li> The project output location path cannot be null, must be absolute and located inside the project.
581
	 *   <li> The project output location path cannot be null, must be absolute and located inside the project.
582
	 *   <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project,
582
	 *   <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project,
583
	 *   <li> A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
583
	 *   <li> A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
584
     *   <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below:
584
     *   <li> Classpath entries or output locations cannot coincide or be nested in each other, except for the following scenarios listed below:
585
	 *      <ul><li> A source folder can coincidate with its own output location, in which case this output can then contain library archives.
585
	 *      <ul><li> A source folder can coincide with its own output location, in which case this output can then contain library archives.
586
	 *                     However, a specific output location cannot coincidate with any library or a distinct source folder than the one referring to it. </li>
586
	 *                     However, a specific output location cannot coincide with any library or a distinct source folder than the one referring to it.<br>
587
	 *                     Note: Since 3.8, this behavior can be overridden by configuring {@link JavaCore#CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE}
588
	 *                     </li>
587
	 *              <li> A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one. </li>
589
	 *              <li> A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one. </li>
588
	 * 			<li> An output location can be nested in a source folder, if the source folder coincidates with the project itself, or if the output
590
	 * 			<li> An output location can be nested in a source folder, if the source folder coincides with the project itself, or if the output
589
	 * 					location is excluded from the source folder.
591
	 * 					location is excluded from the source folder.
590
	 *      </ul>
592
	 *      </ul>
591
	 * </ul>
593
	 * </ul>
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java (+14 lines)
Lines 1879-1884 Link Here
1879
	 */
1879
	 */
1880
	public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
1880
	public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
1881
	/**
1881
	/**
1882
	 * Core option ID: Reporting an output location overlapping another source location.
1883
	 * <p> Indicate the severity of the problem reported when a source entry's output location overlaps another
1884
	 * source entry. </p>
1885
	 * 
1886
	 * <dl>
1887
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource"</code></dd>
1888
	 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
1889
	 * <dt>Default:</dt><dd><code>"error"</code></dd>
1890
	 * </dl>
1891
	 * @since 3.8
1892
	 */
1893
	public static final String CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE = PLUGIN_ID + ".classpath.outputOverlappingAnotherSource";  //$NON-NLS-1$
1894
	/**
1882
	 * Core option ID: Set the timeout value for retrieving the method's parameter names from javadoc.
1895
	 * Core option ID: Set the timeout value for retrieving the method's parameter names from javadoc.
1883
	 * <p>Timeout in milliseconds to retrieve the method's parameter names from javadoc.
1896
	 * <p>Timeout in milliseconds to retrieve the method's parameter names from javadoc.
1884
	 * <p>If the value is <code>0</code>, the parameter names are not fetched and the raw names are returned.
1897
	 * <p>If the value is <code>0</code>, the parameter names are not fetched and the raw names are returned.
Lines 3734-3739 Link Here
3734
							try {
3747
							try {
3735
								if (JavaBuilder.DEBUG)
3748
								if (JavaBuilder.DEBUG)
3736
									System.out.println("Touching " + project.getElementName()); //$NON-NLS-1$
3749
									System.out.println("Touching " + project.getElementName()); //$NON-NLS-1$
3750
								new ClasspathValidation((JavaProject) project).validate(); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=287164
3737
								project.getProject().touch(progressMonitor2);
3751
								project.getProject().touch(progressMonitor2);
3738
							} catch (CoreException e) {
3752
							} catch (CoreException e) {
3739
								// could not touch this project: ignore
3753
								// could not touch this project: ignore
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-9 / +33 lines)
Lines 1777-1782 Link Here
1777
		// perform one separate iteration so as to not take precedence over previously checked scenarii (in particular should
1777
		// perform one separate iteration so as to not take precedence over previously checked scenarii (in particular should
1778
		// diagnose nesting source folder issue before this one, for example, [src]"Project/", [src]"Project/source/" and output="Project/" should
1778
		// diagnose nesting source folder issue before this one, for example, [src]"Project/", [src]"Project/source/" and output="Project/" should
1779
		// first complain about missing exclusion pattern
1779
		// first complain about missing exclusion pattern
1780
		IJavaModelStatus cachedStatus = null;
1780
		for (int i = 0 ; i < length; i++) {
1781
		for (int i = 0 ; i < length; i++) {
1781
			IClasspathEntry entry = classpath[i];
1782
			IClasspathEntry entry = classpath[i];
1782
			if (entry == null) continue;
1783
			if (entry == null) continue;
Lines 1789-1818 Link Here
1789
1790
1790
			if (kind == IClasspathEntry.CPE_SOURCE) {
1791
			if (kind == IClasspathEntry.CPE_SOURCE) {
1791
				IPath output = entry.getOutputLocation();
1792
				IPath output = entry.getOutputLocation();
1792
				if (output == null) continue; // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate)
1793
				if (output == null) output = projectOutputLocation; // if no specific output, still need to check using default output (this line would check default output)
1793
				// if (output == null) output = projectOutputLocation; // if no specific output, still need to check using default output (this line would check default output)
1794
				for (int j = 0; j < length; j++) {
1794
				for (int j = 0; j < length; j++) {
1795
					IClasspathEntry otherEntry = classpath[j];
1795
					IClasspathEntry otherEntry = classpath[j];
1796
					if (otherEntry == entry) continue;
1796
					if (otherEntry == entry) continue;
1797
1797
1798
					// Build some common strings for status message
1799
					boolean opStartsWithProject = projectName.equals(otherEntry.getPath().segment(0));
1800
					String otherPathMsg = opStartsWithProject ? otherEntry.getPath().removeFirstSegments(1).toString() : otherEntry.getPath().makeRelative().toString();
1801
1802
					switch (otherEntry.getEntryKind()) {
1798
					switch (otherEntry.getEntryKind()) {
1803
						case IClasspathEntry.CPE_SOURCE :
1799
						case IClasspathEntry.CPE_SOURCE :
1804
							if (otherEntry.getPath().equals(output)) {
1800
							// Bug 287164 : Report errors of overlapping output locations only if the user sets the corresponding preference.
1805
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotUseDistinctSourceFolderAsOutput, new String[] {entryPathMsg, otherPathMsg, projectName}));
1801
							// The check is required for backward compatibility with bug-fix 36465.
1802
							String option = javaProject.getOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, true);
1803
							if (otherEntry.getPath().equals(output) 
1804
									&& !JavaCore.IGNORE.equals(option)) {
1805
								boolean opStartsWithProject = projectName.equals(otherEntry.getPath().segment(0));
1806
								String otherPathMsg = opStartsWithProject ? otherEntry.getPath().removeFirstSegments(1).toString() : otherEntry.getPath().makeRelative().toString();
1807
								if (JavaCore.ERROR.equals(option)) {
1808
									return new JavaModelStatus(IStatus.ERROR, IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, 
1809
											Messages.bind(Messages.classpath_cannotUseDistinctSourceFolderAsOutput, new String[] {
1810
											entryPathMsg, otherPathMsg, projectName }));
1811
								}
1812
								if (cachedStatus == null) {
1813
									// Note that the isOK() is being overridden to return true. This is an exceptional scenario
1814
									cachedStatus = new JavaModelStatus(IStatus.OK, IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, 
1815
										Messages.bind(Messages.classpath_cannotUseDistinctSourceFolderAsOutput, new String[] {
1816
										entryPathMsg, otherPathMsg, projectName })){
1817
										public boolean isOK() {
1818
											return true;
1819
										}
1820
									};
1821
								}
1806
							}
1822
							}
1807
							break;
1823
							break;
1808
						case IClasspathEntry.CPE_LIBRARY :
1824
						case IClasspathEntry.CPE_LIBRARY :
1809
							if (otherEntry.getPath().equals(output)) {
1825
							if (output != projectOutputLocation && otherEntry.getPath().equals(output)) {
1826
								boolean opStartsWithProject = projectName.equals(otherEntry.getPath().segment(0));
1827
								String otherPathMsg = opStartsWithProject ? otherEntry.getPath().removeFirstSegments(1).toString() : otherEntry.getPath().makeRelative().toString();
1810
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotUseLibraryAsOutput, new String[] {entryPathMsg, otherPathMsg, projectName}));
1828
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotUseLibraryAsOutput, new String[] {entryPathMsg, otherPathMsg, projectName}));
1811
							}
1829
							}
1812
					}
1830
					}
1813
				}
1831
				}
1814
			}
1832
			}
1815
		}
1833
		}
1834
1835
		// NOTE: The above code that checks for IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, can be configured to return
1836
		// a WARNING status and hence should be at the end of this validation method. Any other code that might return a more severe ERROR should be 
1837
		// inserted before the mentioned code.
1838
		if (cachedStatus != null) return cachedStatus;
1839
1816
		return JavaModelStatus.VERIFIED_OK;
1840
		return JavaModelStatus.VERIFIED_OK;
1817
	}
1841
	}
1818
1842
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathValidation.java (-5 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
import org.eclipse.core.resources.IProject;
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.runtime.IPath;
14
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.jdt.core.IClasspathEntry;
16
import org.eclipse.jdt.core.IClasspathEntry;
16
import org.eclipse.jdt.core.IJavaModelStatus;
17
import org.eclipse.jdt.core.IJavaModelStatus;
17
import org.eclipse.jdt.core.JavaModelException;
18
import org.eclipse.jdt.core.JavaModelException;
Lines 37-43 Link Here
37
			// project doesn't exist
38
			// project doesn't exist
38
			IProject resource = this.project.getProject();
39
			IProject resource = this.project.getProject();
39
			if (resource.isAccessible()) {
40
			if (resource.isAccessible()) {
40
				this.project.flushClasspathProblemMarkers(true/*flush cycle markers*/, true/*flush classpath format markers*/);
41
				this.project.flushClasspathProblemMarkers(true/*flush cycle markers*/, true/*flush classpath format markers*/, true /*flush overlapping output markers*/);
41
42
42
				// remove problems and tasks created  by the builder
43
				// remove problems and tasks created  by the builder
43
				JavaBuilder.removeProblemsAndTasksFor(resource);
44
				JavaBuilder.removeProblemsAndTasksFor(resource);
Lines 56-67 Link Here
56
		}
57
		}
57
58
58
		// update classpath format problems
59
		// update classpath format problems
59
		this.project.flushClasspathProblemMarkers(false/*cycle*/, true/*format*/);
60
		this.project.flushClasspathProblemMarkers(false/*cycle*/, true/*format*/, false/*overlapping*/);
60
		if (!status.isOK())
61
		if (!status.isOK())
61
			this.project.createClasspathProblemMarker(status);
62
			this.project.createClasspathProblemMarker(status);
62
63
64
		// update overlapping output problem markers 
65
		this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/, true/*overlapping*/);
66
		
63
		// update resolved classpath problems
67
		// update resolved classpath problems
64
		this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/);
68
		this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/, false/*overlapping*/);
65
69
66
		if (rawClasspath != JavaProject.INVALID_CLASSPATH && outputLocation != null) {
70
		if (rawClasspath != JavaProject.INVALID_CLASSPATH && outputLocation != null) {
67
		 	for (int i = 0; i < rawClasspath.length; i++) {
71
		 	for (int i = 0; i < rawClasspath.length; i++) {
Lines 71-77 Link Here
71
				}
75
				}
72
			 }
76
			 }
73
			status = ClasspathEntry.validateClasspath(this.project, rawClasspath, outputLocation);
77
			status = ClasspathEntry.validateClasspath(this.project, rawClasspath, outputLocation);
74
			if (!status.isOK())
78
			if (status.getCode() != IStatus.OK)
75
				this.project.createClasspathProblemMarker(status);
79
				this.project.createClasspathProblemMarker(status);
76
		 }
80
		 }
77
	}
81
	}
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java (+1 lines)
Lines 58-63 Link Here
58
		defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE);
58
		defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE);
59
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED);
59
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED);
60
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED);
60
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED);
61
		defaultOptionsMap.put(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.ERROR);
61
62
62
		// encoding setting comes from resource plug-in
63
		// encoding setting comes from resource plug-in
63
		optionNames.add(JavaCore.CORE_ENCODING);
64
		optionNames.add(JavaCore.CORE_ENCODING);
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java (-2 / +4 lines)
Lines 1482-1488 Link Here
1482
					propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) ||
1482
					propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) ||
1483
					propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) ||
1483
					propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) ||
1484
					propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) ||
1484
					propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) ||
1485
					propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL)) {
1485
					propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL) ||
1486
					propertyName.equals(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE)) {
1486
					JavaModelManager manager = JavaModelManager.getJavaModelManager();
1487
					JavaModelManager manager = JavaModelManager.getJavaModelManager();
1487
					IJavaModel model = manager.getJavaModel();
1488
					IJavaModel model = manager.getJavaModel();
1488
					IJavaProject[] projects;
1489
					IJavaProject[] projects;
Lines 2249-2255 Link Here
2249
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_ORDER, JavaCore.IGNORE);
2250
		defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_ORDER, JavaCore.IGNORE);
2250
		defaultOptionsMap.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, JavaCore.ERROR);
2251
		defaultOptionsMap.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, JavaCore.ERROR);
2251
		defaultOptionsMap.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.ERROR);
2252
		defaultOptionsMap.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.ERROR);
2252
		defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE);
2253
		defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE); 
2254
		defaultOptionsMap.put(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.ERROR);
2253
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED);
2255
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED);
2254
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED);
2256
		defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED);
2255
2257
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java (-5 / +20 lines)
Lines 433-439 Link Here
433
							new JavaModelStatus(IJavaModelStatusConstants.CLASSPATH_CYCLE, project, cycleString));
433
							new JavaModelStatus(IJavaModelStatusConstants.CLASSPATH_CYCLE, project, cycleString));
434
					}
434
					}
435
				} else {
435
				} else {
436
					project.flushClasspathProblemMarkers(true, false);
436
					project.flushClasspathProblemMarkers(true, false, false);
437
				}
437
				}
438
			}
438
			}
439
		}
439
		}
Lines 803-809 Link Here
803
		IMarker marker = null;
803
		IMarker marker = null;
804
		int severity;
804
		int severity;
805
		String[] arguments = CharOperation.NO_STRINGS;
805
		String[] arguments = CharOperation.NO_STRINGS;
806
		boolean isCycleProblem = false, isClasspathFileFormatProblem = false;
806
		boolean isCycleProblem = false, isClasspathFileFormatProblem = false, isOutputOverlapping = false;
807
		switch (status.getCode()) {
807
		switch (status.getCode()) {
808
808
809
			case  IJavaModelStatusConstants.CLASSPATH_CYCLE :
809
			case  IJavaModelStatusConstants.CLASSPATH_CYCLE :
Lines 830-836 Link Here
830
					return; // setting == IGNORE
830
					return; // setting == IGNORE
831
				}
831
				}
832
				break;
832
				break;
833
833
			case IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE :
834
				isOutputOverlapping = true;
835
				setting = getOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, true);
836
				if (JavaCore.ERROR.equals(setting)) {
837
					severity = IMarker.SEVERITY_ERROR;
838
				} else if (JavaCore.WARNING.equals(setting)) {
839
					severity = IMarker.SEVERITY_WARNING;
840
				} else {
841
					return; // setting == IGNORE
842
				}
843
				break;
834
			default:
844
			default:
835
				IPath path = status.getPath();
845
				IPath path = status.getPath();
836
				if (path != null) arguments = new String[] { path.toString() };
846
				if (path != null) arguments = new String[] { path.toString() };
Lines 852-857 Link Here
852
					IMarker.LOCATION,
862
					IMarker.LOCATION,
853
					IJavaModelMarker.CYCLE_DETECTED,
863
					IJavaModelMarker.CYCLE_DETECTED,
854
					IJavaModelMarker.CLASSPATH_FILE_FORMAT,
864
					IJavaModelMarker.CLASSPATH_FILE_FORMAT,
865
					IJavaModelMarker.OUTPUT_OVERLAPPING_SOURCE,
855
					IJavaModelMarker.ID,
866
					IJavaModelMarker.ID,
856
					IJavaModelMarker.ARGUMENTS ,
867
					IJavaModelMarker.ARGUMENTS ,
857
					IJavaModelMarker.CATEGORY_ID,
868
					IJavaModelMarker.CATEGORY_ID,
Lines 863-868 Link Here
863
					Messages.classpath_buildPath,
874
					Messages.classpath_buildPath,
864
					isCycleProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
875
					isCycleProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
865
					isClasspathFileFormatProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
876
					isClasspathFileFormatProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
877
					isOutputOverlapping ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$
866
					new Integer(status.getCode()),
878
					new Integer(status.getCode()),
867
					Util.getProblemArgumentsForMarker(arguments) ,
879
					Util.getProblemArgumentsForMarker(arguments) ,
868
					new Integer(CategorizedProblem.CAT_BUILDPATH),
880
					new Integer(CategorizedProblem.CAT_BUILDPATH),
Lines 1356-1373 Link Here
1356
	/**
1368
	/**
1357
	 * Remove all markers denoting classpath problems
1369
	 * Remove all markers denoting classpath problems
1358
	 */ //TODO (philippe) should improve to use a bitmask instead of booleans (CYCLE, FORMAT, VALID)
1370
	 */ //TODO (philippe) should improve to use a bitmask instead of booleans (CYCLE, FORMAT, VALID)
1359
	protected void flushClasspathProblemMarkers(boolean flushCycleMarkers, boolean flushClasspathFormatMarkers) {
1371
	protected void flushClasspathProblemMarkers(boolean flushCycleMarkers, boolean flushClasspathFormatMarkers, boolean flushOverlappingOutputMarkers) {
1360
		try {
1372
		try {
1361
			if (this.project.isAccessible()) {
1373
			if (this.project.isAccessible()) {
1362
				IMarker[] markers = this.project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
1374
				IMarker[] markers = this.project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
1363
				for (int i = 0, length = markers.length; i < length; i++) {
1375
				for (int i = 0, length = markers.length; i < length; i++) {
1364
					IMarker marker = markers[i];
1376
					IMarker marker = markers[i];
1365
					if (flushCycleMarkers && flushClasspathFormatMarkers) {
1377
					if (flushCycleMarkers && flushClasspathFormatMarkers && flushOverlappingOutputMarkers) {
1366
						marker.delete();
1378
						marker.delete();
1367
					} else {
1379
					} else {
1368
						String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
1380
						String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
1369
						String classpathFileFormatAttr =  (String)marker.getAttribute(IJavaModelMarker.CLASSPATH_FILE_FORMAT);
1381
						String classpathFileFormatAttr =  (String)marker.getAttribute(IJavaModelMarker.CLASSPATH_FILE_FORMAT);
1382
						String overlappingOutputAttr = (String) marker.getAttribute(IJavaModelMarker.OUTPUT_OVERLAPPING_SOURCE);
1370
						if ((flushCycleMarkers == (cycleAttr != null && cycleAttr.equals("true"))) //$NON-NLS-1$
1383
						if ((flushCycleMarkers == (cycleAttr != null && cycleAttr.equals("true"))) //$NON-NLS-1$
1384
							&& (flushOverlappingOutputMarkers == (overlappingOutputAttr != null && overlappingOutputAttr.equals("true"))) //$NON-NLS-1$
1371
							&& (flushClasspathFormatMarkers == (classpathFileFormatAttr != null && classpathFileFormatAttr.equals("true")))){ //$NON-NLS-1$
1385
							&& (flushClasspathFormatMarkers == (classpathFileFormatAttr != null && classpathFileFormatAttr.equals("true")))){ //$NON-NLS-1$
1372
							marker.delete();
1386
							marker.delete();
1373
						}
1387
						}
Lines 1513-1518 Link Here
1513
						propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) ||
1527
						propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) ||
1514
						propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) ||
1528
						propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) ||
1515
						propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) ||
1529
						propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) ||
1530
						propertyName.equals(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE) ||
1516
						propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL))
1531
						propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL))
1517
					{
1532
					{
1518
						manager.deltaState.addClasspathValidation(JavaProject.this);
1533
						manager.deltaState.addClasspathValidation(JavaProject.this);
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java (+1 lines)
Lines 114-119 Link Here
114
		IJavaModelStatus status = super.verify();
114
		IJavaModelStatus status = super.verify();
115
		if (!status.isOK())
115
		if (!status.isOK())
116
			return status;
116
			return status;
117
		this.project.flushClasspathProblemMarkers(false, false, true);
117
		return ClasspathEntry.validateClasspath(	this.project, this.newRawClasspath, this.newOutputLocation);
118
		return ClasspathEntry.validateClasspath(	this.project, this.newRawClasspath, this.newOutputLocation);
118
	}
119
	}
119
120
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 44-50 Link Here
44
private StringSet structurallyChangedTypes;
44
private StringSet structurallyChangedTypes;
45
public static int MaxStructurallyChangedTypes = 100; // keep track of ? structurally changed types, otherwise consider all to be changed
45
public static int MaxStructurallyChangedTypes = 100; // keep track of ? structurally changed types, otherwise consider all to be changed
46
46
47
public static final byte VERSION = 0x0019; // fix for 325755
47
public static final byte VERSION = 0x001A; // fix for 287164
48
48
49
static final byte SOURCE_FOLDER = 1;
49
static final byte SOURCE_FOLDER = 1;
50
static final byte BINARY_FOLDER = 2;
50
static final byte BINARY_FOLDER = 2;

Return to bug 287164