Bug 519539 - [1.8][inference] Usage of generics not compiling in 4.7 while Eclipse 4.6 and javac are OK
Summary: [1.8][inference] Usage of generics not compiling in 4.7 while Eclipse 4.6 and...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug possibly regression
Keywords:
Depends on: 448793
Blocks: 564617
  Show dependency tree
 
Reported: 2017-07-12 07:01 EDT by Benoit Lacelle CLA
Modified: 2022-06-19 14:37 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benoit Lacelle CLA 2017-07-12 07:01:41 EDT
The following piece of piece does not compile in Eclipse 3.6

	protected abstract Stream<? extends Map<String, ?>> convertToStream(String storeName,
			URL url,
			Map<String, String> movedColumns) throws IOException;


@Override
	public long loadUrlWhileInTransaction(String storeName,
			URL url,
			Map<String, String> movedColumns,
			Map<String, ?> fixedColumns) throws IOException {
		convertToStream(storeName, url, movedColumns).map(m -> transcodeColumns(movedColumns, m));

		return 0L;
	}

	public static <K1, V, K2 extends K1> Map<K1, V> transcodeColumns(Map<?, ? extends K2> mapping, Map<K1, V> map) {
		// https://stackoverflow.com/questions/24630963/java-8-nullpointerexception-in-collectors-tomap
		return map.entrySet().stream().collect(HashMap::new, (m, e) -> {
			K1 newKey;
			{

				if (mapping.containsKey(e.getKey())) {
					newKey = mapping.get(e.getKey());
				} else {
					newKey = e.getKey();
				}
			}
			m.put(newKey, e.getValue());
		}, HashMap::putAll);
	}
Comment 1 Stephan Herrmann CLA 2017-07-12 11:31:59 EDT
Please clarify exact versions, versions 3.6 and 3.7 pre-date any support for Java 8 (please consult Help > About Eclipse).
Comment 2 Benoit Lacelle CLA 2017-07-12 12:53:35 EDT
(In reply to Stephan Herrmann from comment #1)
> Please clarify exact versions, versions 3.6 and 3.7 pre-date any support for
> Java 8 (please consult Help > About Eclipse).

It fails on:
Eclipse IDE for Java Developers
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800

It seems I got completely wrong in the title
Comment 3 Stephan Herrmann CLA 2017-07-12 18:33:00 EDT
Reproduced. Latest version accepting the example was 4.7M1

More specifically, we reject since the fix for bug 111208.

This indicates that the problem is triggered by some wildcard capture, which is a complex and thorny area of JLS.
At this point I'm not sure which is the correct behavior.

Will look into it after Java 9 work.
Comment 4 Stephan Herrmann CLA 2017-07-12 18:34:45 EDT
For a workaround you can change the first lambda from
   m -> transcodeColumns(movedColumns, m)
to
   (Map<String, ?> m) -> transcodeColumns(movedColumns, m)
Comment 5 Stephan Herrmann CLA 2019-05-18 17:12:31 EDT
Stepping down as I see no hope without a spec update.
Comment 6 Eclipse Genie CLA 2022-06-19 14:37:29 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.