-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add GraalVM Native Image support for Java applications #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds a comprehensive prompt for adding GraalVM Native Image support to Java applications. The prompt provides an expert-level, iterative workflow for analyzing projects, configuring native image builds, resolving errors, and verifying native executables across multiple frameworks (Spring Boot, Quarkus, Micronaut).
Key changes:
- New prompt file providing step-by-step GraalVM native image configuration guidance
- Framework-specific instructions for Maven and Gradle projects
- Detailed troubleshooting and error resolution strategies for common native image issues
- Comprehensive examples for reflection, resource, JNI, and proxy configurations
|
|
||
| ```groovy | ||
| plugins { | ||
| id 'org.graalvm.buildtools.native' version '0.10.0' |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GraalVM Native Build Tools plugin version 0.10.0 appears again here. Please ensure this is the latest version or consider using a placeholder like [latest-version] to avoid outdated version recommendations.
|
|
||
| ```kotlin | ||
| plugins { | ||
| id("org.graalvm.buildtools.native") version "0.10.0" |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GraalVM Native Build Tools plugin version 0.10.0 appears again here. Please ensure this is the latest version or consider using a placeholder like [latest-version] to avoid outdated version recommendations.
|
|
||
| **Maven:** | ||
| ```sh | ||
| mvn -Pnative native:compile |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Maven command mvn -Pnative native:compile assumes a Maven profile named "native" exists. However, based on the plugin configuration shown earlier (lines 42-62), no profile is defined. The command should be mvn -Pnative-maven-plugin native:compile or simply mvn native:compile if the plugin execution is configured in the default build lifecycle. Consider clarifying which approach is being used or add the profile configuration if the -Pnative flag is intended.
| mvn -Pnative native:compile | |
| mvn native:compile |
|
|
||
| **Spring Boot (Maven):** | ||
| ```sh | ||
| mvn -Pnative spring-boot:build-image |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Maven command mvn -Pnative spring-boot:build-image assumes a Maven profile named "native" exists, but no such profile is shown in the earlier configuration examples. For Spring Boot 3.0+, the recommended approach is to use the Spring Boot Maven plugin with native image support built-in. Consider providing the profile configuration or using a more standard command like mvn spring-boot:build-image -Pnative with a corresponding native profile definition in the pom.xml.
| mvn -Pnative spring-boot:build-image | |
| mvn spring-boot:build-image -Dspring-boot.build-image.native=true |
| 5. **Container Image Build**: Use Quarkus container-image extensions: | ||
| ```properties | ||
| quarkus.native.container-build=true | ||
| quarkus.native.builder-image=mandrel |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quarkus.native.builder-image=mandrel configuration specifies a builder image name that's incomplete. The full image name should include a version tag, for example: quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 or similar. Without a full reference, this configuration may not work as expected.
| quarkus.native.builder-image=mandrel | |
| quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 |
| <plugin> | ||
| <groupId>org.graalvm.buildtools</groupId> | ||
| <artifactId>native-maven-plugin</artifactId> | ||
| <version>0.10.0</version> |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GraalVM Native Build Tools plugin version 0.10.0 should be verified. As of January 2025, this version may be outdated. Consider checking the latest version at https://graalvm.github.io/native-build-tools/latest/index.html and updating to ensure users get the most recent features and bug fixes.
| <version>0.10.0</version> | |
| <version>0.10.2</version> |
|
|
||
| Or register entire packages: | ||
| ```java | ||
| @RegisterForReflection(classNames = {"com.example.package.*"}) |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The classNames attribute for @RegisterForReflection doesn't support wildcard patterns like "com.example.package.*" in standard Quarkus. The wildcard syntax shown here won't work. Instead, users should either list individual classes or use the targets attribute with explicit class references, or register packages differently. Consider updating this example to show a valid approach.
| @RegisterForReflection(classNames = {"com.example.package.*"}) | |
| // Wildcards are NOT supported; list each class explicitly: | |
| @RegisterForReflection(classNames = {"com.example.package.Foo", "com.example.package.Bar"}) | |
| // Or, preferably, use the targets attribute with class references: | |
| @RegisterForReflection(targets = {com.example.package.Foo.class, com.example.package.Bar.class}) |
| {"pattern": ".*\\.yml"}, | ||
| {"pattern": ".*\\.yaml"} |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The regex pattern .*\\.yml and .*\\.yaml in the resource includes should be escaped properly in JSON. While the current format might work, the more standard JSON representation would use double backslashes: ".*\\\\.yml" and ".*\\\\.yaml" to ensure the pattern is correctly interpreted. However, if this is intended to be literal documentation that users will copy, single backslash is correct.
| {"pattern": ".*\\.yml"}, | |
| {"pattern": ".*\\.yaml"} | |
| {"pattern": ".*\\\\.yml"}, | |
| {"pattern": ".*\\\\.yaml"} |
| - Spring Boot 3.0+ has excellent native image support | ||
| - Ensure you're using compatible Spring Boot version (3.0+) |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Spring Boot version compatibility should be explicitly mentioned. The statement "Ensure you're using compatible Spring Boot version (3.0+)" is good, but consider being more specific about which Spring Boot versions are tested and recommended for native image support. For example, Spring Boot 3.2+ has enhanced native image capabilities.
| - Spring Boot 3.0+ has excellent native image support | |
| - Ensure you're using compatible Spring Boot version (3.0+) | |
| - Spring Boot 3.2+ is recommended for best native image support (with enhanced capabilities and improved compatibility) | |
| - Minimum required version is Spring Boot 3.0, but 3.2 or later is strongly advised |
| --- | ||
| description: 'GraalVM Native Image expert that adds native image support to Java applications, builds the project, analyzes build errors, applies fixes, and iterates until successful compilation using Oracle best practices.' | ||
| tools: | ||
| - read_file | ||
| - replace_string_in_file | ||
| - run_in_terminal | ||
| - list_dir | ||
| - grep_search | ||
| --- |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a model field to the front matter to specify the AI model this prompt is optimized for. According to repository conventions and the custom guidelines, it's strongly encouraged to specify the model. For example: model: 'Claude Sonnet 4' or model: 'gpt-4.1'. This helps users understand which model will provide the best results with this prompt.
aaronpowell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file needs to have a .prompt.md suffix so that it's treated as a prompt file and then run npm start to generate the README changes.
There's also a number of other comments from Copilot, I'm unsure how many are correct though
This fixes #447 from @SandraAhlgrimm
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.Description
Add support for GraalVM native image builds for Java projects.
Type of Contribution
Additional Notes
By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.