Created
July 3, 2014 14:40
-
-
Save purplefox/244a13bb00b8d92eb3b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo; | |
import org.mvel2.templates.TemplateRuntime; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class CompilerBug { | |
public static void main(String[] args) { | |
String templ = | |
"@declare{'someTempl'}\n" + | |
" @if{obj.foo}x@end{}\n" + | |
"@end{}\n" + | |
"@foreach{obj : objs}\n" + | |
"@includeNamed{'someTempl'}\n" + | |
"@end{}\n" + | |
"@foreach{obj : objs}\n" + | |
"@includeNamed{'someTempl'}\n" + | |
"@end{}"; | |
ArrayList<MyObj> objs = new ArrayList<>(); | |
for (int i = 0; i < 30; i++) { | |
objs.add(new MyObj()); | |
} | |
Map<String, Object> vars = new HashMap<>(); | |
vars.put("objs", objs); | |
TemplateRuntime.eval(templ, vars); | |
} | |
public static class MyObj { | |
public boolean isFoo() { | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment