-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the Issue
Issue
The problem is when i generate a native image and run it, it throws below error:
java.lang.IllegalArgumentException: Type org.example.dtos.SSOGetTokenResponse is instantiated reflectively but was never registered. Register the type by adding "unsafeAllocated" for the type in rechability-metadata.json
currently as a workaround, i have added "unsafeAllocated" to generated reflection config manually and it works post that but would be awesome if we can figure out and fix it in the tool itself somehow
Using the latest version of GraalVM can resolve many issues.
- I tried with the latest version of GraalVM.
GraalVM Version
➜ graalvm-demo git:(main) ✗ java --version
java 25.0.1 2025-10-21 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS-jvmci-b01)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS-jvmci-b01, mixed mode, sharing)
Operating System and Version
Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041 arm64
Build Command
Clone the repo https://github.com/Sasuke214/graalvm-demo
Run sdk use java 25.0.1-graal
Run ./mvnw -Pnative -DskipTests native:compile
Run ./target/Graal-JS
Expected Behavior
Generates complete reflection for the provided class
Actual Behavior
Generates reflection for the provided class but doesn't have "unsafeAllocated" or any way to instanciate that class
Steps to Reproduce
- Clone the repo https://github.com/Sasuke214/graalvm-demo
- Run
sdk use java 25.0.1-graal - Run
./mvnw -Pnative -DskipTests native:compile - Run
./target/Graal-JS
Additional Context
No response
Build Log Output and Error Messages
java.lang.IllegalArgumentException: Type org.example.dtos.SSOGetTokenResponse is instantiated reflectively but was never registered. Register the type by adding "unsafeAllocated" for the type in rechability-metadata.json.