Bug 534694 - [1.8][inference] Eclipse compiler behaves differently from javac
Summary: [1.8][inference] Eclipse compiler behaves differently from javac
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7.3   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: 564617
  Show dependency tree
 
Reported: 2018-05-15 09:23 EDT by Philemon Schucker CLA
Modified: 2022-07-25 12:53 EDT (History)
1 user (show)

See Also:


Attachments
Examples (746 bytes, application/x-zip-compressed)
2018-05-15 09:23 EDT, Philemon Schucker CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philemon Schucker CLA 2018-05-15 09:23:02 EDT
Created attachment 274045 [details]
Examples

Found a strange behaviour where the eclipse compiler fails to compile a file, that compiles without any problems with Oracle JDK's javac. Seems to be a problem with type inference and bounded generics.

Playing around with the position of the type parameters, I was able to make eclipse compile the file. But now javac fails!

I added a minimalized example showing the problem (maybe it could be minimized more).

Example 1 compiles in Eclipse but not with javac. (Error: incompatible types: cannot infer type-variable(s) T; this.action(a.get().entrySet(), this::handleEntry);)

Example 2 compiles with javac but not with Eclipse.  (Error: The type Test does not define handleEntry(List<Test.A>, Map.Entry<String,List<capture#1-of ? extends Test.A>>) that is applicable here)

Note that the only difference between these two examples is the handleEntry function's signature.

Tested with Java 8 and 10 in Eclipse Oxygen 4.7.3a.
Comment 1 Stephan Herrmann CLA 2018-05-15 12:56:00 EDT
Thanks for the examples.

Figuring out, which compiler is right or wrong in this kind of situations can be quite a hard nut to crack. So please don't hold your breath waiting for a change.

From a quick glance it seems that ecj is able to unify the type variable T with a wildcard, but it cannot unify two distinct wildcards. At this level I can find no fault at ecj's behavior, but please take this statement with a grain of salt.
Comment 2 Eclipse Genie CLA 2022-07-25 12:53:43 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.