File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
core/src/main/scala/org/apache/spark/api/r Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,19 @@ private[r] class RBackendHandler(server: RBackend)
8888 ctx.close()
8989 }
9090
91+ // get classPath for static object. This addresses SPARK-5185
92+ def getStaticClass (objId : String ): Class [_] = {
93+ try {
94+ val clsCurrent = Class .forName(objId)
95+ clsCurrent
96+ } catch {
97+ // use contextLoader if we can't find the JAR in the system class loader
98+ case e : ClassNotFoundException =>
99+ val clsContext = Class .forName(objId, true , Thread .currentThread().getContextClassLoader)
100+ clsContext
101+ }
102+ }
103+
91104 def handleMethodCall (
92105 isStatic : Boolean ,
93106 objId : String ,
@@ -98,7 +111,7 @@ private[r] class RBackendHandler(server: RBackend)
98111 var obj : Object = null
99112 try {
100113 val cls = if (isStatic) {
101- Class .forName (objId)
114+ getStaticClass (objId)
102115 } else {
103116 JVMObjectTracker .get(objId) match {
104117 case None => throw new IllegalArgumentException (" Object not found " + objId)
You can’t perform that action at this time.
0 commit comments