Skip to content

Commit d1d4afd

Browse files
authored
Add setClassLoader method to MleapReflection (#816)
1 parent fad50bf commit d1d4afd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mleap-core/src/main/scala/ml/combust/mleap/core/reflection/MleapReflection.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,17 @@ trait MleapReflection {
152152

153153
object MleapReflection extends MleapReflection {
154154
override val universe: scala.reflect.runtime.universe.type = scala.reflect.runtime.universe
155+
private var classLoader: Option[ClassLoader] = None
156+
157+
def setClassLoader(cl: ClassLoader) = MleapReflectionLock.synchronized {
158+
classLoader = Some(cl)
159+
}
160+
161+
def getClassLoader(): ClassLoader = MleapReflectionLock.synchronized {
162+
classLoader.getOrElse(Thread.currentThread().getContextClassLoader)
163+
}
164+
155165
override def mirror: universe.Mirror = MleapReflectionLock.synchronized {
156-
universe.runtimeMirror(Thread.currentThread().getContextClassLoader)
166+
universe.runtimeMirror(getClassLoader())
157167
}
158168
}

0 commit comments

Comments
 (0)