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 235588 - [Introduce Method] changes code semantic
Summary: [Introduce Method] changes code semantic
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-06 08:31 UTC by ssazonov
Modified: 2016-07-07 07:17 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
before (27.14 KB, image/png)
2013-09-06 08:31 UTC, ssazonov
Details
after (36.59 KB, image/png)
2013-09-06 08:32 UTC, ssazonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ssazonov 2013-09-06 08:31:27 UTC
1. Assume following java class (note, that output of code is 4):

package simpleapplication123;

public class SimpleApplication123 {

    public static void main(String[] args) {
        myMethod();
    }
    
    static void myMethod(){
        int a = 5;
        if(--a > 0){
            System.out.println(a);
        }
    }
}

2. Select "--a > 0" statement and using Alt+Shift+M invoke "Introduce Method" refactor dialog

3. Enter name "m" and press Ok.

4. You'll get following code:

package simpleapplication123;

public class SimpleApplication123 {

    public static void main(String[] args) {
        myMethod();
    }
    
    static void myMethod(){
        int a = 5;
        if(m(a)){
            System.out.println(a);
        }
    }

    private static boolean m(int a) {
        return --a > 0;
    }
}

>> now the output of code is 5 (see attached images)

Product Version: NetBeans IDE 7.3.1 (Build 201306052037)
Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 ssazonov 2013-09-06 08:31:49 UTC
Created attachment 139737 [details]
before
Comment 2 ssazonov 2013-09-06 08:32:01 UTC
Created attachment 139738 [details]
after
Comment 3 Martin Balin 2016-07-07 07:17:34 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss