Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Thread.currentThread.getContextClassLoader isnt set up properly in the console/repl #5072
Thread.currentThread.getContextClassLoader returns a stub of a classloader:
This resulting classloader is unable to load resources from the system classpath, so any code you call from within the console may fail. For example, the Hadoop project uses the context class loader to obtain configuration files from the jars. But it will fail to find config entries (bad):
scala> val c = new Configuration
One cannot set the Thread.currentThread.setContextClassLoader because every new line is a new thread. Thus perhaps one could fix it by doing a block first setting the context class loader, then calling the code which needs it like such.
Essentially the result is legitimate code which will run in a script/app in scala will not run in a console.
Imported From: https://issues.scala-lang.org/browse/SI-5072?orig=1
@retronym said (edited on Jan 20, 2012 10:04:21 PM UTC):
In Scala 2.10.0-M1, this is classloader covers classes created during the REPL session.