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 236259 - Refactoring "Introduce Method" creates method with unnecessary parameter
Summary: Refactoring "Introduce Method" creates method with unnecessary parameter
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-23 09:33 UTC by k_sch
Modified: 2016-07-07 07:17 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 k_sch 2013-09-23 09:33:34 UTC
Product Version = NetBeans IDE 7.4 Beta (Build 201307092200)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_25
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.25-b01

Given a new Netbeans Java project.
Class with following contents:
"
package testapp;

public class TestClass
{
    private Integer intVar;

    protected void testFunction()
    {
        Integer intVar;
        try
        {
            intVar = Integer.valueOf( 1 );
        }
        catch ( final Exception ex )
        {
            intVar = null;
        }
        finally
        {
        }
        this.intVar = intVar;
    }
}
"

Marking lines enclosed in >>...<<
"
package testapp;

public class TestClass
{
    private Integer intVar;

    protected void testFunction()
    {
>>        Integer intVar;
        try
        {
            intVar = Integer.valueOf( 1 );
        }
        catch ( final Exception ex )
        {
            intVar = null;
        }
        finally
        {
        } <<
        this.intVar = intVar;
    }
}
"
and executing "Introduce Method" (Alt+Shift+M) gives the following result:
"
package testapp;

public class TestClass
{
    private Integer intVar;

    protected void testFunction()
    {
        Integer intVar = introducedMethod( intVar );
        this.intVar = intVar;
    }

    private Integer introducedMethod( Integer intVar )
    {
        Integer intVar;
        try
        {
            intVar = Integer.valueOf( 1 );
        }
        catch ( final Exception ex )
        {
            intVar = null;
        }
        finally
        {
        }
        return intVar;
    }
}
"
which is not compilable. The parameter Integer intVar should not have been generated.
Comment 1 Jiri Prox 2013-09-27 09:21:45 UTC
reproducible
Comment 2 Martin Balin 2016-07-07 07:17:57 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