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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-3 / +4 lines)
Lines 997-1005 Link Here
997
			JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
997
			JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
998
			ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
998
			ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
999
			HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
999
			HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
1000
			IClasspathEntry[] entries =
1000
			boolean isJavaLike = org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment());
1001
				org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment())
1001
			IClasspathEntry[] entries = isJavaLike ? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
1002
					? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
1003
					: ((JavaProject)project).getResolvedClasspath();
1002
					: ((JavaProject)project).getResolvedClasspath();
1004
1003
1005
			int length	= entries.length;
1004
			int length	= entries.length;
Lines 1011-1016 Link Here
1011
					if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
1010
					if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
1012
					IPath rootPath = entry.getPath();
1011
					IPath rootPath = entry.getPath();
1013
					if (rootPath.equals(resourcePath)) {
1012
					if (rootPath.equals(resourcePath)) {
1013
						if (isJavaLike) 
1014
							return null;
1014
						return project.getPackageFragmentRoot(resource);
1015
						return project.getPackageFragmentRoot(resource);
1015
					} else if (rootPath.isPrefixOf(resourcePath)) {
1016
					} else if (rootPath.isPrefixOf(resourcePath)) {
1016
						// allow creation of package fragment if it contains a .java file that is included
1017
						// allow creation of package fragment if it contains a .java file that is included
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+21 lines)
Lines 6747-6751 Link Here
6747
		ContainerInitializer.setInitializer(null);
6747
		ContainerInitializer.setInitializer(null);
6748
	}
6748
	}
6749
}
6749
}
6750
public void testBug321170() throws Exception {
6751
	try {
6752
		IJavaProject p = this.createJavaProject("P", new String[] {}, "bin");
6753
		
6754
		IFile file = this.createFile("/P/bin/X.java", "public class X {}");
6755
		
6756
		IClasspathEntry[] classpath = new IClasspathEntry[1];
6757
		classpath[0] = JavaCore.newLibraryEntry(new Path("/P/bin/X.java"), null, null);
6758
		setClasspath(p, classpath);
6759
		ICompilationUnit element = (ICompilationUnit)JavaCore.create(file, p);
6760
		assertNotNull("File created", element);
6761
	}
6762
	catch(ClassCastException e){
6763
		fail("classcast exception");
6764
	}
6765
	finally {
6766
		deleteProject("P");
6767
		ContainerInitializer.setInitializer(null);
6768
	}
6769
}
6770
6750
6771
6751
}
6772
}

Return to bug 321170