| Summary: | [1.7] In 1.6 project, use of <> in anonymous classes is giving an unexpected error message | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Satyam Kandula <satyam.kandula> |
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> |
| Status: | VERIFIED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | amj87.iitr |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
(In reply to comment #0) > Without the patched version, the message was "The type new X(){} cannot extend > or implement X<?>. A supertype may not specify any wildcard". IMO, this message > is better. I'm not too sure I agree with this message being better. X<> has no business to be interpreted as X<?>. "..A supertype may not specify any wildcard" - where is the wildcard? :) (In reply to comment #0) > Found in BETA_JAVA7 branch for a 1.6 project. > Without the patched version, the message was "The type new X(){} cannot extend > or implement X<?>. A supertype may not specify any wildcard". IMO, this message > is better. (My message collided with Ayush's message, reposting) Satyam, this message is based on suspect recovery. See that there is no ? at all in the source program and we are complaining about it and this can actually seriously leave a user scratching his/her head. (what supertype is specifying wildcard ???) See also bug 349054, in particular https://bugs.eclipse.org/bugs/show_bug.cgi?id=349054#c2 which shows the effects of broken recovery. OK, I agree that the previous message is not good, but do you think the present message is correct in a 1.6 project context. (In reply to comment #3) > OK, I agree that the previous message is not good, but do you think the present > message is correct in a 1.6 project context. Yup. This is very much intentional and also consistent with what javac says. See bug 348493. javac 7b147 with -source 1.5 says:
"error: diamond operator is not s
upported in -source 1.5
new X<>("abc") {};
^
(use -source 7 or higher to enable diamond operator)
1 error
1 warning"
Hence closing as invalid.
I am fine with this. |
Found in BETA_JAVA7 branch for a 1.6 project. Type the following program in the package explorer in 1.6 project. public class X<T> { public void foo() { new X<>("abc") {}; } } The following errors are reported: - '<>' operator is not allowed for source level below 1.7 - '<>' cannot be used with anonymous classes Without the patched version, the message was "The type new X(){} cannot extend or implement X<?>. A supertype may not specify any wildcard". IMO, this message is better.