I am making an uber-jar (i.e. containing scala-runtime classes inside) using scala and maven (maven-shade-plugin). I need it to run with (using scala console) and without scala runtime libs on classpath (as a standalone jar). So I did the following:
- shaded classes to scala to scala_2_12_8 using maven-shade-plugin (i.e. scala runtime is places in scala_2_12_8 package)
- ran scala 2.12.8 console
- loaded my jar using require my.jar (my_2.12-2.1.3-SNAPSHOT.jar) When I try to create to create an object using new org.test.MyObject, I get the following exceptions:
(class java.lang.RuntimeException/Scala class file does not contain Scala annotation)
error: error while loading package, class file '/home/cergey/Documents/my_2.12-2.1.3-SNAPSHOT.jar(scala_2_12_8/package.class)' is broken
(class java.lang.RuntimeException/Scala class file does not contain Scala annotation)
error: error while loading MyObject, class file '/home/cergey/Documents/my_2.12-2.1.3-SNAPSHOT.jar(org/test/MyObject.class)' is broken
(class java.lang.RuntimeException/Scala class file does not contain Scala annotation)
<console>:12: error: my.MyObject does not have a constructor
new test.MyObject
Scala console version and version in the jar match. When I run without scala runtime classes, everything works fine. Could someone point in what's happening, i.e. why jvm is looking for Scala annotation on non-scala class ?