Community
Participate
Working Groups
A Xtend file with lots of else-if-statements leads to a stack overflow. (A generator in an existing project created the Xtend file with about 500 else-if-statements.) Steps to reproduce: - Create an Xtend file with a method containing, for instance, 500 "else if" statements in a text editor def void multiElseIf() { if (true) { return } else if (true) { return } else if (true) { return } // ... x500 } - open the file in the Xtend editor Expected: File opens without errors Actual: java.lang.StackOverflowError A workaround would be to use Xtend case statements. The Eclipse Java editor handles multiple else-if-statements in Java of the same quantity without errors Manual Java code: if (true) { return; } else if (true) { return;} else if (true) { return;} // ... The generated Java code from the Xtend snippet looks like this: if (true) { return; } else { if (true) { return; } else { ...
That's a guard we added to help people not generating xtend code :-)
Yes, maybe because of the nesting in the generated Java code vs. non-nesting in the handwritten Java code. Luckily, the guard is not active when we use Xtend case statements ;-)