Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352453 - [1.7] In 1.6 project, use of <> in anonymous classes is giving an unexpected error message
Summary: [1.7] In 1.6 project, use of <> in anonymous classes is giving an unexpected ...
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 09:14 EDT by Satyam Kandula CLA
Modified: 2011-07-19 10:56 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Satyam Kandula CLA 2011-07-19 09:14:01 EDT
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.
Comment 1 Ayushman Jain CLA 2011-07-19 09:41:17 EDT
(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? :)
Comment 2 Srikanth Sankaran CLA 2011-07-19 09:44:46 EDT
(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.
Comment 3 Satyam Kandula CLA 2011-07-19 10:29:30 EDT
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.
Comment 4 Ayushman Jain CLA 2011-07-19 10:35:04 EDT
(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.
Comment 5 Ayushman Jain CLA 2011-07-19 10:40:08 EDT
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.
Comment 6 Satyam Kandula CLA 2011-07-19 10:56:27 EDT
I am fine with this.