This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 128673 - [Use Supertype] Refactoring can change program behavior
Summary: [Use Supertype] Refactoring can change program behavior
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-28 09:45 UTC by Jiri Prox
Modified: 2009-11-02 11:13 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2008-02-28 09:45:02 UTC
Use Super type can change program behavior. It does not check that after changing type another variant of overloaded
method can by called.

Steps to reproduce:
1) have class SubClass extending class SuperClass
2) have a class Test:
public class Test {

    public void method() {
        SubClass sub = new SubClass();
        action(sub);
    }
    
    public void action(SubClass sc) {
        System.out.println("Called on subclass");
        sc.subMethod();
    }
    
    public void action(SuperClass sc) {
        System.out.println("Called on superclass");
        sc.superMethod();
    }
    
    public static void main(String[] args) {
        new Test().method();       
    }
}

3) call Use Supertype on SubClass and select SuperClass as target type
-> the type of 'sub' is changed to SuperType and as result another variant of action method is called
Comment 1 Daniel Prusa 2008-02-29 10:40:40 UTC
reproducible
Comment 2 Jan Pokorsky 2008-12-12 12:35:06 UTC
later
Comment 3 Quality Engineering 2009-11-02 11:13:56 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX