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.
1. Create new simple java class: package introduceParameter; public class Class_A_A{ public void m(int param, String... varargs ) { String x = "ABC"; String y = "ABC"; int z = 12345; } public void usage() { new Class_A_A(); m(1,"",""); } } 2. Select text "ABC" in statement String x = "ABC"; 3. Bu Alt+Shift+P invoke introduce parameter dialog 4. Set this dialog according the attached image "before" 5. Press Refactor and you'll get broken code (see "after") Product Version: NetBeans IDE 7.4 (Build 201310111528) Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08 Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18 System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Created attachment 141249 [details] before
Created attachment 141250 [details] after
Reproducible, but not sure what the best fix would be. The other major IDEs do not solve it either
I'm not sure about the best fix as well One solution would be to to change all call m(1,"",""); to m(1, new String[]{"1", "2"}); but it will destroy the beauty of varargs. Another solution would be not to perform refactoring is such case or at lest show warning. e.g. when introducing parameter of type T when there is vararg of type T...
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