Community
Participate
Working Groups
BETA_JAVA7 head of branch. public class X<T> { X<String> x = new X<>() { }; } The program above elicits the error message: "Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>" We could issue a better message that informs the user that his/her attempt to use <> with anonymous classes is disallowed.
This was already part of the initial implementation for the diamond construct in bug 339478 comment 2. "2. ERROR in X.java (at line 3)\n" + " X Test = new X<>(){\n" + " ^\n" + "Empty type argument list cannot be used in anonymous class declaration\n" + "----------\n"
Created attachment 195296 [details] Proposed patch + tests Patch under test. Note that prior to this patch, we were rejecting the illegal programs correctly. Now the message makes it explicit to the user that diamond cannot be used with anonymous classes.
Released in BETA_JAVA7 branch.
Verified with v20110714-1300.