Bug 88300

Summary: [search] Reference search result is changed by placement of private method
Product: [Eclipse Project] JDT Reporter: Tammo Freese <freese>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: steffen.kuenzel
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Tammo Freese CLA 2005-03-17 04:26:11 EST
We've found this strange behavior on 3.1M5a.

package search;
public class SuperClass {
    public void aMethod(Object x) {
    }
}

package search;
public class SubClass extends SuperClass {
    public void aMethod(Object x) {
    }
    private void aMethod(String x) {
    }
}

package search;
public class User {
    public void methodUsingSubClassMethod() {
        SuperClass user = new SubClass();
        user.aMethod(new Object());
    }
}

When we do a reference search on SubClass.aMethod(Object x),
we get the result:
search.User.methodUsingSubClassMethod()

But if we change the order of the methods in SubClass (see below),
no references are found!
In Eclipse 3.0.1 the problem does not occur.

package search;
public class SubClass extends SuperClass {
    private void aMethod(String x) {
    }
    public void aMethod(Object x) {
    }
}
Comment 1 Frederic Fusier CLA 2005-03-23 18:11:32 EST
Increase severity of this bug as requested by user:
"I would like to suggest that we raise the severity of #88300 to 'critical',
since the incomplete search result may lead to the
assumption that a method is not called anymore and therefore to 
the deletion of the method. The compiler would not complain,
since the signature is available in the superclass. 

The code would be available in the attic of the SCM, but 
this kind of cleaning up could lead to the introduction of subtle bugs.
We only found this problem by pure luck and considered it so severe
that we decided to switch back to 3.0.1."

Comment 2 Frederic Fusier CLA 2005-03-23 18:16:55 EST
In fact, it has been already fixed and released in HEAD stream as we discover by
another way (mails titled "Unreferenced methods" on jdt-core-dev@eclipse.org
were talking about this issue).

When available, you can use this week integration build or next week 3.1 M6
milestone to have this bug fixed.

[jdt-core-dev internal]
Add specific test cases #testBug88300 and #testBug88300b in JavaSearchBugsTest
and rename #testBug70827b as #testBug88300c.
Also update buildnotes_jdt-core.html
Comment 3 Olivier Thomann CLA 2005-03-30 16:59:43 EST
Verified in I20050330-0500