Closed cdsap closed 8 months ago
Hi Iñaki! 🙂 👋
That's caused by Gradle calling selectClass(Class)
after loading the class with the default class loader early to perform some checks.
If Gradle would call selectClass(String)
, it would work. Switching those checks to read the bytecode instead of using reflection would avoid initializing the class potentially multiple times. However, using ASM for that should be avoided since newer JDK require upgrading. The Class-File API would avoid that in the future. I'll leave the decision whether to open an issue in the Gradle repo up to you.
As a workaround, you can replace the ClassLoader
in the constructor of CustomLauncherInterceptor
rather than in intercept()
.
In a test using a simple launcher interceptor, test passes if it is executed with the IDE Junit configuration but fails with the IDE Gradle configuration or
./gradlew test
command-line execution. I'm not sure if this issue falls on Junit or Gradle BT. Please, let me know if I should close this issue and create a new one with Gradle.Having the following LauncherInterceptor:
where the
ExampleClassLoader
is:the expected results for the test:
is passing when executing from the IDE and gradle command:
However, the result with Gradle execution is:
(interceptors has been enabled in the platform properties and CustomLauncherInterceptor registered in the services file)
Steps to reproduce
CustomClassLoaderTest
with Junit Configuration in the IDE. Test passes.CustomClassLoaderTest
with Gradle configuration or command-line gradle command. Test fails.Context
Deliverables