CodeRunner has parameter Sandbox-Option
So we can run java programs with -Djava.security.manager
But it has not work for me.
But we can use SecurityManager this way
public class __Test__ {
static{
System.setSecurityManager(new SecurityManager());
} //... }
{{ STUDENT_ANSWER | replace({'public class ': 'class '}) }}
I think this code is safe enough.
Аnd it is a very weak protection disallow imports, but we cal filter any using of standart packages by twig replace function.
Hope this information will be useful for somebody.