Bug 496869 - [1.8] Compiler cannot infer types when mixing generic and raw types
Summary: [1.8] Compiler cannot infer types when mixing generic and raw types
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-27 14:32 EDT by Rostyslav Smirnov CLA
Modified: 2024-01-24 16:44 EST (History)
1 user (show)

See Also:


Attachments
Test (827 bytes, text/x-java)
2016-06-27 14:32 EDT, Rostyslav Smirnov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rostyslav Smirnov CLA 2016-06-27 14:32:02 EDT
Created attachment 262732 [details]
Test

Code that is using both generic and raw types fails to compile with Eclipse 4.6 Neon, but compiles with Oracle Java compiler and Eclipse 4.5 Mars.

Test cases attached.

Raw types can come from third party library, one shouldn't have to abandon generics to use them.
Comment 1 Stephan Herrmann CLA 2016-06-28 07:41:50 EDT
The example is rejected since the fix for Bug 473657.

I'm quite certain that this change is correct.


When comparing the compiler against javac, the first thing that comes to my mind is: javac is known to have a fundamental flaw in handling raw types during type inference: https://bugs.openjdk.java.net/browse/JDK-8026527
JDT has invested significant efforts in emulating that javac bug, but due to lack of precise description of the extent of that bug, it is impossible to 100% accurately reproduce javac's behavior in this regard.


Until proven wrong (by rigorous argumentation based on JLS), I'll claim that ecj is correct in this regard. I may be wrong, but I personally will not invest my spare time in further investigation. Anybody?


PS: We all know JLS 4.8: "The use of raw types is allowed only as a concession to compatibility of legacy code. The use of raw types in code written after the introduction of generics into the Java programming language is strongly discouraged. It is possible that future versions of the Java programming language will disallow the use of raw types."
In that light I'd also wonder about the vitality of a library that hasn't adjusted to the introduction of generics more than a decade ago - but that's only one piece in the puzzle. I personally see more good in improving support for Java 8 code, rather than 1.4.
Comment 2 Eclipse Genie CLA 2022-02-02 15:01:00 EST
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 3 Eclipse Genie CLA 2024-01-24 16:44:55 EST
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.