This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270010 - Conversion to lambda may lead to broken code
Summary: Conversion to lambda may lead to broken code
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: Dev
Hardware: PC Windows 7
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-07 15:29 UTC by arakasi
Modified: 2017-03-08 10:32 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description arakasi 2017-03-07 15:29:58 UTC
Provided hint on following piece of code:

public void processMap(Map map1, Map map2) {
  for (Object keyEntry : map1.entrySet()) {
    Map.Entry<String, Object> mapEntry = (Map.Entry<String, Object>) keyEntry;
    map2.get(mapEntry.getKey());
    // do more stuff
  }
}

do the change to functional form

public void processMap(Map map1, Map map2) {
  map1.entrySet().stream().map((keyEntry) -> (Map.Entry<String, Object>) keyEntry)
                 .forEachOrdered(( mapEntry) -> {
                   map2.get(mapEntry.getKey());
                   // do more stuff
                 });
}

which is not compilable due lost mapEntry.getKey() return type.
Issue happens only when original map1 and map2 are generic-less.