Add graalvm-native-images: Boot 4.1 + GraalVM CE for JDK 25, AOT processing,
the tracing agent, and a real reflection-collision trap Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EQNA6DJ9VgCtW6zhCE8Xud
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# Reproduces every measurement behind the ankurm.com GraalVM native images post.
|
||||
# Requires: JAVA_HOME pointed at a plain JDK 25 for the JVM steps, and a separate GraalVM
|
||||
# distribution (with the bundled native-image tool) for the native steps -- see docs/00-versions.md.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
echo "== 1. plain JVM baseline =="
|
||||
"$JDK25_HOME/bin/java" -jar target/app.jar --server.port=8081 &
|
||||
JPID=$!
|
||||
sleep 5
|
||||
curl -s localhost:8081/hello; echo
|
||||
ps -o rss= -p $JPID
|
||||
kill $JPID
|
||||
|
||||
echo "== 2. build the native image (mvn -Pnative native:compile) =="
|
||||
mvn -Pnative -DskipTests native:compile
|
||||
|
||||
echo "== 3. run the native image, reflection trap included =="
|
||||
./target/graalvm-native-images --server.port=8082 &
|
||||
NPID=$!
|
||||
sleep 1
|
||||
curl -s "localhost:8082/report?format=plain"; echo
|
||||
ps -o rss= -p $NPID
|
||||
kill $NPID
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Reproduces the tracing-agent fix for the /report reflection trap: run the plain jar under the
|
||||
# GraalVM tracing agent, exercise both code paths, then rebuild the native image with the
|
||||
# generated hints merged in under a namespace that does NOT collide with Spring's own AOT output.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
rm -rf agent-output && mkdir -p agent-output
|
||||
"$GRAALVM_HOME/bin/java" -agentlib:native-image-agent=config-output-dir=agent-output \
|
||||
-jar target/app.jar --server.port=8083 &
|
||||
AGENT_PID=$!
|
||||
sleep 10
|
||||
curl -s "localhost:8083/report?format=plain"; echo
|
||||
curl -s "localhost:8083/report?format=json"; echo
|
||||
kill $AGENT_PID
|
||||
|
||||
echo "Generated hints for our own classes:"
|
||||
grep -A4 "com.ankurm.graalvmdemo.report" agent-output/reachability-metadata.json
|
||||
Reference in New Issue
Block a user