| Summary: | Invalid getGenericParameterTypes when using reference to an instance method of a particular object | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Christian Connert <christian.connert> | ||||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||||
| Status: | CLOSED DUPLICATE | QA Contact: | |||||||
| Severity: | critical | ||||||||
| Priority: | P3 | CC: | register.eclipse, stephan.herrmann | ||||||
| Version: | 4.7.3 | ||||||||
| Target Milestone: | 4.8 M7 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 274051 [details]
Problematic class file
Perhaps the two lambdas got swapped on the way? This is what javap tells me about the attached class file:
private java.util.Optional<T> lambda$6(T);
descriptor: (Lat/arz/eb01a/faq/service/impl/TestBadGenerics;)Ljava/util/Optional;
flags: ACC_PRIVATE, ACC_SYNTHETIC
Signature: #130 // (TT;)Ljava/util/Optional<TT;>;
...
private java.util.Optional lambda$3(at.arz.eb01a.faq.service.impl.TestBadGenerics);
descriptor: (Lat/arz/eb01a/faq/service/impl/TestBadGenerics;)Ljava/util/Optional;
flags: ACC_PRIVATE, ACC_SYNTHETIC
...
So, lambda$6 seems to have a correct signature, whereas lambda$3 does not.
Moreover, starting with 4.8M6 ecj generates only one lambda. Not sure if this is good or bad.
Anyway, when compiled with ecj 4.8M6 or greater, this is the output from running the program:
--------
private java.util.Optional TestBadGenerics.lambda$3(TestBadGenerics)
[class TestBadGenerics]
[class TestBadGenerics]
private java.util.List TestBadGenerics.getFilteredEntriesBad(java.util.Collection)
[java.util.Collection<T>]
[interface java.util.Collection]
private java.util.Optional TestBadGenerics.getFilteredEntry(java.util.Optional)
[java.util.Optional<T>]
[class java.util.Optional]
private java.util.Optional TestBadGenerics.getFilteredEntry(TestBadGenerics)
[T]
[class TestBadGenerics]
private java.util.List TestBadGenerics.getFilteredEntriesOk(java.util.Collection)
[java.util.Collection<T>]
[interface java.util.Collection]
public static void TestBadGenerics.main(java.lang.String[])
[class [Ljava.lang.String;]
[class [Ljava.lang.String;]
--------
Is that what you expected?
This sounds very similar to bug 531093 (In reply to Till Brychcy from comment #3) > This sounds very similar to bug 531093 So, bug 531093 comment 8 matches to the fact that things look better already at M6. Let's call it a duplicate then, Christian may still re-open (with more info) if he can reproduce the problem in M7 or later. *** This bug has been marked as a duplicate of bug 531093 *** |
Created attachment 274049 [details] Source file to reproduce the problem Hi, imho. the eclipse java compiler does write invalid getGenericParameterTypes into the class file when using reference to an instance method of a particular object as a "lambda" (in my case map expression). I attached a minimal example (sources and class file) to reproduce the problem. The example has two relevant methods getFilteredEntriesBad and getFilteredEntriesOk. In the getFilteredEntriesBad method I used a reference to an instance method of this object to call a map function on a stream. Unfortunately the resulting lambda method has no valid genericParameterTypes: private java.util.Optional at.arz.eb01a.faq.service.impl.TestBadGenerics.lambda$6(at.arz.eb01a.faq.service.impl.TestBadGenerics) [null] [class at.arz.eb01a.faq.service.impl.TestBadGenerics] In contrast the getFilteredEntriesOk uses a real lambda expression inside the map step: private java.util.Optional at.arz.eb01a.faq.service.impl.TestBadGenerics.lambda$3(at.arz.eb01a.faq.service.impl.TestBadGenerics) [class at.arz.eb01a.faq.service.impl.TestBadGenerics] [class at.arz.eb01a.faq.service.impl.TestBadGenerics] Pleas do not hesitate to get in touch with me if you require more information.