Skip to content
Snippets Groups Projects
Commit 1396678b authored by Ismael Juma's avatar Ismael Juma
Browse files

Move REPL classes to separate module.

parent 3e8114dd
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 5 deletions
......@@ -64,10 +64,19 @@ object ClosureCleaner extends Logging {
accessedFields(cls) = Set[String]()
for (cls <- func.getClass :: innerClasses)
getClassReader(cls).accept(new FieldAccessFinder(accessedFields), 0)
val isInterpNull = {
try {
val klass = Class.forName("spark.repl.Main")
klass.getMethod("interp").invoke(null) == null
} catch {
case _: ClassNotFoundException => true
}
}
var outer: AnyRef = null
for ((cls, obj) <- (outerClasses zip outerObjects).reverse) {
outer = instantiateClass(cls, outer);
outer = instantiateClass(cls, outer, isInterpNull);
for (fieldName <- accessedFields(cls)) {
val field = cls.getDeclaredField(fieldName)
field.setAccessible(true)
......@@ -85,8 +94,8 @@ object ClosureCleaner extends Logging {
}
}
private def instantiateClass(cls: Class[_], outer: AnyRef): AnyRef = {
if (spark.repl.Main.interp == null) {
private def instantiateClass(cls: Class[_], outer: AnyRef, isInterpNull: Boolean): AnyRef = {
if (isInterpNull) {
// This is a bona fide closure class, whose constructor has no effects
// other than to set its fields, so use its constructor
val cons = cls.getConstructors()(0)
......
......@@ -105,7 +105,15 @@ class Executor extends mesos.Executor with Logging {
val classUri = System.getProperty("spark.repl.class.uri")
if (classUri != null) {
logInfo("Using REPL class URI: " + classUri)
loader = new repl.ExecutorClassLoader(classUri, loader)
loader = {
try {
val klass = Class.forName("spark.repl.ExecutorClassLoader").asInstanceOf[Class[_ <: ClassLoader]]
val constructor = klass.getConstructor(classUri.getClass, loader.getClass)
constructor.newInstance(classUri, loader)
} catch {
case _: ClassNotFoundException => loader
}
}
}
return loader
......
......@@ -10,6 +10,8 @@ class SparkProject(info: ProjectInfo) extends ParentProject(info) with IdeaProje
lazy val core = project("core", "Spark Core", new CoreProject(_))
lazy val repl = project("repl", "Spark REPL", new ReplProject(_), core)
lazy val examples = project("examples", "Spark Examples", new ExamplesProject(_), core)
lazy val bagel = project("bagel", "Bagel", new BagelProject(_), core)
......@@ -34,6 +36,10 @@ class SparkProject(info: ProjectInfo) extends ParentProject(info) with IdeaProje
val jetty = jettyWebapp
}
class ReplProject(info: ProjectInfo) extends DefaultProject(info) with BaseProject with DepJar with XmlTestReport {
val jetty = jettyWebapp
}
class ExamplesProject(info: ProjectInfo) extends DefaultProject(info) with BaseProject {
val colt = "colt" % "colt" % "1.2.0"
}
......
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment