Community
Participate
Working Groups
User-Agent: Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.2.15 Version/10.00 Build Identifier: M20090211-1700 Can’t create type hierarchy for abstract types when they have inline descendants and *.class* in project name. Reproducible: Always Steps to Reproduce: 1.Create project with name containing the following pattern *.class* (e.g. bug.class_test) 2.Create simple abstract class; 3.Create class that extends abstract class 4.Try to see type hierarchy for abstract class -- everything should work fine 5.Create simple class with any method where you create an inline instance of abstract class; 6.Save it. Now you are not able to see hierarchy for abstract class. See error log As we can't create type hierarchy, java code analysis functionality may not work correctly found in 3.4.2 but exists in 3.5 too
Created attachment 146555 [details] example project example plugin with buggy classes
Created attachment 146556 [details] error log
Oops (looking at IndexBasedHierarchyBuilder.searchAllPossibleSubTypes()): int suffix = documentPath.toLowerCase().lastIndexOf(SUFFIX_STRING_class); if this matches in the middle of a string, I wouldn't call it a suffix ;-) further down substring(lastSlash+1, suffix) tries to create a substring with negative length since suffix is smaller than lastSlash. how about: if (documentPath.toLowerCase().endsWith(SUFFIX_STRING_class)) { int suffix = documentPath.length()-SUFFIX_STRING_class.lenght(); ?
looks good :) . Should work :)
Created attachment 146576 [details] proposed patch with test Here you go! Now we only need a committer to accept the patch. 2 notes: - I changed the example to use a source folder with ".class" in its name, rather than a project. Fits easier into existing test infrastructure. - I made a search for other occurrences of String.lastIndexOf(String), but none looked suspecious to me. However, many places use this method with a one char String. Would it matter for performance to change it to using lastIndexOf(char)??
about perfomance: an idea came to me int suffix = documentPath.length() - SUFFIX_STRING_class.length(); if (documentPath.substring(suffix).toLowerCase().equals(SUFFIX_STRING_class)) { will work more quickly, especially with long pathes
(In reply to comment #6) > about perfomance: an idea came to me > > int suffix = documentPath.length() - SUFFIX_STRING_class.length(); > if (documentPath.substring(suffix).toLowerCase().equals(SUFFIX_STRING_class)) > { > will work more quickly, especially with long pathes Why do you think so? endsWith looks pretty efficient, plus it avoids to create another string as substring does.
Created attachment 146585 [details] example project with a simple speed test a simple speed test look at SpeedTest.java
Let's review this. Thanks Stephan!
Patch looks good. Thanks for the patch. Released for 3.6M2. Regression test added in: org.eclipse.jdt.core.tests.model.TypeHierarchyTests#testBug288698
Verified for 3.6M2
*** Bug 295206 has been marked as a duplicate of this bug. ***