From 82089f7909e63696a5e1be004510aa529b90f663 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 21 Dec 2011 14:19:25 +0100 Subject: 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 --- src/compiler/scala/reflect/runtime/JavaToScala.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/compiler') 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? -- cgit v1.2.3