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.
Build: NetBeans IDE Dev (Build 090529) VM: Java HotSpot(TM) Client VM, 1.5.0_16-133, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_16-b06-284 OS: Mac OS X, 10.5.6, i386 User Comments: msauer: Have following class: package test; public class Test { public static void test(int y) { for (int u = y;;) { if (y == 0) break; else y++; } } } Select whole if-else tree and Introduce method => NPE. This used to work until some fixes had been made on May 22 in CasualDiff and TreeMaker. Stacktrace: java.lang.NullPointerException at org.netbeans.modules.java.source.save.CasualDiff.diffBreak(CasualDiff.java:1065) at org.netbeans.modules.java.source.save.CasualDiff.diffTreeImpl(CasualDiff.java:2684) at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:2583) at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:2571) at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:3115) at org.netbeans.modules.java.source.save.CasualDiff.diffIf(CasualDiff.java:1029)
Created attachment 83055 [details] stacktrace
@fommil: It is caused by one of patches for diff created by you. Please, try to fix it. If you are unable, please let me know.
I can certainly look at it, but can't guarantee timescales.
I've added org.netbeans.api.java.source.gen.BreakContinueTest.testBreak166327() to cover this. --- http://hg.netbeans.org/jet-main/rev/05c113176b5d
Integrated into 'main-golden', will be available in build *200906040201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/05c113176b5d User: Max Sauer <msauer@netbeans.org> Log: #166327: adding test
Created attachment 83281 [details] proposed fix
Proposed fix is also a fix for 166324. The existing code assumes that both the old and new trees have a label part. e.g. "break innerLoop;" The patch does not make this assumption. However, there are two things about the existing code that I do not like. They are perpetuated in the proposed fix:- 1 - There is an assumption that there is only a single space character of whitespace between the break/continue and the label. 2 - There is a lot of code duplication between diff{Break, Continue}. I thought about using a helper method, but didn't want to obfuscate the proposed fix in the process.
OK, I'll apply the fix. As for 1), I think we can live with that, since this is the typical usecase and conforms with formatter. Thanks, Sam.
Polished and integrated. Marking as FIXED. --- http://hg.netbeans.org/jet-main/rev/cd0de99b63bb
Integrated into 'main-golden', will be available in build *200906110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/cd0de99b63bb User: Max Sauer <msauer@netbeans.org> Log: #166327: NPE at o.n.m.java.source.save.CasualDiff.diffBreak
v.
The fix has been ported into the release67_fixes repository. http://hg.netbeans.org/release67_fixes/rev/fa32503210b0
Product Version: NetBeans IDE 6.7.1 RC (Build 200907150227) Java: 1.6.0_14; Java HotSpot(TM) Client VM 14.0-b16 System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb) Verified in 6.7.1 RC