Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 25528 - move method: incomplete and wrong access level [refactoring]
Summary: move method: incomplete and wrong access level [refactoring]
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Adam Kiezun CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-30 05:40 EST by Thorsten van Ellen CLA
Modified: 2003-01-07 10:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thorsten van Ellen CLA 2002-10-30 05:40:37 EST
Hi!

I moved the method 

protected static void bla(...)

from the class

...common.BeanBase 

to the class

...common.utils.StringUtils

The refactoring tool moved the method textually.
The access level protected was kept, but should have been public.
-> compiler errors followed

References to the method exist only in classes,
that inherit from the original class:

bla(...)

and have to be refactored to:

StringUtils.bla(...)

The tool found all classes that reference that method and
replaced all but one correctly! Only the last one
was not replaced at all!

best regards

Thorsten van Ellen
Comment 1 Adam Kiezun CLA 2002-12-18 06:43:45 EST
>The tool found all classes that reference that method and
>replaced all but one correctly! Only the last one
>was not replaced at all!

for this one i will need a test case


Comment 2 Thorsten van Ellen CLA 2002-12-20 09:02:39 EST
o.k. here is one:
(not yet compiled, but should be complete)

a/A.java:

package a;

public class A
{
  protected static void bla()
  {
    System.out.println("bla");
  }
}

aa/AA.java

package aa;

import a.A;

public class AA extends A
{
  public void blubb()
  {
    System.out.println("blubb");
    A.bla();
  };
}

b/B.java:

package b;

public class B
{
}

Explanation:

Class AA in package aa calls method bla in super class A in package a.
The reference to the method bla in Class A
from the method blubb in class AA is valid,
because AA extends A and therefore has access to bla!

Now, method bla should be moved 
from class A in package a to class B in package b.
Eclipse moves bla unchanged to class B!
The access level of the method bla remains PROTECTED!!!

The reference to the method bla in Class A
from the method blubb in class AA will be changed
from A.bla() to B.bla(), 
but class AA has no access to the protected method in class B!
And this is the problem!

best regards

Thorsten van Ellen
Comment 3 Adam Kiezun CLA 2002-12-20 11:09:50 EST
cool - thanks
will have a look
Comment 4 Adam Kiezun CLA 2002-12-20 11:16:51 EST
so the only problem is the access modifier, right?
making the method publi would make the compiler happy

if so, then we can fix it for M5 i guess
Comment 5 Adam Kiezun CLA 2003-01-07 10:02:30 EST
i decided not to fix for M5 - it's a not very common case (accessing a protected
static member from a subclass) and you get a compiler error right away so it's
very easy to spot and fix

changing the visibility to public would be contrary to other places in Eclipse
refactoring.
so the only thing that could be done here is issuing a warning or an error
during precondition checking.
please reopen if you feel strongly.