| Summary: | add code style problem for invocation of varargs method with unnecessary "new Type[] {..}" | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | akurtakov, daniel_megert, jjohnstn |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
HEAD We could add a code style problem for an invocation of a varargs method with unnecessary "new Type[] {..}" right in the arguments list. Example: public class Try { public static void main(String[] args) { foo("x", "1", "1"); foo("x", 1); foo("x", "a", "b"); // add a problem for these two: foo("x", new String[] {"a"}); foo("x", new Object[] {"a", "b"}); } static void foo(String first, Object... o) { System.out.println(o.getClass()); } } JDT/UI can then add a quick fix to remove the unnecessary explicit array creation. The quick fix should also work in the 'new String[] {"a"}' case in the example, although there's another problem reported there.