### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: workspace/TypeHierarchy/.classpath =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/TypeHierarchy/.classpath,v retrieving revision 1.5 diff -u -r1.5 .classpath --- workspace/TypeHierarchy/.classpath 12 May 2004 10:54:57 -0000 1.5 +++ workspace/TypeHierarchy/.classpath 6 Sep 2009 15:17:17 -0000 @@ -8,5 +8,6 @@ + Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.93 diff -u -r1.93 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 27 Aug 2009 15:26:53 -0000 1.93 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 6 Sep 2009 15:17:17 -0000 @@ -2404,4 +2404,21 @@ deleteProjects(new String[] {"P"}); } } +/** + * @bug 288698: Can’t create type hierarchy for abstract types when they have inline descendants and *.class* in project name + * @test Ensure that ".class" as a substring of a path name is not interpreted as the ".class" suffix. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=288698" + */ +public void testBug288698() throws JavaModelException { + IType type = getCompilationUnit("/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java").getType("AbstractBugTest"); + assertTrue("Type should exist!", type.exists()); + ITypeHierarchy hierarchy = type.newTypeHierarchy(null); // when bug occurred a StringIndexOutOfBoundsException was thrown here + assertHierarchyEquals( + "Focus: AbstractBugTest [in AbstractBugTest.java [in p288698 [in src288698.classbug [in TypeHierarchy]]]]\n" + + "Super types:\n" + + " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Sub types:\n" + + " [in testIt() [in BugTest2Buggy [in BugTest2Buggy.java [in p288698 [in src288698.classbug [in TypeHierarchy]]]]]]\n", + hierarchy); +} } Index: workspace/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java =================================================================== RCS file: workspace/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java diff -N workspace/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +package p288698.example; + +/** + * Abstract class + * + * @author Ivan + */ +public abstract class AbstractBugTest { +} Index: workspace/TypeHierarchy/src288698.classbug/p288698/BugTest2Buggy.java =================================================================== RCS file: workspace/TypeHierarchy/src288698.classbug/p288698/BugTest2Buggy.java diff -N workspace/TypeHierarchy/src288698.classbug/p288698/BugTest2Buggy.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src288698.classbug/p288698/BugTest2Buggy.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +package p288698; + +/** + * create type hierarchy for class @see AbstractBugTest + * You will get @see java.lang.reflect.InvocationTargetException where Root exception is: + * + * @see java.lang.StringIndexOutOfBoundsException: String index out of range: -27; method substring (), called by @see + * org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.java : 475 + * + * @author Ivan + */ +public class BugTest2Buggy { + public void testIt () { + new AbstractBugTest() {}; + } +} + #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java,v retrieving revision 1.108 diff -u -r1.108 IndexBasedHierarchyBuilder.java --- model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java 7 Mar 2009 01:08:09 -0000 1.108 +++ model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java 6 Sep 2009 15:17:20 -0000 @@ -460,8 +460,8 @@ boolean isLocalOrAnonymous = record.enclosingTypeName == IIndexConstants.ONE_ZERO; pathRequestor.acceptPath(documentPath, isLocalOrAnonymous); char[] typeName = record.simpleName; - int suffix = documentPath.toLowerCase().lastIndexOf(SUFFIX_STRING_class); - if (suffix != -1){ + if (documentPath.toLowerCase().endsWith(SUFFIX_STRING_class)) { + int suffix = documentPath.length()-SUFFIX_STRING_class.length(); HierarchyBinaryType binaryType = (HierarchyBinaryType)binariesFromIndexMatches.get(documentPath); if (binaryType == null){ char[] enclosingTypeName = record.enclosingTypeName;