Skip to content
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

Add requiresClassesResolvableAtBuildTime flag #25528

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public class NativeConfig {
@ConfigItem(defaultValue = "true")
public boolean enableHttpUrlHandler;

/**
* Requires all classes to be resolvable at build.
*
* Adds {@code --link-at-build-time} flag in GraalVM versions equal or greater than 22.0.0.2, otherwise adds
* {@code --allow-incomplete-classpath} flag.
*/
@ConfigItem(defaultValue = "true")
public boolean requiresClassesResolvableAtBuildTime;

/**
* If the HTTPS url handler should be enabled, allowing you to do URL.openConnection() for HTTPS URLs
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,12 @@ public NativeImageInvokerInfo build() {

// 22.1 removes --allow-incomplete-classpath and makes it the default. --link-at-build-time is now
// needed to bring back the old behavior (which requires all classes to be resolvable at build time).
if (graalVMVersion.isNewerThan(GraalVM.Version.VERSION_22_0_0_2) && !classpathIsBroken) {
nativeImageArgs.add("--link-at-build-time");
} else if (!graalVMVersion.isNewerThan(GraalVM.Version.VERSION_22_0_0_2) && classpathIsBroken) {
nativeImageArgs.add("--allow-incomplete-classpath");
if (nativeConfig.requiresClassesResolvableAtBuildTime){
if (graalVMVersion.isNewerThan(GraalVM.Version.VERSION_22_0_0_2) && !classpathIsBroken) {
nativeImageArgs.add("--link-at-build-time");
} else if (!graalVMVersion.isNewerThan(GraalVM.Version.VERSION_22_0_0_2) && classpathIsBroken) {
nativeImageArgs.add("--allow-incomplete-classpath");
}
}

if (nativeConfig.reportErrorsAtRuntime) {
Expand Down