/** * Ensures compilation has happened and returns the class loader including compiled classes. * * @return the class loader after the compilation happend */ public ClassLoader getClassLoader() { doCompile(); return classLoader; }
@SuppressWarnings("unchecked") public <RT> Functions.Function0<RT> createFunction(String expression, Class<RT> returnType) { return (Function0<RT>) internalCreateFunction(expression, returnType); }
@Override protected void after() { if (folder != null) { delete(); folder = null; initialized = false; } }
/** * @return all generated resources. the key is the file path and the value denotes the generated text. */ public Map<String, CharSequence> getAllGeneratedResources() { doGenerate(); Map<String,CharSequence> result = newHashMap(); for (GeneratedFile f: access.getGeneratedFiles()) { result.put(f.getPath(), f.getContents()); } return result; }
/** * @since 2.11 */ public long setJavaVersion(final JavaVersion javaVersion) { long _xblockexpression = (long) 0; { final long classFmt = this.toClassFmt(javaVersion); this.setSourceLevel(classFmt); this.setComplianceLevel(classFmt); _xblockexpression = this.compilerOptions.targetJDK = classFmt; } return _xblockexpression; }
public void initializeClassPath() { clearClassPath(); classPathAssembler.assembleCompilerClassPath(this); }
public InMemoryJavaCompiler(final ClassLoader parent, final JavaVersion javaVersion) { InMemoryJavaCompiler.ClassLoaderBasedNameEnvironment _classLoaderBasedNameEnvironment = new InMemoryJavaCompiler.ClassLoaderBasedNameEnvironment(parent); this.nameEnv = _classLoaderBasedNameEnvironment; this.parentClassLoader = parent; CompilerOptions _compilerOptions = new CompilerOptions(); this.compilerOptions = _compilerOptions; this.setJavaVersion(javaVersion); this.compilerOptions.inlineJsrBytecode = true; this.compilerOptions.preserveAllLocalVariables = true; }
/** * Delete all files and folders under the temporary folder. * Usually not called directly, since it is automatically applied * by the {@link Rule} */ public void delete() { recursiveDelete(folder); }
/** * @since 2.11 */ public void setJavaVersion(final JavaVersion version) { this.inMemoryCompiler.setJavaVersion(version); this.javaVersion = version; }
/** * 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); }
/** * creates a fresh temp directory and sets it as the workspace root. */ public void configureFreshWorkspace() { workspaceRoot = createFreshTempDir(); }
/** * Ensures validation has happened and returns any errors and warnings * * @return errors and warnings contained in the currently processed sources */ public List<Issue> getErrorsAndWarnings() { doValidation(); return allErrorsAndWarnings; }
/** * Ensures generation happened and returns a map of the generated Java source files. * * @return a map of the generated Java source files, where the key is the qualified class name and the value the generated Java code. */ public Map<String,String> getGeneratedCode() { doGenerate(); return generatedCode; }
/** * @since 2.9 */ public void setJavaCompilerClassPath(ClassLoader classPath) { compilationTestHelper.setJavaCompilerClassPath(classPath); }
public OnTheFlyJavaCompiler2(final ClassLoader scope, final JavaVersion version) { InMemoryJavaCompiler _inMemoryJavaCompiler = new InMemoryJavaCompiler(scope, version); this.inMemoryCompiler = _inMemoryJavaCompiler; this.javaVersion = version; }
public ClassLoader getClassLoader() { return new InMemoryJavaCompiler.ByteClassLoader(this.classMap, this.parentClassLoader); }
protected File createFreshTempDir() { try { return temporaryFolder.newFolder(); } catch (IOException e) { throw new AssertionError(e); } }
/** * Convenience method for single generated Java classes */ public Class<?> getCompiledClass(String className) { return getCompiledClasses().get(className); }
/** * Ensures compilation has happened and returns any generated and compiled Java classes. * * @return the compiled Java classes */ public Map<String,Class<?>> getCompiledClasses() { doCompile(); return compiledClasses; }