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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+30 lines)
Lines 8014-8017 Link Here
8014
		packageCollector);
8014
		packageCollector);
8015
}
8015
}
8016
8016
8017
/**
8018
 * @bug 204652 "Open Type": ClassCastException in conjunction with a class folder
8019
 * @test Ensure that no ClassCastException is thrown for a library folder with a jar like name 
8020
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652"
8021
 */
8022
public void testBug204652() throws CoreException {
8023
	IJavaProject javaProject = getJavaProject("JavaSearchBugs");
8024
	IClasspathEntry[] originalRawClasspath = javaProject.getRawClasspath();
8025
	try {
8026
		addLibraryEntry(javaProject, new Path("/JavaSearchBugs/b204652.jar"), false/*not exported*/);
8027
		TypeNameMatchCollector collector = new TypeNameMatchCollector();
8028
		new SearchEngine().searchAllTypeNames(
8029
			"b204652".toCharArray(),
8030
			SearchPattern.R_EXACT_MATCH,
8031
			null,
8032
			SearchPattern.R_PREFIX_MATCH,
8033
			IJavaSearchConstants.TYPE,
8034
			getJavaSearchScopeBugs(),
8035
			collector,
8036
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
8037
			null);
8038
		IPackageFragment pkg = getPackage("/JavaSearchBugs/b204652.jar/b204652");
8039
		pkg.open(null);
8040
		IType result = (IType) collector.matches.get(0);
8041
		assertTrue("Resulting type should exist", result.exists());
8042
	} finally {
8043
		javaProject.setRawClasspath(originalRawClasspath, null);
8044
	}
8045
}
8046
8017
}
8047
}
(-)workspace/JavaSearchBugs/b204652.jar/b204652/X.java (+3 lines)
Added Link Here
1
package b204652;
2
public class X {
3
}
(-)model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java (-4 / +5 lines)
Lines 330-336 Link Here
330
	if (!(o instanceof PackageFragmentRoot))
330
	if (!(o instanceof PackageFragmentRoot))
331
		return false;
331
		return false;
332
	PackageFragmentRoot other = (PackageFragmentRoot) o;
332
	PackageFragmentRoot other = (PackageFragmentRoot) o;
333
	return this.resource.equals(other.resource) && 
333
	return getResource().equals(other.getResource()) && 
334
			this.parent.equals(other.parent);
334
			this.parent.equals(other.parent);
335
}
335
}
336
336
Lines 454-461 Link Here
454
	}
454
	}
455
}		
455
}		
456
public String getElementName() {
456
public String getElementName() {
457
	if (this.resource instanceof IFolder)
457
	IResource res = getResource();
458
		return ((IFolder) this.resource).getName();
458
	if (res instanceof IFolder)
459
		return ((IFolder) res).getName();
459
	return ""; //$NON-NLS-1$
460
	return ""; //$NON-NLS-1$
460
}
461
}
461
/**
462
/**
Lines 716-722 Link Here
716
}
717
}
717
718
718
public int hashCode() {
719
public int hashCode() {
719
	return this.resource.hashCode();
720
	return getResource().hashCode();
720
}
721
}
721
722
722
/**
723
/**

Return to bug 204652