### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.107.2.1 diff -u -r1.107.2.1 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 28 Jun 2007 16:51:08 -0000 1.107.2.1 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 28 Sep 2007 11:37:25 -0000 @@ -8014,4 +8014,34 @@ packageCollector); } +/** + * @bug 204652 "Open Type": ClassCastException in conjunction with a class folder + * @test Ensure that no ClassCastException is thrown for a library folder with a jar like name + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652" + */ +public void testBug204652() throws CoreException { + IJavaProject javaProject = getJavaProject("JavaSearchBugs"); + IClasspathEntry[] originalRawClasspath = javaProject.getRawClasspath(); + try { + addLibraryEntry(javaProject, new Path("/JavaSearchBugs/b204652.jar"), false/*not exported*/); + TypeNameMatchCollector collector = new TypeNameMatchCollector(); + new SearchEngine().searchAllTypeNames( + "b204652".toCharArray(), + SearchPattern.R_EXACT_MATCH, + null, + SearchPattern.R_PREFIX_MATCH, + IJavaSearchConstants.TYPE, + getJavaSearchScopeBugs(), + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + IPackageFragment pkg = getPackage("/JavaSearchBugs/b204652.jar/b204652"); + pkg.open(null); + IType result = (IType) collector.matches.get(0); + assertTrue("Resulting type should exist", result.exists()); + } finally { + javaProject.setRawClasspath(originalRawClasspath, null); + } +} + } \ No newline at end of file Index: workspace/JavaSearchBugs/b204652.jar/b204652/X.java =================================================================== RCS file: workspace/JavaSearchBugs/b204652.jar/b204652/X.java diff -N workspace/JavaSearchBugs/b204652.jar/b204652/X.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/JavaSearchBugs/b204652.jar/b204652/X.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +package b204652; +public class X { +} #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java,v retrieving revision 1.124 diff -u -r1.124 PackageFragmentRoot.java --- model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 26 Apr 2007 13:19:22 -0000 1.124 +++ model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 28 Sep 2007 11:37:27 -0000 @@ -330,7 +330,7 @@ if (!(o instanceof PackageFragmentRoot)) return false; PackageFragmentRoot other = (PackageFragmentRoot) o; - return this.resource.equals(other.resource) && + return getResource().equals(other.getResource()) && this.parent.equals(other.parent); } @@ -454,8 +454,9 @@ } } public String getElementName() { - if (this.resource instanceof IFolder) - return ((IFolder) this.resource).getName(); + IResource res = getResource(); + if (res instanceof IFolder) + return ((IFolder) res).getName(); return ""; //$NON-NLS-1$ } /** @@ -716,7 +717,7 @@ } public int hashCode() { - return this.resource.hashCode(); + return getResource().hashCode(); } /**