Bug 537051 - [Errors/Warnings] Redundant type arguments: Exception for anonymous types
Summary: [Errors/Warnings] Redundant type arguments: Exception for anonymous types
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-16 03:15 EDT by Marvin Fröhlich CLA
Modified: 2022-09-29 10:18 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marvin Fröhlich CLA 2018-07-16 03:15:27 EDT
In Java 9+ generic type arguments for anonymous types are finally redundant. Yes! But there should be an exception to be configured in Eclipse to ignore exactly this to avoid warnings when code needs to be compatible with Java 1.8 and 9+.

Example:
###############################
MyClass<String> c = new MyClass<String>() {};
###############################

The second <String> is necessary in Java 1.7/1.8, and redundant in 9+, which it really is.
Comment 1 Jay Arthanareeswaran CLA 2018-07-18 01:12:22 EDT
Don't we have the "Redundant type arguments ..." option for this?
Comment 2 Stephan Herrmann CLA 2018-07-19 04:11:58 EDT
(In reply to Jay Arthanareeswaran from comment #1)
> Don't we have the "Redundant type arguments ..." option for this?

I guess that Marvin doesn't want to ignore all such warnings, only those that are newly raised at 9+.

OTOH, fiddling with the special case of anonymous diamond seems like scratching at the surface. If code should really be compatible with different versions, the only reliable strategy will be to perform two builds, one at each compliance level. Ah, and then this warning should perhaps be considered only at the lower compliance level. Am I missing something?
Comment 3 Marvin Fröhlich CLA 2018-07-20 08:22:15 EDT
(In reply to Stephan Herrmann from comment #2)
> (In reply to Jay Arthanareeswaran from comment #1)
> > Don't we have the "Redundant type arguments ..." option for this?
> 
> I guess that Marvin doesn't want to ignore all such warnings, only those
> that are newly raised at 9+.

Exactly.

> OTOH, fiddling with the special case of anonymous diamond seems like
> scratching at the surface. If code should really be compatible with
> different versions, the only reliable strategy will be to perform two
> builds, one at each compliance level. Ah, and then this warning should
> perhaps be considered only at the lower compliance level. Am I missing
> something?

I agree, this might be of low priority. Still this can be of some importance.

I don't know, if it is too exotic to have a workspace, where some projects are already ported to Java 9+ and some can't (yet). In this case I have to live with some exceptions for a time.
Comment 4 Eclipse Genie CLA 2020-09-11 17:28:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2022-09-29 10:18:05 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.