Skip to content

Instantly share code, notes, and snippets.

@purplefox
Created July 3, 2014 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purplefox/244a13bb00b8d92eb3b7 to your computer and use it in GitHub Desktop.
Save purplefox/244a13bb00b8d92eb3b7 to your computer and use it in GitHub Desktop.
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