eed3si9n / expecty

Power assertions (as known from Groovy and Spock) for the Scala language.
Apache License 2.0
99 stars 14 forks source link

[Scala 3] Macro leads to class-not-found at runtime when containing a reference to a java enum. #59

Open Baccata opened 2 years ago

Baccata commented 2 years ago

Repro (using scala-cli) :

// using lib org.scala-sbt:test-interface:1.0
// using lib com.eed3si9n.expecty::expecty:0.15.4

import sbt.testing.Status
import com.eed3si9n.expecty.Expecty.assert

@main
def main() = assert(Status.Error == Status.Error)

Output :

Compiling project (Scala 3.0.2, JVM)
Compiled project (Scala 3.0.2, JVM)
Exception in thread main: java.lang.Exception: java.lang.NoClassDefFoundError: sbt/testing/Status$
    at method print in modules/runner/src/main/scala-3-stable/scala/cli/runner/Stacktrace.scala:12 inside runner_3.jar 
    at method printException in modules/runner/src/main/scala/scala/cli/runner/StackTracePrinter.scala:91 inside runner_3.jar 
    at method main in modules/runner/src/main/scala/scala/cli/runner/Runner.scala:22 inside runner_3.jar 

Caused by: Exception in thread main: java.lang.ClassNotFoundException: sbt.testing.Status$
    at method loadClass in jdk.internal.loader.BuiltinClassLoader:602 
    at method loadClass in jdk.internal.loader.ClassLoaders$AppClassLoader:178 
    at method loadClass in java.lang.ClassLoader:522 
    at method main in foo.scala:8 
Baccata commented 2 years ago

This is likely the exact same bug as : https://github.com/eed3si9n/expecty/issues/54

kubukoz commented 1 year ago

Hitting this too:

//> using scala "3.2.2"
//> using lib "software.amazon.smithy:smithy-model:1.30.0"
//> using lib "com.disneystreaming::weaver-cats:0.8.3"
import software.amazon.smithy.model.shapes.ShapeId
import weaver._

object MyTest extends FunSuite {

  test("demo") {
    val shapes = Set.empty[ShapeId]
    expect(shapes.contains(ShapeId.from("foo#Foo")))
  }

}
Exception in thread "io-compute-6" java.lang.NoClassDefFoundError: software/amazon/smithy/model/shapes/ShapeId$
        at MyTest$.$init$$$anonfun$1(main.scala:11)
        at scala.util.Try$.apply(Try.scala:210)
        at weaver.Test$.pure(Test.scala:31)
        at weaver.FunSuiteF.test$$anonfun$1(suites.scala:187)
        at weaver.FunSuiteF.pureSpec$$anonfun$1(suites.scala:197)
        at scala.collection.immutable.List.map(List.scala:246)
        at scala.collection.immutable.List.map(List.scala:79)
        at weaver.FunSuiteF.pureSpec(suites.scala:197)
        at weaver.FunSuiteF.spec(suites.scala:201)
        at weaver.EffectSuite.run(suites.scala:52)
        at weaver.EffectSuite.run$(suites.scala:29)
        at weaver.RunnableSuite.run(suites.scala:64)
        at weaver.framework.RunnerCompat$IOTask.$anonfun$9$$anonfun$1$$anonfun$1(RunnerCompat.scala:221)
        at cats.effect.IOFiber.succeeded(IOFiber.scala:1177)
        at cats.effect.IOFiber.runLoop(IOFiber.scala:345)
        at cats.effect.IOFiber.execR(IOFiber.scala:1324)
        at cats.effect.IOFiber.run(IOFiber.scala:118)
        at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:485)
Caused by: java.lang.ClassNotFoundException: software.amazon.smithy.model.shapes.ShapeId$
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 18 more