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

(-)workspace/TypeHierarchy/.classpath (+1 lines)
Lines 8-12 Link Here
8
    <classpathentry kind="lib" path="test54043.jar"/>
8
    <classpathentry kind="lib" path="test54043.jar"/>
9
    <classpathentry kind="lib" path="test58440.jar"/>
9
    <classpathentry kind="lib" path="test58440.jar"/>
10
    <classpathentry kind="lib" path="test60365.jar"/>
10
    <classpathentry kind="lib" path="test60365.jar"/>
11
    <classpathentry kind="src" path="src288698.classbug"/>
11
    <classpathentry kind="output" path="bin"/>
12
    <classpathentry kind="output" path="bin"/>
12
</classpath>
13
</classpath>
(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java (+17 lines)
Lines 2404-2407 Link Here
2404
		deleteProjects(new String[] {"P"});
2404
		deleteProjects(new String[] {"P"});
2405
	}
2405
	}
2406
}
2406
}
2407
/**
2408
 * @bug 288698: Can’t create type hierarchy for abstract types when they have inline descendants and *.class* in project name 
2409
 * @test Ensure that ".class" as a substring of a path name is not interpreted as the ".class" suffix.
2410
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=288698"
2411
 */
2412
public void testBug288698() throws JavaModelException {
2413
	IType type = getCompilationUnit("/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java").getType("AbstractBugTest");
2414
	assertTrue("Type should exist!", type.exists());
2415
	ITypeHierarchy hierarchy = type.newTypeHierarchy(null); // when bug occurred a StringIndexOutOfBoundsException was thrown here
2416
	assertHierarchyEquals(
2417
		"Focus: AbstractBugTest [in AbstractBugTest.java [in p288698 [in src288698.classbug [in TypeHierarchy]]]]\n" + 
2418
		"Super types:\n" + 
2419
		"  Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + 
2420
		"Sub types:\n" + 
2421
		"  <anonymous #1> [in testIt() [in BugTest2Buggy [in BugTest2Buggy.java [in p288698 [in src288698.classbug [in TypeHierarchy]]]]]]\n",
2422
		hierarchy);
2423
}
2407
}
2424
}
(-)workspace/TypeHierarchy/src288698.classbug/p288698/AbstractBugTest.java (+9 lines)
Added Link Here
1
package p288698.example;
2
3
/**
4
 * Abstract class
5
 * 
6
 * @author Ivan
7
 */
8
public abstract class AbstractBugTest {
9
}
(-)workspace/TypeHierarchy/src288698.classbug/p288698/BugTest2Buggy.java (+17 lines)
Added Link Here
1
package p288698;
2
3
/**
4
 * create type hierarchy for class @see AbstractBugTest
5
 * You will get @see java.lang.reflect.InvocationTargetException where Root exception is:
6
 * 
7
 * @see java.lang.StringIndexOutOfBoundsException: String index out of range: -27; method substring (), called by @see
8
 *      org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.java : 475
9
 * 
10
 * @author Ivan
11
 */
12
public class BugTest2Buggy {
13
	public void testIt () {
14
		new AbstractBugTest() {};
15
	}
16
}
17
(-)model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java (-2 / +2 lines)
Lines 460-467 Link Here
460
			boolean isLocalOrAnonymous = record.enclosingTypeName == IIndexConstants.ONE_ZERO;
460
			boolean isLocalOrAnonymous = record.enclosingTypeName == IIndexConstants.ONE_ZERO;
461
			pathRequestor.acceptPath(documentPath, isLocalOrAnonymous);
461
			pathRequestor.acceptPath(documentPath, isLocalOrAnonymous);
462
			char[] typeName = record.simpleName;
462
			char[] typeName = record.simpleName;
463
			int suffix = documentPath.toLowerCase().lastIndexOf(SUFFIX_STRING_class);
463
			if (documentPath.toLowerCase().endsWith(SUFFIX_STRING_class)) {
464
			if (suffix != -1){
464
			    int suffix = documentPath.length()-SUFFIX_STRING_class.length();
465
				HierarchyBinaryType binaryType = (HierarchyBinaryType)binariesFromIndexMatches.get(documentPath);
465
				HierarchyBinaryType binaryType = (HierarchyBinaryType)binariesFromIndexMatches.get(documentPath);
466
				if (binaryType == null){
466
				if (binaryType == null){
467
					char[] enclosingTypeName = record.enclosingTypeName;
467
					char[] enclosingTypeName = record.enclosingTypeName;

Return to bug 288698