Jonas Konrad
06/17/2024, 11:07 AMjvmArgs("-javaagent:${configurations.typePollutionAgent.singleFile}") , as described here. However, it leads to the following error:
Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: io/type/pollution/agent/TraceInstanceOf
at org.slf4j.LoggerFactory.findPossibleStaticLoggerBinderPathSet(LoggerFactory.java:311)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:146)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
at org.gradle.process.internal.worker.messaging.WorkerConfigSerializer.<clinit>(WorkerConfigSerializer.java:46)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:81)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:66)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.ClassNotFoundException: io.type.pollution.agent.TraceInstanceOf
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 11 more
My assessment is that GradleWorkerMain is creating a FilteringClassLoader that does not let the agent classes through from the boot classpath, which then blows up when the instrumented classes in the class loader attempt to access the agent code. I see a concept of "shared packages" which might help if I added the agent package to it, but I don't see a way to configure the shared packages. Is there a way to fix this or to just disable the class loading isolation?Clayton Walker
06/17/2024, 7:39 PMClayton Walker
06/17/2024, 7:39 PMval testAgent by configurations.creating
dependencies {
testAgent("net.bytebuddy:byte-buddy-agent:1.14.6")
}
testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter("5.10.1")
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.22")
implementation("io.mockk:mockk:1.13.9")
}
targets.configureEach {
testTask.configure {
jvmArgs(testAgent.files.map { "-javaagent:${it.absolutePath}" })
}
}
}
}
}Clayton Walker
06/17/2024, 7:39 PMJonas Konrad
06/18/2024, 7:30 AM