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.
While there are a number of interesting Java hints, I have found that what I most want and need are hints (and fixes) for converting formerly -source 1.4 code to idiomatic -source 5 code. In practice I spend a lot of doing menial conversions of old source code, and the IDE offers little or no help. I am making a list in order from easy to hard, but probably this should be considered a source of ideas to be filed separately (or marked duplicate): 1. [WARNING] Simplify code using autoboxing wherever possible, e.g. 1a. new Integer($x) -> $x 1b. Integer.valueOf($x) -> $x 1c. $x.intValue() -> $x 2. [WARNING] Use vararg calls wherever possible, e.g. $class.getMethod($name, new Object[] {$type1, $type2}) -> $class.getMethod($name, $type1, $type2); or Arrays.asList(new Whatever[] {$x1, $x2}) -> Arrays.asList($x1, $x2). Tricky when Object... formal arguments are involved, because the ambiguity between a vararg and non-vararg call (for a value of type Object[] or null) sometimes necessitates a clarifying cast. 3. [CURRENT_LINE_WARNING?] Offer to use a static import on a static method/field (replacing other usages of that method/field or its containing class as well). 4. [WARNING] If the class implements an interface containing only fields, cease to implement it and statically import it instead. 5. [CURRENT_LINE_WARNING] For a method whose final argument is an array type, offer to make it use varargs. Since this would best involve changing callers as well (#2), perhaps it should rather be a Refactoring menu item? I am not clear on how you decide in general what is presented as a hint with fix and what is presented as a refactoring action. 6. [WARNING] Replace use of Iterator with an enhanced for-loop, assuming that the iterator is run to completion (using 'for' or 'while' with exactly one call to .next() per iteration and excepting break/continue statements and exceptions) and that .remove() is not called. Usually needs to infer the right type for the elements, too (#8). Reuse a variable name for the element if there is already a 'SomeType $var = it.next();' statement, else introduce a variable for this purpose if .next() is called in the middle of a complex expression. 7. [CURRENT_LINE_WARNING] Replace a list of public static final int constants with an enum. Not clear if it is possible to detect this pattern reliably enough to be useful, since you need to know about their usages (which might extend into other compilation units). 8. [WARNING] Use of raw types. (This is actually now a standard lint warning in JDK 7 javac - see issue #126437.) Fixing this mechanically could be very difficult in general, but offering fixes for some common cases could be a big help: a List which is observed to only have objects assignable to some type placed in it can be given a type parameter, for example, and .get() calls etc. can have casts removed.
IDEA seems to do at least #1, #2, #3, and #8.