View | Details | Raw Unified | Return to bug 323785
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 229-236 Link Here
229
	if (isStructuralChange) {
229
	if (isStructuralChange) {
230
		String last = path.lastSegment();
230
		String last = path.lastSegment();
231
		if (last.length() == TypeConstants.PACKAGE_INFO_NAME.length)
231
		if (last.length() == TypeConstants.PACKAGE_INFO_NAME.length)
232
			if (CharOperation.equals(last.toCharArray(), TypeConstants.PACKAGE_INFO_NAME))
232
			if (CharOperation.equals(last.toCharArray(), TypeConstants.PACKAGE_INFO_NAME)) {
233
				path = path.removeLastSegments(1); // the package-info file has changed so blame the package itself
233
				path = path.removeLastSegments(1); // the package-info file has changed so blame the package itself
234
				/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=323785, in the case of default package,
235
				   there is no need to blame the package itself as there can be no annotations or documentation
236
				   comment tags in the package-info file that can influence the rest of the package. Just bail out
237
				   so we don't touch null objects below.
238
				 */
239
				if (path.isEmpty())
240
					return;
241
			}
234
	}
242
	}
235
243
236
	if (isStructuralChange && !this.hasStructuralChanges) {
244
	if (isStructuralChange && !this.hasStructuralChanges) {
(-)src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java (+48 lines)
Lines 228-233 Link Here
228
		otherPackageInfoPath,
228
		otherPackageInfoPath,
229
		new Problem("my/foo/package-info.java", "The type package-info is already defined", otherPackageInfoPath, 0, 0, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
229
		new Problem("my/foo/package-info.java", "The type package-info is already defined", otherPackageInfoPath, 0, 0, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
230
}
230
}
231
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323785 
232
// (NPE upon creation/deletion of package-info.java in default package)
233
public void test323785 () throws JavaModelException {
234
	
235
	IPath projectPath = env.addProject("Project", "1.5"); 
236
	env.addExternalJars(projectPath, Util.getJavaClassLibs());
237
	fullBuild(projectPath);
238
239
	// remove old package fragment root so that names don't collide
240
	env.removePackageFragmentRoot(projectPath, ""); 
241
242
	IPath root = env.addPackageFragmentRoot(projectPath, "src");
243
	env.setOutputFolder(projectPath, "bin"); 
244
	
245
	fullBuild(projectPath);
246
247
	env.addFile(root, "package-info.java",	"");
248
249
	incrementalBuild(projectPath);
250
	expectingNoProblems();
251
	
252
}
253
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323785
254
// verify that changes to package info containing secondary types do trigger incremental build.
255
public void test323785a () throws JavaModelException {
256
	
257
	IPath projectPath = env.addProject("Project", "1.5"); 
258
	env.addExternalJars(projectPath, Util.getJavaClassLibs());
259
	fullBuild(projectPath);
260
261
	// remove old package fragment root so that names don't collide
262
	env.removePackageFragmentRoot(projectPath, ""); 
263
264
	IPath root = env.addPackageFragmentRoot(projectPath, "src");
265
	env.setOutputFolder(projectPath, "bin"); 
266
	
267
	IPath xJavaPath = env.addFile(root, "X.java",	"class X extends Y {}\n");
268
	fullBuild(projectPath);
269
	env.addFile(root, "package-info.java",	"class Y {}\n");
270
	incrementalBuild(projectPath);
271
	expectingNoProblems();
272
	env.addFile(root, "package-info.java",	"final class Y {}\n");
273
	incrementalBuild(projectPath);
274
	expectingOnlySpecificProblemFor(
275
			xJavaPath,
276
			new Problem("X.java", "The type X cannot subclass the final class Y", xJavaPath, 16, 17, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR));
277
	
278
}
231
protected void assertSourceEquals(String message, String expected, String actual) {
279
protected void assertSourceEquals(String message, String expected, String actual) {
232
	if (actual == null) {
280
	if (actual == null) {
233
		assertEquals(message, expected, null);
281
		assertEquals(message, expected, null);

Return to bug 323785