Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 526423 - Compile error when using List<Map.Entry>
Summary: Compile error when using List<Map.Entry>
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.8 M3   Edit
Assignee: Till Brychcy CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 518157
Blocks:
  Show dependency tree
 
Reported: 2017-10-24 11:25 EDT by Thomas Watson CLA
Modified: 2017-10-26 06:26 EDT (History)
2 users (show)

See Also:


Attachments
test project (2.27 KB, application/octet-stream)
2017-10-24 11:25 EDT, Thomas Watson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Watson CLA 2017-10-24 11:25:34 EDT
Created attachment 271158 [details]
test project

The following code does not compile in the workspace with I20171023-2000 build and gives the following error:

Type mismatch: cannot convert from ArrayList<Map.Entry> to List<Map.Entry>

This code compiles fine using Oxygen.1

<java-code>
package test.compileBug;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class TestCompileBug {
    @SuppressWarnings({ "rawtypes" })
    private static void cannotCompile(Object token) {
    		// change the type to List<Entry> and ArrayList<Entry> and it compiles
    		@SuppressWarnings("unchecked")
    		List<Map.Entry> identityServicesToTokensMap = new ArrayList<Map.Entry>(((LinkedHashMap) token).entrySet());
    }
}
</java-code>
Comment 1 Andrey Loskutov CLA 2017-10-24 17:34:48 EDT
javac 1.8.0_144 and 9 compiles the snippet without errors.

If one removes suppress warnings annotation and fix the warnings, the code compiles in Eclipse too:

List<Map.Entry<?,?>> identityServicesToTokensMap = new ArrayList<Map.Entry<?,?>>(((LinkedHashMap<?,?>) token).entrySet());
Comment 2 Till Brychcy CLA 2017-10-25 01:45:41 EDT
Caused by the change for bug 518157.
Comment 3 Eclipse Genie CLA 2017-10-25 02:07:08 EDT
New Gerrit change created: https://git.eclipse.org/r/110587
Comment 4 Till Brychcy CLA 2017-10-25 02:10:15 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/110587

Contains a regression test (bug is fixed by reverting the commit for bug 518157 ).
Comment 6 Till Brychcy CLA 2017-10-25 03:28:23 EDT
(In reply to Eclipse Genie from comment #5)
> Gerrit change https://git.eclipse.org/r/110587 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=b4703cd3177b31f98429d60ab965ab16955ecd20

Released for 4.8M3
Comment 7 Andrey Loskutov CLA 2017-10-25 03:37:50 EDT
(In reply to Till Brychcy from comment #6)
> (In reply to Eclipse Genie from comment #5)
> > Gerrit change https://git.eclipse.org/r/110587 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> > ?id=b4703cd3177b31f98429d60ab965ab16955ecd20
> 
> Released for 4.8M3

Till, what about backport for 4.7.2?
Comment 8 Till Brychcy CLA 2017-10-25 08:40:54 EDT
(In reply to Andrey Loskutov from comment #7)
> (In reply to Till Brychcy from comment #6)
> > (In reply to Eclipse Genie from comment #5)
> > > Gerrit change https://git.eclipse.org/r/110587 was merged to [master].
> > > Commit:
> > > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> > > ?id=b4703cd3177b31f98429d60ab965ab16955ecd20
> > 
> > Released for 4.8M3
> 
> Till, what about backport for 4.7.2?

The code that caused the bug was not yet on the maintenance branch. 
Just backporting the test case doesn't sound useful :-)
Comment 9 Sasikanth Bharadwaj CLA 2017-10-26 06:26:31 EDT
Verified for 4.8 M3 using I20171025-2000 build