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.
The following statement generates a red hint: { break; } However, the following does not: label: { break label; } nor: retry: try { throw new Exception(); } catch(Exception e) { break retry; } The compiler doesn't complain either, but Netbeans should inform that this code won't work as one might think. Ideally, a hint should exist that also detects: while(true) { label: if(true) { break label; } } But the current "break outside of switch or loop" should at least detect the former situations.
To my surprise, breaking to a non-loop/switch label is perfectly valid as per the Java Language Specification (JLS 14.15). So not showing a compile-time error is absolutely correct. Showing a warning might be reasonable (mostly because such break can be considered to be a code smell), but does not qualify as a defect, IMO.
Oh I see. It does work. It's a very limited form of goto. I don't think a warning is necessary for this (I'm not one of those goto zealots). Your call.