summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2011-12-21 14:19:25 +0100
committerEugene Burmako <xeno.by@gmail.com>2011-12-21 14:19:25 +0100
commit82089f7909e63696a5e1be004510aa529b90f663 (patch)
treed6ff4092c0a1af8b5939d636499df092b578a7ca /src/compiler
parent178d49df450904330c06cfea9955f120ba04d34c (diff)
downloadscala-82089f7909e63696a5e1be004510aa529b90f663.tar.gz
scala-82089f7909e63696a5e1be004510aa529b90f663.tar.bz2
scala-82089f7909e63696a5e1be004510aa529b90f663.zip
Attempt to fix classloader issues
@odersky writes: When doing reflect.mirror.ClassWithName("foo") in the REPL, we get a NullPointerException. It goes away if we have this fallback in defaultClassLoader. Not sure it's the right fix, though. Fixes SI-5226, review by @odersky
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/runtime/JavaToScala.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala
index 5297ea6db4..afd623b833 100644
--- a/src/compiler/scala/reflect/runtime/JavaToScala.scala
+++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala
@@ -34,8 +34,10 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable =>
val global: JavaToScala.this.type = self
}
- protected def defaultReflectiveClassLoader(): JClassLoader =
- Thread.currentThread.getContextClassLoader
+ protected def defaultReflectiveClassLoader(): JClassLoader = {
+ val cl = Thread.currentThread.getContextClassLoader
+ if (cl == null) getClass.getClassLoader else cl
+ }
/** Paul: It seems the default class loader does not pick up root classes, whereas the system classloader does.
* Can you check with your newly acquired classloader fu whether this implementation makes sense?