Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jarek/7015: overwrite java classes #7125

Merged
merged 4 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#7015: rename Beakerx => Beaker
  • Loading branch information
jaroslawmalekcodete committed Apr 6, 2018
commit c5f2de590371d1cfee7f3e26c948a1d31768fe3e
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

import static com.google.common.base.Preconditions.checkNotNull;

public class BeakerxUrlClassLoader extends URLClassLoader {
public class BeakerUrlClassLoader extends URLClassLoader {

public BeakerxUrlClassLoader(URL[] urls, ClassLoader parent) {
public BeakerUrlClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}

public BeakerxUrlClassLoader(ClassLoader parent) {
public BeakerUrlClassLoader(ClassLoader parent) {
this(new URL[0], parent);
}

public BeakerxUrlClassLoader() {
public BeakerUrlClassLoader() {
this(ClassLoader.getSystemClassLoader());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DynamicClassLoaderSimple extends ClassLoader {

private final static Logger logger = LoggerFactory.getLogger(DynamicClassLoaderSimple.class.getName());

private BeakerxUrlClassLoader myloader = new BeakerxUrlClassLoader(new URL[0], null);
private BeakerUrlClassLoader myloader = new BeakerUrlClassLoader(new URL[0], null);
private String outDir;
protected final Map<String, Class<?>> classes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.twosigma.beakerx.TryResult;
import com.twosigma.beakerx.autocomplete.AutocompleteResult;
import com.twosigma.beakerx.inspect.InspectResult;
import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.jvm.object.SimpleEvaluationObject;
import com.twosigma.beakerx.jvm.threads.CellExecutor;
import com.twosigma.beakerx.kernel.CacheFolderFactory;
Expand Down Expand Up @@ -48,7 +48,7 @@ public class EvaluatorTest extends BaseEvaluator {
private Classpath classpath = new Classpath();
private Imports imports = new Imports(new ArrayList<>());
private int resetEnvironmentCounter = 0;
private BeakerxUrlClassLoader loader = new BeakerxUrlClassLoader(Thread.currentThread().getContextClassLoader());
private BeakerUrlClassLoader loader = new BeakerUrlClassLoader(Thread.currentThread().getContextClassLoader());

public EvaluatorTest() {
this("idEvaluatorTest", "sIdEvaluatorTest", TestBeakerCellExecutor.cellExecutor(), KERNEL_PARAMETERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.twosigma.beakerx.kernel;

import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -26,12 +26,12 @@
public class ImportsTest {

private Imports imports;
private BeakerxUrlClassLoader urlClassLoader;
private BeakerUrlClassLoader urlClassLoader;

@Before
public void setUp() throws Exception {
imports = new Imports(new ArrayList<>());
urlClassLoader = new BeakerxUrlClassLoader();
urlClassLoader = new BeakerUrlClassLoader();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.twosigma.beakerx.groovy.evaluator;

import com.google.common.base.Joiner;
import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.kernel.Classpath;
import com.twosigma.beakerx.kernel.ImportPath;
import com.twosigma.beakerx.kernel.Imports;
Expand Down Expand Up @@ -93,8 +93,8 @@ public static void addImportPathToImportCustomizer(ImportCustomizer icz, ImportP
}
}

public static BeakerxUrlClassLoader newParentClassLoader(Classpath classpath) {
BeakerxUrlClassLoader loader = new BeakerxUrlClassLoader(ClassLoader.getSystemClassLoader());
public static BeakerUrlClassLoader newParentClassLoader(Classpath classpath) {
BeakerUrlClassLoader loader = new BeakerUrlClassLoader(ClassLoader.getSystemClassLoader());
loader.addPathToJars(classpath.getPaths());
return loader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import com.twosigma.beakerx.evaluator.TempFolderFactoryImpl;
import com.twosigma.beakerx.groovy.autocomplete.GroovyAutocomplete;
import com.twosigma.beakerx.groovy.autocomplete.GroovyClasspathScanner;
import com.twosigma.beakerx.inspect.Inspect;
import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.jvm.object.SimpleEvaluationObject;
import com.twosigma.beakerx.jvm.threads.BeakerCellExecutor;
import com.twosigma.beakerx.jvm.threads.CellExecutor;
Expand Down Expand Up @@ -54,7 +53,7 @@ public class GroovyEvaluator extends BaseEvaluator {
private GroovyClassLoader groovyClassLoader;
private Binding scriptBinding = null;
private ImportCustomizer icz;
private BeakerxUrlClassLoader beakerxUrlClassLoader;
private BeakerUrlClassLoader beakerxUrlClassLoader;

public GroovyEvaluator(String id, String sId, EvaluatorParameters evaluatorParameters) {
this(id, sId, new BeakerCellExecutor("groovy"), new TempFolderFactoryImpl(), evaluatorParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.twosigma.beakerx.javash;

import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.kernel.PathToJar;

import java.net.URL;
Expand All @@ -25,14 +25,14 @@

import static java.util.Collections.singletonList;

public class JavaBeakerxUrlClassLoader extends URLClassLoader {
public class JavaBeakerUrlClassLoader extends URLClassLoader {

private BeakerxUrlClassLoader beakerxUrlClassLoader;
private BeakerUrlClassLoader beakerxUrlClassLoader;
private JavaInternalUrlClassLoader javaURLClassLoader;

public JavaBeakerxUrlClassLoader(ClassLoader systemClassLoader, PathToJar pathToJar) {
public JavaBeakerUrlClassLoader(ClassLoader systemClassLoader, PathToJar pathToJar) {
super(new URL[0]);
beakerxUrlClassLoader = new BeakerxUrlClassLoader(this.getURLs(), systemClassLoader);
beakerxUrlClassLoader = new BeakerUrlClassLoader(this.getURLs(), systemClassLoader);
javaURLClassLoader = new JavaInternalUrlClassLoader(beakerxUrlClassLoader, new URL[0]);
javaURLClassLoader.addJar(pathToJar);
}
Expand Down Expand Up @@ -72,13 +72,13 @@ public JavaInternalUrlClassLoader getJavaURLClassLoader() {
return javaURLClassLoader;
}

static class JavaInternalUrlClassLoader extends BeakerxUrlClassLoader {
static class JavaInternalUrlClassLoader extends BeakerUrlClassLoader {

private static final List<String> excludedClasses = singletonList("slf4j");

private BeakerxUrlClassLoader external;
private BeakerUrlClassLoader external;

public JavaInternalUrlClassLoader(BeakerxUrlClassLoader external, URL[] urls) {
public JavaInternalUrlClassLoader(BeakerUrlClassLoader external, URL[] urls) {
super(urls, null);
this.external = external;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
package com.twosigma.beakerx.javash.autocomplete;

import com.twosigma.beakerx.autocomplete.ClassUtils;
import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;

import java.util.List;
import java.util.Optional;

public class JavaClassUtils extends ClassUtils {

private JavaClasspathScanner classpathscanner;
private BeakerxUrlClassLoader classLoader;
private BeakerUrlClassLoader classLoader;

public JavaClassUtils(JavaClasspathScanner cps, ClassLoader l) {
super(l);
Expand All @@ -44,7 +44,7 @@ protected Class<?> getClass(String name) throws ClassNotFoundException {
if (fname != null) {
try {
if (classLoader == null)
classLoader = new BeakerxUrlClassLoader(loader != null ? loader : getClass().getClassLoader());
classLoader = new BeakerUrlClassLoader(loader != null ? loader : getClass().getClassLoader());
Class<?> clazz = classLoader.parseClass(fname);
return clazz;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.twosigma.beakerx.evaluator.JobDescriptor;
import com.twosigma.beakerx.evaluator.TempFolderFactory;
import com.twosigma.beakerx.evaluator.TempFolderFactoryImpl;
import com.twosigma.beakerx.javash.JavaBeakerxUrlClassLoader;
import com.twosigma.beakerx.javash.JavaBeakerUrlClassLoader;
import com.twosigma.beakerx.javash.autocomplete.JavaAutocomplete;
import com.twosigma.beakerx.javash.autocomplete.JavaClasspathScanner;
import com.twosigma.beakerx.jvm.object.SimpleEvaluationObject;
Expand All @@ -42,7 +42,7 @@ public class JavaEvaluator extends BaseEvaluator {
private final String packageId;
private JavaClasspathScanner cps;
private JavaAutocomplete jac;
private JavaBeakerxUrlClassLoader loader = null;
private JavaBeakerUrlClassLoader loader = null;

public JavaEvaluator(String id, String sId, EvaluatorParameters evaluatorParameters) {
this(id, sId, new BeakerCellExecutor("javash"), new TempFolderFactoryImpl(), evaluatorParameters);
Expand Down Expand Up @@ -130,13 +130,13 @@ public String getPackageId() {
return packageId;
}

private JavaBeakerxUrlClassLoader newClassLoader() {
JavaBeakerxUrlClassLoader loader = new JavaBeakerxUrlClassLoader(ClassLoader.getSystemClassLoader(),new PathToJar(outDir));
private JavaBeakerUrlClassLoader newClassLoader() {
JavaBeakerUrlClassLoader loader = new JavaBeakerUrlClassLoader(ClassLoader.getSystemClassLoader(),new PathToJar(outDir));
loader.addInitPathToJars(getClasspath().getPaths());
return loader;
}

public JavaBeakerxUrlClassLoader getJavaClassLoader() {
public JavaBeakerUrlClassLoader getJavaClassLoader() {
return loader;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.twosigma.beakerx.evaluator.JobDescriptor;
import com.twosigma.beakerx.evaluator.TempFolderFactory;
import com.twosigma.beakerx.evaluator.TempFolderFactoryImpl;
import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.jvm.object.SimpleEvaluationObject;
import com.twosigma.beakerx.jvm.threads.BeakerCellExecutor;
import com.twosigma.beakerx.jvm.threads.CellExecutor;
Expand All @@ -49,7 +49,7 @@ public class KotlinEvaluator extends BaseEvaluator {
private ClasspathScanner cps;
private ReplInterpreter repl;
private ReplClassLoader loader = null;
private BeakerxUrlClassLoader kotlinClassLoader;
private BeakerUrlClassLoader kotlinClassLoader;

public KotlinEvaluator(String id, String sId, EvaluatorParameters evaluatorParameters) {
this(id, sId, new BeakerCellExecutor("kotlin"), new TempFolderFactoryImpl(), evaluatorParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.twosigma.beakerx.kotlin.evaluator;

import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.kernel.ImportPath;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.common.repl.ReplClassLoader;
Expand All @@ -39,7 +39,7 @@
public class ReplWithClassLoaderFactory {

@NotNull
public static ReplWithClassLoader createReplWithKotlinParentClassLoader(KotlinEvaluator kotlinEvaluator, BeakerxUrlClassLoader parent) {
public static ReplWithClassLoader createReplWithKotlinParentClassLoader(KotlinEvaluator kotlinEvaluator, BeakerUrlClassLoader parent) {
return createReplInterpreter(getClasspath(), parent, kotlinEvaluator);
}

Expand Down Expand Up @@ -71,9 +71,9 @@ private static String[] getClasspath() {
}

@NotNull
public static BeakerxUrlClassLoader createParentClassLoader(KotlinEvaluator kotlinEvaluator) {
List<URL> urls = BeakerxUrlClassLoader.createUrls(kotlinEvaluator.getClasspath().getPaths());
BeakerxUrlClassLoader parent = new BeakerxUrlClassLoader(urls.toArray(new URL[urls.size()]), ClassLoader.getSystemClassLoader());
public static BeakerUrlClassLoader createParentClassLoader(KotlinEvaluator kotlinEvaluator) {
List<URL> urls = BeakerUrlClassLoader.createUrls(kotlinEvaluator.getClasspath().getPaths());
BeakerUrlClassLoader parent = new BeakerUrlClassLoader(urls.toArray(new URL[urls.size()]), ClassLoader.getSystemClassLoader());
return parent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.twosigma.beakerx.evaluator.JobDescriptor;
import com.twosigma.beakerx.evaluator.TempFolderFactory;
import com.twosigma.beakerx.evaluator.TempFolderFactoryImpl;
import com.twosigma.beakerx.jvm.classloader.BeakerxUrlClassLoader;
import com.twosigma.beakerx.jvm.classloader.BeakerUrlClassLoader;
import com.twosigma.beakerx.jvm.object.SimpleEvaluationObject;
import com.twosigma.beakerx.jvm.serialization.BeakerObjectConverter;
import com.twosigma.beakerx.jvm.threads.BeakerCellExecutor;
Expand Down Expand Up @@ -53,7 +53,7 @@ public class ScalaEvaluator extends BaseEvaluator {
private BeakerxObjectFactory beakerxObjectFactory;
private final Provider<BeakerObjectConverter> objectSerializerProvider;
private static boolean autoTranslationSetup = false;
private BeakerxUrlClassLoader classLoader;
private BeakerUrlClassLoader classLoader;
private ScalaEvaluatorGlue shell;

public ScalaEvaluator(String id, String sId, Provider<BeakerObjectConverter> osp, EvaluatorParameters evaluatorParameters) {
Expand Down Expand Up @@ -175,9 +175,9 @@ private void addImportToShell(ScalaEvaluatorGlue shell, ImportPath importPath) {
* Scala uses multiple classloaders and (unfortunately) cannot fallback to the java one while compiling scala code so we
* have to build our DynamicClassLoader and also build a proper classpath for the compiler classloader.
*/
private BeakerxUrlClassLoader newClassLoader() {
private BeakerUrlClassLoader newClassLoader() {
logger.debug("creating new loader");
BeakerxUrlClassLoader cl = new BeakerxUrlClassLoader(ClassLoader.getSystemClassLoader());
BeakerUrlClassLoader cl = new BeakerUrlClassLoader(ClassLoader.getSystemClassLoader());
cl.addPathToJars(getClasspath().getPaths());
return cl;
}
Expand Down