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

Summary: Conversion to lambda may lead to broken code
Product: java Reporter: arakasi
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P4    
Version: Dev   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

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.