Bug 70827 - [Search] wrong reference match to private method of supertype
Summary: [Search] wrong reference match to private method of supertype
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 81783 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-26 11:01 EDT by Markus Keller CLA
Modified: 2005-03-30 15:11 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2004-07-26 11:01:46 EDT
class A {
	private void privateMethod() {
	}
}

class Second extends A {
	void call() {
		int i= privateMethod();
	}
	int privateMethod() {
		return 1;
	}
}

Search for References to method A#privateMethod().
=> A match is found in Second#call().
=> expected: no match (one could argue about an inaccurate match iff there's no
Second#privateMethod(), but not in this situation)
Comment 1 Frederic Fusier CLA 2004-09-08 12:06:39 EDT
Markus,
Currently, there's no way to avoid this inaccurate result as search patterns do
not have any information about visibility of its java element. If names match
(ie. strings are equals), we report the match and - as demonstrated - sometimes
it can be wrong...

So, change this would imply new API for SearchPattern.

Note that in your test case, search find result only because
Second.privateMethod() is NOT private! If it was, no result would be found to
your search...
Comment 2 Frederic Fusier CLA 2004-09-08 12:08:32 EDT
Philippe, do you think this new API may be investigated for 3.1?
Comment 3 Frederic Fusier CLA 2004-10-12 11:10:22 EDT
Finally API change is not necessary to solve this peculiar issue...
Comment 4 Frederic Fusier CLA 2004-10-14 05:01:05 EDT
Fixed.

Search does not find any match now as expected.

[jdt-core-internal]
See patch file for changes.
Test cases added in JavaSearchTests
Comment 5 David Audel CLA 2004-11-03 05:02:17 EST
Verified for 3.1M3 with build I20041102
Comment 6 Frederic Fusier CLA 2004-12-22 09:53:50 EST
*** Bug 81783 has been marked as a duplicate of this bug. ***
Comment 7 Frederic Fusier CLA 2005-03-21 18:44:29 EST
Reopen bug as fix was time consuming and must be removed.
To get focus method visibility we're obliged to verify method while parsing
compilation units and this slow search by approximatively 5%.
This is not acceptable for such a specific test case...
Comment 8 Frederic Fusier CLA 2005-03-21 18:45:04 EST
So, finally, it seems that a new API was necessary in this case
=> defer post 3.1
Comment 9 Frederic Fusier CLA 2005-03-22 10:05:59 EST
There would be a solution using IMethod.getFlags()
Comment 10 Frederic Fusier CLA 2005-03-22 10:06:43 EST
So there won't be any API changes needed...(again)
Comment 11 Frederic Fusier CLA 2005-03-23 18:18:14 EST
Fixed using Flags.isPrivate(int) API method.

[jdt-core-internal]
Test case JavaSearchBugsTest#testBug70827() was re-enabled.
Comment 12 Olivier Thomann CLA 2005-03-30 15:11:50 EST
Verified in I20050330-0500