use of org.finos.legend.pure.runtime.java.compiled.metadata.FunctionCache in project legend-pure by finos.
the class JavaCompilerEventHandler method generateAndCompileJavaCode.
public void generateAndCompileJavaCode(SortedMap<String, ? extends RichIterable<? extends Source>> compiledSourcesByRepo) {
this.generateAndCompile.generateAndCompileJavaCodeForSources(compiledSourcesByRepo, this.getJavaSourceCodeGenerator());
this.javaGeneratedAndCompiled = true;
this.sharedFunctionCache = new FunctionCache();
this.classCache = new ClassCache(getJavaCompiler().getClassLoader());
}
use of org.finos.legend.pure.runtime.java.compiled.metadata.FunctionCache in project legend-pure by finos.
the class Test_PureTestSuite method getClassLoaderExecutionSupport.
public static CompiledExecutionSupport getClassLoaderExecutionSupport() {
MutableList<CodeRepository> codeRepos = Lists.mutable.of(CodeRepository.newPlatformCodeRepository()).withAll(CodeRepositoryProviderHelper.findCodeRepositories());
ClassLoader classLoader = Test_PureTestSuite.class.getClassLoader();
return new CompiledExecutionSupport(new JavaCompilerState(null, classLoader), new CompiledProcessorSupport(classLoader, MetadataLazy.fromClassLoader(classLoader), Sets.mutable.empty()), null, new PureCodeStorage(null, new ClassLoaderCodeStorage(classLoader, codeRepos)), null, null, new ConsoleCompiled(), new FunctionCache(), new ClassCache(classLoader), null, Sets.mutable.empty());
}
use of org.finos.legend.pure.runtime.java.compiled.metadata.FunctionCache in project legend-pure by finos.
the class TestJavaStandaloneLibraryGenerator method testStandaloneLibraryNoExternal.
@Test
public void testStandaloneLibraryNoExternal() throws Exception {
String metadataName = "test_metadata_name";
JavaStandaloneLibraryGenerator generator = JavaStandaloneLibraryGenerator.newGenerator(runtime, CompiledExtensionLoader.extensions(), false, null);
Path classesDir = this.temporaryFolder.newFolder("classes").toPath();
generator.serializeAndWriteDistributedMetadata(metadataName, classesDir);
generator.compileAndWriteClasses(classesDir);
URLClassLoader classLoader = new URLClassLoader(new URL[] { classesDir.toUri().toURL() }, Thread.currentThread().getContextClassLoader());
MetadataLazy metadataLazy = MetadataLazy.fromClassLoader(classLoader, metadataName);
CompiledExecutionSupport executionSupport = new CompiledExecutionSupport(new JavaCompilerState(null, classLoader), new CompiledProcessorSupport(classLoader, metadataLazy, null), null, runtime.getCodeStorage(), null, VoidExecutionActivityListener.VOID_EXECUTION_ACTIVITY_LISTENER, new ConsoleCompiled(), new FunctionCache(), new ClassCache(classLoader), null, null);
String className = JavaPackageAndImportBuilder.getRootPackage() + ".test_standalone_tests";
Class<?> testClass = classLoader.loadClass(className);
Method joinWithCommas = testClass.getMethod("Root_test_standalone_joinWithCommas_String_MANY__String_1_", RichIterable.class, ExecutionSupport.class);
Object result1 = joinWithCommas.invoke(null, Lists.immutable.with("a", "b", "c"), executionSupport);
Assert.assertEquals("a, b, c", result1);
Method testWithReflection = testClass.getMethod("Root_test_standalone_testWithReflection_String_1__String_1_", String.class, ExecutionSupport.class);
Object result2 = testWithReflection.invoke(null, "_*_", executionSupport);
Assert.assertEquals("_*_testWithReflection", result2);
}
use of org.finos.legend.pure.runtime.java.compiled.metadata.FunctionCache in project legend-pure by finos.
the class JavaCompilerEventHandler method invalidate.
@Override
public void invalidate(RichIterable<? extends CoreInstance> consolidatedCoreInstances) {
consolidatedCoreInstances.asLazy().selectInstancesOf(Type.class).forEach(this.classCache::remove);
this.sharedFunctionCache = new FunctionCache();
}
use of org.finos.legend.pure.runtime.java.compiled.metadata.FunctionCache in project legend-pure by finos.
the class JavaCompilerEventHandler method reset.
@Override
public void reset() {
this.javaGeneratedAndCompiled = false;
this.generateAndCompile = new GenerateAndCompile(this.message, this.observer);
this.sharedFunctionCache = new FunctionCache();
this.classCache = new ClassCache(getJavaCompiler().getClassLoader());
}
Aggregations