matthiasblaesing commented on issue #7397:
URL: https://github.com/apache/netbeans/issues/7397#issuecomment-2133943592
This is reproducible standalone with the supplied file. I took that as base
and distilled it down to:
```java
import java.util.ArrayList;
public class Dummy {
private void main() {
ArrayList<ArrayList<String[]>> result = new ArrayList<>();
result.stream().map((table) -> {
table.stream().map((row) -> {
return null;
}).forEachOrdered((_item) -> System.out.println();
}).forEachOrdered((_item) -> System.out.println("---"))
);
}
}
```
The compiler rightfully complains about this:
```
Dummy.java:10: error: ')' or ',' expected
}).forEachOrdered((_item) -> System.out.println();
^
Dummy.java:11: error: ';' expected
}).forEachOrdered((_item) -> System.out.println("---"))
^
2 errors
```
But NB raises an Exception as already shown.
I used by debugging-fu and found, that the `JCMethodInvocation` instance
that for the lambda is indeed constructed with an argument list and all
arguments are non-null. So I figured, that some later stage must destroy the
tree for the argument and indeed I got a hit in
`com.sun.tools.javac.tree.TreeTranslator.translate(List<T>)`/`com.sun.tools.javac.tree.TreeTranslator.visitApply(JCMethodInvocation)`.
The transformation that is applied there is an anonymous class in
`com.sun.tools.javac.comp.AttrRecover.AttrRecover(Context)`.
This comment:
https://github.com/openjdk/jdk/blob/617edf3f0dea2b73e4b444e085de2ad282826e31/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrRecover.java#L151-L154
makes no sense from my POV as the TreeTranslator expects the translated tree
in `result`. If the translation result must not be null, the caller could be
modified to check for null and only replace the tree if the translation is
non-null (line 59 and following):
https://github.com/openjdk/jdk/blob/617edf3f0dea2b73e4b444e085de2ad282826e31/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeTranslator.java#L54-L63
Or the `AttrRecover` class needs to be adjusted to return set `result` to
the input tree if it shall not be touched.
@lahodaj would you mind having a look at this? I try to reason my way around
this, but maybe this the right analysis and you can whip up the right fix?!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists