Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 274049 Details for
Bug 534712
Invalid getGenericParameterTypes when using reference to an instance method of a particular object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Source file to reproduce the problem
TestBadGenerics.java (text/plain), 1.97 KB, created by
Christian Connert
on 2018-05-15 11:48:59 EDT
(
hide
)
Description:
Source file to reproduce the problem
Filename:
MIME Type:
Creator:
Christian Connert
Created:
2018-05-15 11:48:59 EDT
Size:
1.97 KB
patch
obsolete
>package at.arz.eb01a.faq.service.impl; > >import java.lang.reflect.Method; >import java.util.Arrays; >import java.util.Collection; >import java.util.List; >import java.util.Optional; >import java.util.stream.Collectors; > >@SuppressWarnings("unused") >public class TestBadGenerics { > > /* > * 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] > */ > private <T extends TestBadGenerics> List<T> getFilteredEntriesBad(final Collection<T> source) { > return source .stream() > .map(this::getFilteredEntry) > .filter(Optional::isPresent) > .map(Optional::get) > .collect(Collectors.toList()); > } > > // Using a method reference (this::getFilteredEntry) does case a NPE with eclipse oxygen 3a because of invalid generic types information in class file > /* > * 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] > */ > private <T extends TestBadGenerics> List<T> getFilteredEntriesOk(final Collection<T> source) { > return source .stream() > .map(e -> getFilteredEntry(e)) > .filter(Optional::isPresent) > .map(Optional::get) > .collect(Collectors.toList()); > } > > private <T extends TestBadGenerics> Optional<T> getFilteredEntry(final Optional<T> source) { > return getFilteredEntry(source.orElse(null)); > } > > private <T extends TestBadGenerics> Optional<T> getFilteredEntry(final T source) { > return Optional.empty(); > } > > > public static void main(String[] args) { > for(Method m : TestBadGenerics.class.getDeclaredMethods()) { > System.err.println(m); > System.err.println(Arrays.asList(m.getGenericParameterTypes())); > System.err.println(Arrays.asList(m.getParameterTypes())); > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 534712
: 274049 |
274051