Bug 351506 - [rename] Eclipse fails to rename a method in a Java project that transitively depends on the project that declares this method
Summary: [rename] Eclipse fails to rename a method in a Java project that transitively...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-07 23:12 EDT by Stas Negara CLA
Modified: 2022-05-12 16:14 EDT (History)
7 users (show)

See Also:


Attachments
Three Java projects that reveal the described problem. (3.64 KB, application/zip)
2011-07-08 10:01 EDT, Stas Negara CLA
no flags Details
Plugin projects to reproduce the problem (10.17 KB, application/x-zip-compressed)
2011-11-23 08:37 EST, Deepak Azad CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stas Negara CLA 2011-07-07 23:12:27 EDT
Build Identifier: 20110615-0604

While working on the CodingSpectator <http://codingspectator.cs.illinois.edu/>
project, we tried to rename a method that was referenced in a transitively dependent plugin. We expected that the name of the renamed method would be updated for all references, but Eclipse did not update it in this plugin.


Reproducible: Always

Steps to Reproduce:
1. Create three plugins: pluginA, pluginB, pluginC, and make pluginB depend on pluginA and pluginC depend on pluginB. 

2. Create class A in pluginA:

       public class A {
           public void m() {   }
       }
    
   Create class B in pluginB:

       public class B extends A {
           @Override
           public void m() {   }
       }

   Create class C in pluginC:

       public class C {
           public void someMethod() {
               new B().m();
           }
       }

3. Invoke the rename method refactoring on method m in class A and specify any new name for it (e.g. m1).

4. Eclipse will correctly change the method's name from m to m1 in classes A and B, but will not change it in class C, thus leading to a compilation error. 

Thus, Eclipse looks only for immediate dependencies while performing the rename method refactoring (possibly other kinds of refactorings as well). If pluginC had a direct dependency on pluginA, then rename refactoring would correctly update class C as well.
Comment 1 Stas Negara CLA 2011-07-08 10:01:46 EDT
Created attachment 199332 [details]
Three Java projects that reveal the described problem.

Please note that the above scenario works correctly for plugins, i.e. method m will be correctly renamed in all plugins, including the transitively dependent pluginC. To reproduce the problem, please create Java projects (not plugins): projectA, projectB, projectC. The rest of the steps is the same. You can import these projects from the attached archive and try to rename method m in class A to reproduce this problem.
Comment 2 Deepak Azad CLA 2011-11-23 08:37:50 EST
Created attachment 207413 [details]
Plugin projects to reproduce the problem

(In reply to comment #1)
> Please note that the above scenario works correctly for plugins, i.e. method m
> will be correctly renamed in all plugins, including the transitively dependent
> pluginC. 

Not true. The problem also happens with the attached plugin projects.
Comment 3 Deepak Azad CLA 2011-11-23 08:50:13 EST
- Searching for 'All Occurrences' of 'A.m()' via Search dialog in both cases - Java projects and Plugin projects - does not finds the match in C.
- Removing the overridden method 'm()' from B results in a compile error in both cases.

The refactoring works perfectly when all three classes - A,B,C - are in one project.

Satyam, is this a bug in JDT/Core search?
Markus, is this a bug in the refactoring?
Comment 4 Dani Megert CLA 2012-02-21 06:59:48 EST
It depends on how you setup the project and the plug-ins (manifest). If you let C see A in some way (either by requiring A or by letting B export A), then the rename works. However, it should also work without that.

Looks like a bug in our refactoring code. Note that if we first replace A.m() with A.f() and then rename B.m(), it correctly updates C.someMethod().

Markus, please take a look.
Comment 5 Dani Megert CLA 2012-02-21 07:00:00 EST
.
Comment 6 Eclipse Genie CLA 2020-05-21 09:56:47 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Eclipse Genie CLA 2022-05-12 16:14:53 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.