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 Fix introduced in bug 158042 treats String literals and String variables the same way. This can generate some unnecessary code: // Original code if (str == "") { } // With current ternary Fix applied if (str == null ? "" == null : str.equals("")) { } // With current non-ternary Fix applied if ((str == null && "" == null) || (str != null && str.equals(""))) { } Comparing a String literal to null will always return false, so some of the generated code above is unnecessary. The following is what should be generated: // With proposed Fix 1 applied if (str != null && str.equals("")) { } To accommodate different coding styles, an option could be introduced into the Fix to allow it to generate the following code instead: // With proposed Fix 2 applied if ("".equals(str)) { } I am willing to implement these changes, add new test cases, and attach a patch here.
I have begun work on a patch which I will attach here.
Created attachment 94702 [details] patch I've attached a patch which implements the suggested behavior. The patch includes test cases.
Reassigning to component default assignee. Please review the attached patch.
Reassigning to original default assignee. Please review the attached patch.
Can someone please review the attached patch? It's been sitting around for almost 8 months now.
Sorry, it slipped off my radar. I have applied the patch in my local repository, will be public on my next push (c4318e5f6fe6). Thanks for the patch.
(In reply to comment #6) > Sorry, it slipped off my radar. I have applied the patch in my local > repository, will be public on my next push (c4318e5f6fe6). Thanks for the > patch. No worries. I wasn't upset; I just wanted to make a blip on someone's radar. :) Thanks, and you're welcome!
This is definitely resolved in 7.0.