Closed
Description
- When using Spring's Gradle Plugin, the Tracing Agent of GraalVM Native Build Tools cannot be used normally. This issue is an extension of Add support for
com.baomidou:dynamic-datasource-spring-boot-starter:3.6.1
oracle/graalvm-reachability-metadata#154, because it involves Spring's Gradle Plugin. - Related, the Spring Boot OSS version used for verification is 3.0.5. The minimal reproducible Example and corresponding reproduction steps are located at https://github.com/linghengqian/spring-plugin-graalvm-agent-test .
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 22.3.1.r17-grl
sdk use java 22.3.1.r17-grl
gu install native-image
sudo apt-get install build-essential libz-dev zlib1g-dev -y
git clone git@github.com:linghengqian/spring-plugin-graalvm-agent-test.git
cd ./spring-plugin-graalvm-agent-test/
./gradlew -Pagent clean test
./gradlew metadataCopy --task test
./gradlew clean nativeTest
- More early investigations are at Make ShardingSphere Proxy in GraalVM Native Image form available apache/shardingsphere#21347. This issue may also be related to the problem encountered at Add support for Spring Cloud Alibaba modules oracle/graalvm-reachability-metadata#260.
- I noticed that when Spring Boot's Gradle Plugin is introduced, the following error will occur when executing
./gradlew -Pagent clean test
.
> Task :processTestAot
[native-image-plugin] Instrumenting task with the native-image-agent: processTestAot
[0.214s][warning][jni,resolve] Re-registering of platform native method: jdk.internal.misc.Unsafe.allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; from code in a different classloader
20:42:10.489 [main] INFO org.springframework.test.context.aot.TestClassScanner -- Scanning for Spring test classes in all packages in classpath roots [/home/linghengqian/TwinklingLiftWorks/git/public/spring-plugin-graalvm-agent-test/build/classes/java/test, /home/linghengqian/TwinklingLiftWorks/git/public/spring-plugin-graalvm-agent-test/build/resources/test]
Exception in thread "main" java.lang.IllegalStateException: Cannot perform AOT processing during AOT run-time execution
at org.springframework.util.Assert.state(Assert.java:76)
at org.springframework.test.context.aot.TestContextAotGenerator.processAheadOfTime(TestContextAotGenerator.java:126)
at org.springframework.test.context.aot.TestAotProcessor.performAotProcessing(TestAotProcessor.java:91)
at org.springframework.test.context.aot.TestAotProcessor.doProcess(TestAotProcessor.java:72)
at org.springframework.test.context.aot.TestAotProcessor.doProcess(TestAotProcessor.java:39)
at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
at org.springframework.boot.test.context.SpringBootTestAotProcessor.main(SpringBootTestAotProcessor.java:63)
> Task :processTestAot FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processTestAot'.
> Process 'command '/home/linghengqian/.sdkman/candidates/java/22.3.1.r17-grl/bin/java'' finished with non-zero exit value 1
* 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 11s
5 actionable tasks: 4 executed, 1 up-to-date
- If I just execute
./gradlew clean test
, everything works fine, but cannot useuser-code-filter.json
to generate GraalVM reachability metadata in Conditional Agent Mode. - Spring AOT overrides my configuration for Native Build Tools. I wonder if this is the expected behavior of Classpath-based filtering of the native configuration generation #28163 ? Or am I overlooking something?
- As a follow-up to Add support for
com.baomidou:dynamic-datasource-spring-boot-starter:3.6.1
oracle/graalvm-reachability-metadata#154, I opened this issue on the Spring Boot side.