sbt / sbt-assembly

Deploy über-JARs. Restart processes. (port of codahale/assembly-sbt)
MIT License
1.95k stars 224 forks source link

Can't shade scala 2.12.8 symbol #377

Closed Katrix closed 1 year ago

Katrix commented 5 years ago

I can't seem to be able to shade Scala 2.12.8 in a way that doesn't break when running if I'm using symbols.

With a rule like this

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("scala.**" -> "shadetest.shade.scala.@1").inAll,
)

And a scala file like this

package shadetest

object SymbolUser {
  def main(args: Array[String]): Unit = {
    println('foo)
  }
}

Running from sbt works fine, but if trying to run the jar gotten from the assembly task, I get this instead.

Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
    at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
    at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
    at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
    at shadetest.SymbolUser$.main(SymbolUser.scala:5)
    at shadetest.SymbolUser.main(SymbolUser.scala)
Caused by: java.lang.TypeNotPresentException: Type scala.Symbol not present
    at sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:85)
    at sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:63)
    at sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:41)
    at java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1067)
    at shadetest.shade.scala.runtime.SymbolLiteral.bootstrap(SymbolLiteral.java:25)
    at java.lang.invoke.CallSite.makeSite(CallSite.java:294)
    ... 4 more
Caused by: java.lang.ClassNotFoundException: scala.Symbol
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:83)
    ... 9 more

I've created a small repo to reproduce the error here https://github.com/Katrix/SbtAssemblyError

eed3si9n commented 1 year ago

This is probably fixed now.