-
Notifications
You must be signed in to change notification settings - Fork 21
Scala-xml is being picked up from bootclasspath #8358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8358?orig=1 |
@gkossakowski said: |
@gkossakowski said: The underlying issue is that we are conflate compiler's runtime classpath and compilation classpath. To properly split the two we'll need to refactor our classpath handling code. This is a task for Scala 2.12. For Scala 2.11, we should mention this issue in release notes and offer work-around: the |
@SethTisue said: |
the way for this to get fixed is by fixing #9560. (is there a more general, not XML-specific ticket about "The underlying issue is that we are conflate compiler's runtime classpath and compilation classpath"? if not, someone might like to open one) |
Scala-xml module is on the bootclasspath of the compiler because it's needed by scaladoc. However, Scala compiler will pick up all jars from bootclasspath (unless
-nobootclasspath
is passed). That's the reason Scala 2.11 compiles code containing xml literals even if we do not put scala-xml on the classpath explicitly:For command line
scalac
that's the behavior we probably want to have. However, we get the same behavior in Maven. Consider project with the following pom.xml:If you try to compile (
mvn scala:compile
) the same code as above with Maven Scala plugin, it will succeed. However, there's no dependency on xml declared so if you try to run your code you get:mvn scala:run -DmainClass=XMLHelloWorld
[...]
[INFO] --- scala-maven-plugin:3.1.6:run (default-cli) @ scala-module-dependency-sample ---
Exception in thread "main" java.lang.NoClassDefFoundError: scala/xml/NamespaceBinding
at XMLHelloWorld.main(XMLHelloWorld.scala)
Caused by: java.lang.ClassNotFoundException: scala.xml.NamespaceBinding
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
{code}
Also, if you don't try to run from Maven but just compile and then publish you won't notice any problem and you end up with broken published library due to undeclared dependencies.
The text was updated successfully, but these errors were encountered: