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 200030 - Introduce Method: Wrong work of Illegal refactoring error
Summary: Introduce Method: Wrong work of Illegal refactoring error
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.0.1
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jan Lahoda
URL: http://wiki.netbeans.org/TS_60_Refact...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-11 08:33 UTC by ttokoly
Modified: 2011-07-20 11:53 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 ttokoly 2011-07-11 08:33:03 UTC
Product Version: NetBeans IDE 7.0.1 (Build 201107102202)
Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

1. Unzip a project Refactoring to some work directory - there is link:
http://wiki.netbeans.org/wiki/images/0/0e/Refactoring_TS_60_Refactoring2.zip
2. Start IDE with a clean userdir
3. Invoke File | Open Project... action
4. Select unzipped project Refactoring
5. Scanning structure of project should be performed (it takes a while)

6. Open file packageA.ClassA
7. Mark code between //6 and //7
8. Refactor -> Introduce Method
9. Try to change the continue command to break and return respectively and repeat steps 2) and 3).
10. Comment out the line "s = s+"--, ";" and try again

According to the Refactoring TS ( http://wiki.netbeans.org/TS_60_Refactoring2
-> Illegal refactoring - selection contains return/break/continue ) expected result is that the error message "Too many output parameters" is displayed at first. After commenting out the specified line, the refactoring can be performed and semantic of the code is not changed.

But if you don't comment out the line "s = s+"--, ";" and if you change the command continue to return a new boolean method is created.
Comment 1 Jan Becicka 2011-07-11 12:57:19 UTC
Implemented in hints module
Comment 2 Jan Lahoda 2011-07-20 11:53:39 UTC
When the first "continue" is replaced with "return", the value assigned to "s" cannot be used in the calling method anyway, and the method can be introduced. This changed in 7.0.1 as a consequence of (more) precise flow analysis, and we are not going to change it.