Community
Participate
Working Groups
3m7. Foo [] foo = new Foo []{}; is such a common idiom that it deserves special treatment. Either dont treat it as an array or have a special settings for it. Also almost as commmon is Foo [] foo = new Foo[]{bar};
What is the problem with the current options?
Maybe I am being over fussy. The thing that triggered the request was having this line Object result = (foo == null)? new Object[]{} : foo.toArray(); changed to Object result = (foo == null)? new Object[] {} : foo.toArray(); To me that looked pretty wierd I want to treat the empty array init as a special case So I want this to be untouched (or forced) Foo [] foos = new Foo[] { new Foo(x), new Foo(y), } But I also want this to happen Object res = new Object[]{}; not Object res = new Object[] { }
The option FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE has been added. It is false by default to preserve existing behavior. Regression tests added. Fixed and released in HEAD.
Verified for 3.0M9