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

Switch to Scala 3 - fails (due to ClassLoaderLayeringStrategy?) #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rtyley
Copy link
Owner

@rtyley rtyley commented Feb 6, 2025

Switching to Scala 3 (from Scala 2.13.16) fails:

[error] Test suite com.madgag.git.ReachableBlobSpec failed with java.lang.NoClassDefFoundError: com/madgag/compress/CompressUtil$.
[error] This may be due to the ClassLoaderLayeringStrategy (ScalaLibrary) used by your task.
[error] To improve performance and reduce memory, sbt attempts to cache the class loaders used to load the project dependencies.
[error] The project class files are loaded in a separate class loader that is created for each test run.
[error] The test class loader accesses the project dependency classes using the cached project dependency classloader.
[error] With this approach, class loading may fail under the following conditions:
[error] 
[error]  * Dependencies use reflection to access classes in your project's classpath.
[error]    Java serialization/deserialization may cause this.
[error]  * An open package is accessed across layers. If the project's classes access or extend
[error]    jvm package private classes defined in a project dependency, it may cause an IllegalAccessError
[error]    because the jvm enforces package private at the classloader level.
[error] 
[error] These issues, along with others that were not enumerated above, may be resolved by changing the class loader layering strategy.
[error] The Flat and ScalaLibrary strategies bundle the full project classpath in the same class loader.
[error] To use one of these strategies, set the ClassLoaderLayeringStrategy key
[error] in your configuration, for example:
[error] 
[error] set scala-git / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
[error] set scala-git / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
[error] 
[error] See ClassLoaderLayeringStrategy.scala for the full list of options.

Unfortunately, even if we follow the advice of the setting the ClassLoaderLayeringStrategy, the build still fails:

Forking also fails:

See also:

@rtyley rtyley changed the title Switch to Scala 3 Switch to Scala 3 - fails (due to ClassLoaderLayeringStrategy) Feb 6, 2025
@rtyley rtyley changed the title Switch to Scala 3 - fails (due to ClassLoaderLayeringStrategy) Switch to Scala 3 - fails (due to ClassLoaderLayeringStrategy?) Feb 6, 2025
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

Successfully merging this pull request may close these issues.

1 participant