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 new "initializer can be static" hint in 8.0 incorrectly identifies flags instance initializers in anonymous classes, and the resulting fix breaks the code. For example, public static final java.util.Map<Character, String> LOOKUP = java.util.Collections.unmodifiableMap( new java.util.HashMap<Character, String>(){ { put('A', "A is for Apple"); put('B', "B is for Bannana"); put('C', "C is for Coconut"); } }); the hint is displayed. When performing the "fix" by clicking on the hint in the gutter ("make initializer static"), it changes the code to public static final java.util.Map<Character, String> LOOKUP = java.util.Collections.unmodifiableMap( new java.util.HashMap<Character, String>(){ static { put('A', "A is for Apple"); put('B', "B is for Bannana"); put('C', "C is for Coconut"); } }); which obviously won't compile since put(K, V) is an instance method on java.util.Map. The easiest fix would be to suppress this hint in anonymous classes. Alternately, it could use the "[context] Refactor->Convert Anonymous to Member" logic to create a (potentially static) inner class with the initializer as part of the constructor. Product Version = NetBeans IDE 8.0 (Build 201403101706) Operating System = Mac OS X version 10.8.5 running on x86_64 Java; VM; Vendor = 1.7.0_51 Runtime = Java HotSpot(TM) 64-Bit Server VM 24.51-b03
The issue is still there and it is being annoying, please fix this, I request this to be P2 as the fix itself seems trivial to me.
Fix should be present in 8.0.1 *** This bug has been marked as a duplicate of bug 241344 ***