Closed frankvdh closed 1 week ago
lets use a more reasonable issue title
This is reproducible standalone with the supplied file. I took that as base and distilled it down to:
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:
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):
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?!
@matthiasblaesing, uh. You are right, of course. Thanks for diagnosing it so deeply. I've filled: https://bugs.openjdk.org/browse/JDK-8333107
@lahodaj thank you! As the fix made it already into 23, I assume next nb-javac update should fix this issue.
should be fixed via https://github.com/apache/netbeans/pull/7484
Apache NetBeans version
Apache NetBeans 21
What happened
I received this notification...
MultipleTablesTest_92.zip
Language / Project Type / NetBeans Component
No response
How to reproduce
Occurs when I try to build or rebuild my project. Reloading Netbeans doesn't help.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Win11
JDK
jdk21
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
No response
Are you willing to submit a pull request?
No