@Test public void shouldResolveJavaSymbol() { TypeDescriptor a = var("a", asList("scotch.data.num.Num")); SymbolEntry entry = resolver.getEntry(symbol("scotch.data.num.(+)")).get(); assertThat(entry.getValue(), is(Optional.of(fn(a, fn(a, a))))); assertThat(entry.getOperator(), is(Optional.of(operator(LEFT_INFIX, 6)))); assertThat(entry.getValueMethod(), is(Optional.of(methodSignature("scotch/data/num/Num:add:()Lscotch/runtime/Applicable;")))); assertThat(entry.getMemberOf(), is(Optional.of((symbol("scotch.data.num.Num"))))); }
@Override public Optional<SymbolEntry> getEntry(Symbol symbol) { search(symbol); if (namedSymbols.containsKey(symbol)) { return Optional.ofNullable(namedSymbols.get(symbol)); } else { return symbol.accept(new SymbolVisitor<Optional<SymbolEntry>>() { @Override public Optional<SymbolEntry> visit(QualifiedSymbol symbol) { return reExports.qualify(symbol).flatMap(ClassLoaderResolver.this::getEntry); } @Override public Optional<SymbolEntry> visit(UnqualifiedSymbol symbol) { return Optional.empty(); } }); } }
ClassLoaderResolver extends URLClassLoader implements SymbolResolver { @Override public Optional<SymbolEntry> getEntry(Symbol symbol) { search(symbol); if (namedSymbols.containsKey(symbol)) { return Optional.ofNullable(namedSymbols.get(symbol)); } else { return symbol.accept(new SymbolVisitor<Optional<SymbolEntry>>() { @Override public Optional<SymbolEntry> visit(QualifiedSymbol symbol) { return reExports.qualify(symbol).flatMap(ClassLoaderResolver.this::getEntry); } @Override public Optional<SymbolEntry> visit(UnqualifiedSymbol symbol) { return Optional.empty(); } }); } } }
ClassLoaderResolver extends URLClassLoader implements SymbolResolver { @Override public Optional<SymbolEntry> getEntry(Symbol symbol) { search(symbol); if (namedSymbols.containsKey(symbol)) { return Optional.ofNullable(namedSymbols.get(symbol)); } else { return symbol.accept(new SymbolVisitor<Optional<SymbolEntry>>() { @Override public Optional<SymbolEntry> visit(QualifiedSymbol symbol) { return reExports.qualify(symbol).flatMap(ClassLoaderResolver.this::getEntry); } @Override public Optional<SymbolEntry> visit(UnqualifiedSymbol symbol) { return Optional.empty(); } }); } } ClassLoaderResolver(Optional<File> optionalOutputPath, ClassLoader parent);  ClassLoaderResolver(Optional<File> optionalOutputPath, URL[] urls, ClassLoader parent); }
ClassLoaderResolver extends URLClassLoader implements SymbolResolver { @Override public Optional<SymbolEntry> getEntry(Symbol symbol) { search(symbol); if (namedSymbols.containsKey(symbol)) { return Optional.ofNullable(namedSymbols.get(symbol)); } else { return symbol.accept(new SymbolVisitor<Optional<SymbolEntry>>() { @Override public Optional<SymbolEntry> visit(QualifiedSymbol symbol) { return reExports.qualify(symbol).flatMap(ClassLoaderResolver.this::getEntry); } @Override public Optional<SymbolEntry> visit(UnqualifiedSymbol symbol) { return Optional.empty(); } }); } } ClassLoaderResolver(Optional<File> optionalOutputPath, ClassLoader parent);  ClassLoaderResolver(Optional<File> optionalOutputPath, URL[] urls, ClassLoader parent); static ClassLoaderResolver resolver(Optional<File> optionalOutputPath); Class<?> define(GeneratedClass generatedClass); List<Class<?>> defineAll(List<GeneratedClass> generatedClasses); @Override Optional<SymbolEntry> getEntry(Symbol symbol); @Override Set<TypeInstanceDescriptor> getTypeInstances(Symbol symbol, List<TypeDescriptor> types); @Override Set<TypeInstanceDescriptor> getTypeInstancesByModule(String moduleName); }
ClassLoaderResolver extends URLClassLoader implements SymbolResolver { @Override public Optional<SymbolEntry> getEntry(Symbol symbol) { search(symbol); if (namedSymbols.containsKey(symbol)) { return Optional.ofNullable(namedSymbols.get(symbol)); } else { return symbol.accept(new SymbolVisitor<Optional<SymbolEntry>>() { @Override public Optional<SymbolEntry> visit(QualifiedSymbol symbol) { return reExports.qualify(symbol).flatMap(ClassLoaderResolver.this::getEntry); } @Override public Optional<SymbolEntry> visit(UnqualifiedSymbol symbol) { return Optional.empty(); } }); } } ClassLoaderResolver(Optional<File> optionalOutputPath, ClassLoader parent);  ClassLoaderResolver(Optional<File> optionalOutputPath, URL[] urls, ClassLoader parent); static ClassLoaderResolver resolver(Optional<File> optionalOutputPath); Class<?> define(GeneratedClass generatedClass); List<Class<?>> defineAll(List<GeneratedClass> generatedClasses); @Override Optional<SymbolEntry> getEntry(Symbol symbol); @Override Set<TypeInstanceDescriptor> getTypeInstances(Symbol symbol, List<TypeDescriptor> types); @Override Set<TypeInstanceDescriptor> getTypeInstancesByModule(String moduleName);  }