gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
17.01k stars 4.78k forks source link

Unable to compile Scala 3 macro code - `NoClassDefFoundError` for `javax.sql.DataSource` #30419

Open WojciechMazur opened 2 months ago

WojciechMazur commented 2 months ago

Current Behavior

Compilation of projects fails, but only in Gradle. It works when using scala-cli or when invoking scalac directly. The issue seems to be related to JDK 9+ modules.

Crash report below

```scala gradle compileScala > Task :compileScala FAILED unhandled exception while running inlining on /Users/wmazur/projects/sandbox/scala3-quarkus-quickstart/src/main/scala/test.scala An unhandled exception was thrown in the compiler. Please file a crash report here: https://github.com/lampepfl/dotty/issues/new/choose while compiling: /Users/wmazur/projects/sandbox/scala3-quarkus-quickstart/src/main/scala/test.scala during phase: inlining mode: Mode(ImplicitsEnabled) library version: version 2.13.12 compiler version: version 3.3.3 settings: -Xunchecked-java-output-version 8 -bootclasspath /Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.13.12/3c51da898af4ebfac356fcde11388afb2ae8ee82/scala-library-2.13.12.jar -classpath /Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkiverse.scala/quarkus-scala3/1.0.0/74cc9ff7c187fc42a8e477d66edd90c12e03c935/quarkus-scala3-1.0.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala3-compiler_3/3.3.3/f0861fe40f2efb3de760334d7643e5cf0ee1c0cd/scala3-compiler_3-3.3.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/com.augustnagro/magnum_3/1.2.1/f041825597bfb54247e8a112949be08a2662864a/magnum_3-1.2.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang/tasty-core_3/3.3.3/eae28e0f18a38313bb17335ced6cc64c73aed145/tasty-core_3-3.3.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala3-library_3/3.3.3/8717a89f7030fde424b4ba44608fb2583b5ed159/scala3-library_3-3.3.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus/quarkus-arc/3.6.4/ae0a5e6598ca47620524df3ef7e035dfe604bdc5/quarkus-arc-3.6.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.13.12/3c51da898af4ebfac356fcde11388afb2ae8ee82/scala-library-2.13.12.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala3-interfaces/3.3.3/531ddc4a282827400e7ad087802a39964c455b70/scala3-interfaces-3.3.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-asm/9.5.0-scala-1/183e39a374eb4d9f080ca9e1e5445e778d2af6e9/scala-asm-9.5.0-scala-1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-sbt/compiler-interface/1.9.3/b882061aec6f9de3093e777c28022eec82a1e802/compiler-interface-1.9.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jline/jline-reader/3.19.0/645d72953711ee4e61705bc5e576fdd1f22c087/jline-reader-3.19.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jline/jline-terminal-jna/3.19.0/c9f9071612424157ca3d5a774a42f2c9b44c10ef/jline-terminal-jna-3.19.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jline/jline-terminal/3.19.0/d4a75a8be7490c8529c029d6baa59e838f45f22e/jline-terminal-3.19.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus.arc/arc/3.6.4/ac891b43e748c600d872a6b56cb5cfdc5c1f3e99/arc-3.6.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus/quarkus-core/3.6.4/3472132f3c964d64d84afac44efc3f55185c7444/quarkus-core-3.6.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.eclipse.microprofile.context-propagation/microprofile-context-propagation-api/1.3/aab6a415754137629e725a9927702a5cd68038c2/microprofile-context-propagation-api-1.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.scala-sbt/util-interface/1.9.2/b696783ce958ebdf061c53fa173a67f9f1b88754/util-interface-1.9.2.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna/5.3.1/6eb9d07456c56b9c2560722e90382252f0f98405/jna-5.3.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.enterprise/jakarta.enterprise.cdi-api/4.0.1/2012f388c6de83e29101cbf82c3ed2bd37931c64/jakarta.enterprise.cdi-api-4.0.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/2.1.1/48b9bda22b091b1f48b13af03fe36db3be6e1ae3/jakarta.annotation-api-2.1.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.transaction/jakarta.transaction-api/2.0.1/51a520e3fae406abb84e2e1148e6746ce3f80a1a/jakarta.transaction-api-2.0.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.reactive/mutiny/2.5.1/a12c8743df7e7554f0ef3476335c28db6babc9b6/mutiny-2.5.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.config/smallrye-config/3.4.4/93c4b6deb36736ec7284be8d61b9380d87e92771/smallrye-config-3.4.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus/quarkus-bootstrap-runner/3.6.4/7479711b4737175bf5785a742b1d159bca233e02/quarkus-bootstrap-runner-3.6.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jboss.logmanager/jboss-logmanager/3.0.2.Final/5ff47c0785dfdcd833a7b9d00a5a60c1f4d660ca/jboss-logmanager-3.0.2.Final.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jboss.threads/jboss-threads/3.5.1.Final/4a9ba4b753b0148d74a7984b03f5d744e32b42f0/jboss-threads-3.5.1.Final.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.config/smallrye-config-core/3.4.4/a5c38d581dc242f9902038ecb2d5fa1f96b58ce8/smallrye-config-core-3.4.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-net/2.1.0/3b7049a5bcfcf9a14ad8146edbf99acdb85eb72e/smallrye-common-net-2.1.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-expression/2.2.0/efd956fc77a194e2067525587a73c01ed3f18d05/smallrye-common-expression-2.2.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-ref/2.1.0/ad605e6a732a47168752e5806567dc4d21aaadc8/smallrye-common-ref-2.1.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-function/2.2.0/fa5b3437899e29e29dad719543d05bdd9c5c98a8/smallrye-common-function-2.2.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-constraint/2.2.0/73c7b76ba2582b5bd92b0b5300ed85ce5c86d8cb/smallrye-common-constraint-2.2.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.config/smallrye-config-common/3.4.4/d2680e3a3af2ee999b0eab8d3d9d091b6c75c89c/smallrye-config-common-3.4.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.5.3.Final/c88fc1d8a96d4c3491f55d4317458ccad53ca663/jboss-logging-3.5.3.Final.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.inject/jakarta.inject-api/2.0.1/4c28afe1991a941d7702fe1362c365f0a8641d1e/jakarta.inject-api-2.0.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-os/2.1.2/69aa7fb01d27a1adb7dc5b9c350161f4df4ced36/smallrye-common-os-2.1.2.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus/quarkus-ide-launcher/3.6.4/e269ee2b915ff5b9485860a89bee0e29769d495c/quarkus-ide-launcher-3.6.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus/quarkus-development-mode-spi/3.6.4/59ce751e3b9f481f038c0e382b2e1a9fec95cfa4/quarkus-development-mode-spi-3.6.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging-annotations/2.2.1.Final/ee3db82d956ee22c4f1f2df9c611e048e79a4a43/jboss-logging-annotations-2.2.1.Final.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/2.0.6/88c40d8b4f33326f19a7d3c0aaf2c7e8721d4953/slf4j-api-2.0.6.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.jboss.slf4j/slf4j-jboss-logmanager/2.0.0.Final/accb024e15025215cb5ef8c8f41ce5b684fddbf0/slf4j-jboss-logmanager-2.0.0.Final.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.wildfly.common/wildfly-common/1.7.0.Final/b5237d5e5a46ede4e4e142d79623d04b59d11476/wildfly-common-1.7.0.Final.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.quarkus/quarkus-fs-util/0.0.9/af43a8b4da2a2c9119e5280929887445847597a0/quarkus-fs-util-0.0.9.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.enterprise/jakarta.enterprise.lang-model/4.0.1/2b195781faad31c1724d8122136909c34c3ae79e/jakarta.enterprise.lang-model-4.0.1.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.el/jakarta.el-api/5.0.0/2a22b304920f43d6427cdefb5ce5f6726e2a63a3/jakarta.el-api-5.0.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.interceptor/jakarta.interceptor-api/2.1.0/1d06a662708601400af4556577ee514c4ad01549/jakarta.interceptor-api-2.1.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-annotation/2.2.0/ffcae27afa1e62d27fe97e46a9df668f8fd75e81/smallrye-common-annotation-2.2.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-cpu/2.1.0/a677e6f9764c92ed7321f1567396f3afa5f1a65b/smallrye-common-cpu-2.1.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.eclipse.parsson/parsson/1.1.4/d604e85e8c584a652f80f316407a22b147e37af5/parsson-1.1.4.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/jakarta.json/jakarta.json-api/2.1.2/cf0d33a43f05d4d88f30a6972d95115f81c550be/jakarta.json-api-2.1.2.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-io/2.1.2/7eda9aa8e348a18bd07d921ed04524e9fc9730e6/smallrye-common-io-2.1.2.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.github.crac/org-crac/0.1.3/78ca3679ec8ff707c18b17885ef589467780c486/org-crac-0.1.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.eclipse.microprofile.config/microprofile-config-api/3.0.3/6eebba974a4fc34678679a061ac6ef25b2590749/microprofile-config-api-3.0.3.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/io.smallrye.common/smallrye-common-classloader/2.2.0/40f95284ba794d9a88b5aa78e8961e83a1829061/smallrye-common-classloader-2.2.0.jar:/Users/wmazur/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/9.5/dc6ea1875f4d64fbc85e1691c95b96a3d8569c90/asm-9.5.jar:/Users/wmazur/projects/sandbox/scala3-quarkus-quickstart/build/classes/java/main:/Users/wmazur/projects/sandbox/scala3-quarkus-quickstart/build/classes/scala/main -d /Users/wmazur/projects/sandbox/scala3-quarkus-quickstart/build/classes/scala/main -deprecation true ## Exception when compiling 1 sources to /Users/wmazur/projects/sandbox/scala3-quarkus-quickstart/build/classes/scala/main java.lang.NoClassDefFoundError: javax/sql/DataSource java.base/java.lang.Class.getDeclaredMethods0(Native Method) java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3578) java.base/java.lang.Class.getMethodsRecursive(Class.java:3719) java.base/java.lang.Class.getMethod0(Class.java:3705) java.base/java.lang.Class.getMethod(Class.java:2393) dotty.tools.dotc.quoted.Interpreter.getMethod(Interpreter.scala:219) dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall(Interpreter.scala:171) dotty.tools.dotc.quoted.Interpreter.interpretTree(Interpreter.scala:80) dotty.tools.dotc.transform.Splicer$SpliceInterpreter.interpretTree(Splicer.scala:258) dotty.tools.dotc.quoted.Interpreter.interpretTree$$anonfun$2(Interpreter.scala:99) dotty.tools.dotc.transform.Splicer$.$anonfun$2(Splicer.scala:60) scala.Option.fold(Option.scala:263) dotty.tools.dotc.transform.Splicer$.splice(Splicer.scala:60) dotty.tools.dotc.inlines.Inliner.dotty$tools$dotc$inlines$Inliner$$expandMacro(Inliner.scala:1048) dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSplice(Inliner.scala:839) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3094) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3115) dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:153) dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:915) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3187) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3191) dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:65) dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3055) dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3115) dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:153) dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:915) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3187) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) dotty.tools.dotc.typer.Typer.typed(Typer.scala:3191) dotty.tools.dotc.inlines.Inliner.inlined(Inliner.scala:681) dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:449) dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:152) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:95) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1501) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1509) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1507) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1501) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1507) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1507) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1249) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1231) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1244) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1249) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1521) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:91) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:50) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:89) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1244) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1244) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1246) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:58) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1575) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:89) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1244) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1244) dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1246) dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1586) dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67) dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:97) dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:58) dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:18) dotty.tools.dotc.transform.Inlining.run(Inlining.scala:34) dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:327) scala.collection.immutable.List.map(List.scala:246) dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:331) dotty.tools.dotc.transform.Inlining.runOn(Inlining.scala:38) dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246) scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323) dotty.tools.dotc.Run.runPhases$1(Run.scala:262) dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270) dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279) dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:71) dotty.tools.dotc.Run.compileUnits(Run.scala:279) dotty.tools.dotc.Run.compileSources(Run.scala:194) dotty.tools.dotc.Run.compile(Run.scala:179) dotty.tools.dotc.Driver.doCompile(Driver.scala:37) dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:136) dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22) sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91) sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193) scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248) sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183) sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163) sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239) sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163) sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211) sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534) sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534) sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:180) sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178) sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464) sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116) sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56) sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52) sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263) sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:419) sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506) sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406) sbt.internal.inc.Incremental$.apply(Incremental.scala:172) sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534) sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488) sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332) sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425) sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137) org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:158) org.gradle.api.internal.tasks.scala.ZincScalaCompilerFacade.execute(ZincScalaCompilerFacade.java:39) org.gradle.api.internal.tasks.scala.ZincScalaCompilerFacade.execute(ZincScalaCompilerFacade.java:26) org.gradle.api.internal.tasks.compile.daemon.AbstractIsolatedCompilerWorkerExecutor$CompilerWorkAction.execute(AbstractIsolatedCompilerWorkerExecutor.java:78) org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63) org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:54) org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:48) org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100) org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:48) org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49) org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30) org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:103) org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:72) org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:152) org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41) org.gradle.process.internal.worker.request.WorkerAction.lambda$run$1(WorkerAction.java:149) org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:85) org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:141) java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) java.base/java.lang.reflect.Method.invoke(Method.java:580) org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48) java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) java.base/java.lang.Thread.run(Thread.java:1583) FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileScala'. > javax/sql/DataSource ```

Since 3.5.0 the NoClassDefFoundError is catched in the compiler to finish to handle possible issues when pipelining is enabled. It would result in following error:

[Error] test.scala:19:9: Macro code depends on class DataSource in package javax.sql found on the classpath, but could not be loaded while evaluating the macro.
  This is likely because class files could not be found in the classpath entry for the symbol.

  A possible cause is if the origin of this symbol was built with pipelined compilation;
  in which case, this problem may go away by disabling pipelining for that origin.

  class DataSource is defined in file /modules/java.sql/javax/sql/DataSource.class
one error found

Expected Behavior

Gradle should be able to compile the program correctly.

Context (optional)

The issue originated when testing Scala 3 with Quarkus and Mangum library, based on https://github.com/carlosedp/scala3-quarkus-quickstart It might affect new comers to the Gradle build tool.

Steps to Reproduce

Minimal reproducer project

// settings.gradle
plugins {
    id "scala"
}

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    implementation "io.quarkiverse.scala:quarkus-scala3:1.0.0"
    implementation "org.scala-lang:scala3-library_3:3.3.3"
    implementation "org.scala-lang:scala3-compiler_3:3.3.3"
    implementation "com.augustnagro:magnum_3:1.2.1"
}
// src/main/scala/test.scala

// Directives for use with Scala 3.5.0 runner / scala-cli
//> using dep io.quarkiverse.scala:quarkus-scala3:1.0.0
//> using dep com.augustnagro:magnum_3:1.2.1

import com.augustnagro.magnum.*
import jakarta.enterprise.context.ApplicationScoped

@Table(PostgresDbType, SqlNameMapper.SameCase)
@SqlName("userInfo")
case class UserInfo(@Id userid: Long) derives DbCodec

object UserInfo:
    val Table = TableInfo[UserInfo, UserInfo, Long]

@ApplicationScoped
class UserInfoRepository extends ImmutableRepo[UserInfo, Long]:
    def getN(count: Int)(using DbCon): Seq[UserInfo] = 
        val u = UserInfo.Table
        sql"SELECT ${u.all} FROM $u".query.run() // macro leading to crash

Gradle version

8.10

Build scan URL (optional)

https://gradle.com/s/lv3v3ineu63ve

Your Environment (optional)

MacOS 14 Arm64, JDK 17, Scala 3.3.3 / 3.5.0

lmlynik commented 2 months ago

I've encountered this with working with https://github.com/carlosedp/scala3-quarkus-quickstart

Issue happens only for gradle, maven build works fine. after debugging this somewhat I've noticed that:

default Zinc version is outdated, but upgrading it it doesn't help

The params between gradle plugin and maven plugin when calling Zinc differ

Gradle:

2024-09-05T15:19:22.522+0200 [DEBUG] [org.gradle.api.internal.tasks.scala.ZincScalaCompilerFactory] [zinc] The Scala compiler is invoked with:
    -deprecation
    -unchecked
    -feature
    -Wunused:all
    -Xtarget:8
    -bootclasspath
    /home/lmlynik/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.13.14/f8b4afe89abe48ca670f620c7da89b71f93e6546/scala-library-2.13.14.jar
    -classpath
    /home/lmlynik/IdeaProjects/scala3-quarkus-quickstart/build/classes/....

Maven:

[DEBUG] [zinc] The Scala compiler is invoked with:
    -Wunused:all
    -feature
    -deprecation
    -Ysemanticdb
    -java-output-version
    21
    -bootclasspath
    /home/lmlynik/.m2/repository/org/scala-lang/scala3-library_3/3.5.0/scala3-library_3-3.5.0.jar:/home/lmlynik/.m2/repository/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar
    -classpath
    /home/lmlynik/.m2/repository...

Notice that the maven plugin adds the scala3 library into the bootclasspath, where gradle doesn't

ljacomet commented 2 months ago

The issue is in the backlog of the relevant team and is prioritized by them.


Relates to:

Note that our capacity is limited for Scala topics and we welcome help from the community to resolve those issues. If you can confirm that the proposed fix for #27226 also fixes this issue, it would help. If not, figuring out the problem and explaining it here would also help.