Bug 538774 - Cannot cast to Iterator<Map.Entry<?,?>>
Summary: Cannot cast to Iterator<Map.Entry<?,?>>
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.9   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-07 05:06 EDT by Christoph Langer CLA
Modified: 2022-09-01 15:25 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Langer CLA 2018-09-07 05:06:27 EDT
Consider the following code snippet:

Object o = null;
Map<?,?> m = (Map<?,?>)o;
Iterator<Map.Entry<?,?>> it = (Iterator<Map.Entry<?,?>>)m.entrySet().iterator();

This cast does fail in the Eclipse Java compiler with the error:
Cannot cast from Iterator<Map.Entry<capture#3-of ?,capture#4-of ?>> to Iterator<Map.Entry<?,?>>

You'll find this construct in "real life" in java.util.concurrent.ConcurrentSkipListMap.java of OpenJDK:

http://hg.openjdk.java.net/jdk/jdk/file/7e6b86eb7914/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java#l1716

I guess this is a bug!?

I tested with a current master build of the Eclipse platform and the problem still happens.
Comment 1 Eclipse Genie CLA 2020-09-08 01:32:48 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 2 Eclipse Genie CLA 2022-09-01 15:25:37 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.