/** * @since 2.9 */ public void setJavaCompilerClassPath(ClassLoader classLoader) { this.javaCompiler = new OnTheFlyJavaCompiler2(classLoader, generatorConfigProvider.get(null).getJavaSourceVersion()); this.classpathUriContext = classLoader; }
protected void doCompile() { if (compiledClasses == null || classLoader==null) { doGenerate(); try { Map<String, Class<?>> compilationResult = javaCompiler.compileToClasses(getGeneratedCode()); Iterator<Class<?>> values = compilationResult.values().iterator(); this.classLoader = values.hasNext() ? values.next().getClassLoader() : null; this.compiledClasses = compilationResult; } catch (IllegalArgumentException e) { throw new AssertionError(e); } } } }
/** * Sets the Java version both for the DSL generator, for example, Xbase * compiler, and for the Java compiler. * * @since 2.11 */ public void setJavaVersion(JavaVersion javaVersion) { this.javaCompiler.setJavaVersion(javaVersion); }
public Map<String, Class<?>> compileToClasses(final Map<String, String> sources) { final Function1<Map.Entry<String, String>, JavaSource> _function = (Map.Entry<String, String> it) -> { String _javaFile = this.toJavaFile(it.getKey()); String _value = it.getValue(); return new JavaSource(_javaFile, _value);
GeneratorConfigProvider configProvider = (GeneratorConfigProvider) generatorConfigProvider; GeneratorConfig config = generatorConfigProvider.get(null); config.setJavaSourceVersion(javaCompiler.getJavaVersion()); GeneratorConfig existent = configProvider.install(resourceSet, config); if (existent != null) { existent.setJavaSourceVersion(javaCompiler.getJavaVersion()); configProvider.install(resourceSet, existent);
_builder.append("}"); _builder.newLine(); final Class<?> clazz = this.compileToClass("__Generated", _builder.toString()); Object _newInstance = clazz.newInstance(); return ((Function0<RT>) _newInstance);
public Class<?> compileToClass(final String classname, final String code) { String _javaFile = this.toJavaFile(classname); JavaSource _javaSource = new JavaSource(_javaFile, code); final InMemoryJavaCompiler.Result result = this.inMemoryCompiler.compile(_javaSource);