Skip to content
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

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

Open
Baccata opened this issue Dec 1, 2021 · 2 comments

Comments

@Baccata
Copy link
Collaborator

Baccata commented Dec 1, 2021

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
Copy link
Collaborator Author

Baccata commented Dec 1, 2021

This is likely the exact same bug as : #54

@kubukoz
Copy link

kubukoz commented Apr 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants