use of platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.SourceFile in project L42 by ElvisResearchGroup.
the class CompilationInMemoryTest method test1.
@Test
public void test1() throws Throwable {
SourceFile file = new SourceFile("math.Calculator", "package math;" + "public class Calculator { " + " public void testAdd() { " + " System.out.println(200+300); " + " }" + " public static void main(String[] args) { " + " Calculator cal = new Calculator(); " + " cal.testAdd(); " + " } " + "} ");
List<SourceFile> files = Arrays.asList(file);
ClassLoader classes = InMemoryJavaCompiler.compile(ClassLoader.getSystemClassLoader(), files);
RunningUtils.runMain(classes, "math.Calculator");
RunningUtils.runMainStrictSecurity(classes, "math.Calculator", 1000);
}
use of platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.SourceFile in project L42 by ElvisResearchGroup.
the class CompilationInMemoryTest method testExt.
@Test
public void testExt() throws Throwable {
SourceFile file = new SourceFile("math.Calculator", "package math;" + "public class Calculator { " + " public static void main(String[] args) { " + TestClass.class.getCanonicalName() + " cal = new " + TestClass.class.getCanonicalName() + "(); " + " cal.testMeth(); " + " } " + "} ");
List<SourceFile> files = Arrays.asList(file);
ClassLoader classes = InMemoryJavaCompiler.compile(ClassLoader.getSystemClassLoader(), files);
RunningUtils.runMain(classes, "math.Calculator");
RunningUtils.runMainStrictSecurity(classes, "math.Calculator", 1000);
}
use of platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.SourceFile in project L42 by ElvisResearchGroup.
the class CompilationInMemoryTest method test2bis.
@Test
public void test2bis() throws Throwable {
SourceFile file = new SourceFile("math.Calculator", "package math;" + "public class Calculator { " + " public static void main(String[] args) { " + " Calculator2 cal = new Calculator2(); " + " cal.testAdd(); " + " } " + "} " + "class Calculator2 { " + " public void testAdd() { " + " System.out.println(200+300); " + " }} ");
List<SourceFile> files = Arrays.asList(file);
ClassLoader classes = InMemoryJavaCompiler.compile(ClassLoader.getSystemClassLoader(), files);
RunningUtils.runMain(classes, "math.Calculator");
RunningUtils.runMainStrictSecurity(classes, "math.Calculator", 1000);
}
use of platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.SourceFile in project L42 by ElvisResearchGroup.
the class CompilationInMemoryTest method test2Files.
@Test
public void test2Files() throws Throwable {
SourceFile[] file = { new SourceFile("math.Calculator", "package math;" + "class Calculator2 { " + " public void testAdd() { " + " System.out.println(200+300); " + " }} "), new SourceFile("math.Calculator", "package math;" + "public class Calculator { " + " public static void main(String[] args) { " + " Calculator2 cal = new Calculator2(); " + " cal.testAdd(); " + " } " + "} ") };
List<SourceFile> files = Arrays.asList(file);
ClassLoader classes = InMemoryJavaCompiler.compile(ClassLoader.getSystemClassLoader(), files);
RunningUtils.runMain(classes, "math.Calculator");
RunningUtils.runMainStrictSecurity(classes, "math.Calculator", 1000);
}
Aggregations