-
Notifications
You must be signed in to change notification settings - Fork 280
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
IllegalAccessError
in Dagger with KSP2.0.0-1.0.22 and KSP2
#1956
Comments
For reference, the other issue is this one #1911 |
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:kspStudentReleaseKotlin'.
> A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
> failed to access class com.google.common.base.NullnessCasts from class com.google.common.base.Suppliers$NonSerializableMemoizingSupplier (com.google.common.base.NullnessCasts is in unnamed module of loader java.net.URLClassLoader @1da5a084; com.google.common.base.Suppliers$NonSerializableMemoizingSupplier is in unnamed module of loader java.net.URLClassLoader @6a396bab)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 20s |
So I did some digging and I found the issue. The problem happens when you have two KSP tasks in the same Gradle project. The tasks use a custom classloader for each run. But since the classes are loaded into the running VM, you end up in trouble. So for example, say you have an Android project that has
Now the issue happens because I'm not sure what the correct solution is. KSP could perhaps try and force the class loader to be GCed and thus unload the classes. |
The best solution here would be for KSP to shade its guava use, as it doesn't need to be a part of the public API anyway I think? |
They already do. It's Daggers Guava that conflicts with Rooms guava I believe. But it's worth noting that it can happen with any dependency of course |
I'm not sure how that can be the case? I don't see the shading in those package names |
I made a special build of KSP that logged the classloaders so I've confirmed that it's not KSP's guava that is causing issues, it's one from a processor |
Ahh, dagger should be shading then? |
Dagger shading it would be an option, but other libraries can have issues too. Ideally this should be solved on the KSP side I think. If they could unload the CL and thus unload the classes that would be ideal I think. I don't know if there are other ways of isolating the VM that doesn't include forking. |
true, and dagger does expose guava in its public APIs in some places so it probably can't shade |
That’s not solving it, that is disabling KSP2 thus circumventing the issue |
This is likely caused by the conflict between the bundled Guava in KSP and the one pulled as the dependency of Dagger. The KSP artifact is going to be changed from Please reopen if KSP 1.0.24 doesn't work for you. |
Stacktrace:
Kotlin 2.0.0 + KSP2.0.0-1.0.22 (
ksp.useKSP2=true
) + Dagger 2.51.1. Feels related to the other issue with classpath, but if it's an incompatibility that should be fixed on the Dagger side then I'll open an issue there.The text was updated successfully, but these errors were encountered: