Skip to content
15 changes: 14 additions & 1 deletion core/src/main/scala/org/apache/spark/api/r/RBackendHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ private[r] class RBackendHandler(server: RBackend)
ctx.close()
}

//get classPath for static object. This addresses SPARK-5185
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: Space after // - Also could you expand the comment to say Looks up a class given a class name. This function first checks the current class loader and if a class is not found, it looks up the class in the context class loader.

def getStaticClass(objId: String): Class[_] = {
try {
val clsCurrent = Class.forName(objId)
clsCurrent
} catch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align } with the beginning of try

//use contextLoader if we can't find the JAR in the system class loader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same style nit space after //-- Also very minor nit -- Use instead of use

case e: ClassNotFoundException =>
val clsContext = Class.forName(objId, true, Thread.currentThread().getContextClassLoader)
clsContext
}
}

def handleMethodCall(
isStatic: Boolean,
objId: String,
Expand All @@ -98,7 +111,7 @@ private[r] class RBackendHandler(server: RBackend)
var obj: Object = null
try {
val cls = if (isStatic) {
Class.forName(objId)
getStaticClass(objId)
} else {
JVMObjectTracker.get(objId) match {
case None => throw new IllegalArgumentException("Object not found " + objId)
Expand Down