Community
Participate
Working Groups
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)
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...
Philippe, do you think this new API may be investigated for 3.1?
Finally API change is not necessary to solve this peculiar issue...
Fixed. Search does not find any match now as expected. [jdt-core-internal] See patch file for changes. Test cases added in JavaSearchTests
Verified for 3.1M3 with build I20041102
*** Bug 81783 has been marked as a duplicate of this bug. ***
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...
So, finally, it seems that a new API was necessary in this case => defer post 3.1
There would be a solution using IMethod.getFlags()
So there won't be any API changes needed...(again)
Fixed using Flags.isPrivate(int) API method. [jdt-core-internal] Test case JavaSearchBugsTest#testBug70827() was re-enabled.
Verified in I20050330-0500