Skip to content

Commit 2a6f0c8

Browse files
committed
Tune method names
1 parent 1784980 commit 2a6f0c8

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/main/java/scalive/Classpath.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ public static void findAndAddJar(URLClassLoader cl, String[] jarpaths, String ja
5555
}
5656

5757
/**
58-
* Similar to findAndAddJar, but only add the JAR to classpath if the
59-
* representativeClass has not been loaded.
58+
* Similar to findAndAddJar without representativeClass, but only find and
59+
* add the JAR to classpath if the representativeClass has not been loaded.
6060
*/
61-
public static void addJarToURLClassLoader(
61+
public static void findAndAddJar(
6262
URLClassLoader cl, String[] jarpaths, String jarbase, String representativeClass
6363
) throws Exception {
6464
try {
6565
Class.forName(representativeClass, true, cl);
6666
} catch (ClassNotFoundException e) {
6767
System.out.println("[Scalive] Load " + jarbase);
68-
Classpath.findAndAddJar(cl, jarpaths, jarbase);
68+
findAndAddJar(cl, jarpaths, jarbase);
6969
}
7070
}
7171

7272
// http://stackoverflow.com/questions/4121567/embedded-scala-repl-inherits-parent-classpath
73-
public static String getURLClasspath(URLClassLoader cl) {
73+
public static String getClasspath(URLClassLoader cl) {
7474
URL[] urls = cl.getURLs();
7575
return join(urls, File.pathSeparator);
7676
}
@@ -81,6 +81,8 @@ public static String getScalaVersion(ClassLoader cl) throws Exception {
8181
return (String) m.invoke(k);
8282
}
8383

84+
//--------------------------------------------------------------------------
85+
8486
private static String join(Object[] xs, String separator) {
8587
StringBuffer buf = new StringBuffer();
8688
for (Object x: xs) {

src/main/java/scalive/Server.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void serve(Socket client, String[] jarpaths) throws Exception {
2727
URLClassLoader cl = (URLClassLoader) ClassLoader.getSystemClassLoader();
2828
addJarsToURLClassLoader(cl, jarpaths);
2929

30-
String classpath = Classpath.getURLClasspath(cl);
30+
String classpath = Classpath.getClasspath(cl);
3131
Class<?> repl = Class.forName("scalive.Repl");
3232
Method method = repl.getMethod("run", ClassLoader.class, String.class, InputStream.class, OutputStream.class);
3333
method.invoke(null, cl, classpath, in, out);
@@ -42,14 +42,14 @@ public static void serve(Socket client, String[] jarpaths) throws Exception {
4242

4343
private static void addJarsToURLClassLoader(URLClassLoader cl, String[] jarpaths) throws Exception {
4444
// Try scala-library first
45-
Classpath.addJarToURLClassLoader(cl, jarpaths, "scala-library-" + DEFAULT_SCALA_VERSION, "scala.AnyVal");
45+
Classpath.findAndAddJar(cl, jarpaths, "scala-library-" + DEFAULT_SCALA_VERSION, "scala.AnyVal");
4646

4747
// So that we can get the actual Scala version being used
4848
String version = Classpath.getScalaVersion(cl);
4949

50-
Classpath.addJarToURLClassLoader(cl, jarpaths, "scala-reflect-" + version, "scala.reflect.runtime.JavaUniverse");
51-
Classpath.addJarToURLClassLoader(cl, jarpaths, "scala-compiler-" + version, "scala.tools.nsc.interpreter.ILoop");
50+
Classpath.findAndAddJar(cl, jarpaths, "scala-reflect-" + version, "scala.reflect.runtime.JavaUniverse");
51+
Classpath.findAndAddJar(cl, jarpaths, "scala-compiler-" + version, "scala.tools.nsc.interpreter.ILoop");
5252

53-
Classpath.addJarToURLClassLoader(cl, jarpaths, "scalive", "scalive.Repl");
53+
Classpath.findAndAddJar(cl, jarpaths, "scalive", "scalive.Repl");
5454
}
5555
}

0 commit comments

Comments
 (0)