Skip to content

[GR-62633] Preserve all "optimized-out" JDK components. #11612

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

Merged
merged 1 commit into from
Jul 17, 2025
Merged
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 @@ -25,15 +25,23 @@
package com.oracle.svm.hosted.image;

import static com.oracle.graal.pointsto.api.PointstoOptions.UseConservativeUnsafeAccess;
import static com.oracle.svm.core.SubstrateOptions.EnableURLProtocols;
import static com.oracle.svm.core.SubstrateOptions.Preserve;
import static com.oracle.svm.core.jdk.JRTSupport.Options.AllowJRTFileSystem;
import static com.oracle.svm.hosted.SecurityServicesFeature.Options.AdditionalSecurityProviders;
import static com.oracle.svm.hosted.jdk.localization.LocalizationFeature.Options.AddAllCharsets;
import static com.oracle.svm.hosted.jdk.localization.LocalizationFeature.Options.IncludeAllLocales;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Stream;

import org.graalvm.collections.EconomicMap;
Expand Down Expand Up @@ -137,7 +145,23 @@ public static void parsePreserveOption(EconomicMap<OptionKey<?>, Object> hostedV
SubstrateOptionsParser.commandArgument(UseConservativeUnsafeAccess, "-"));
}
UseConservativeUnsafeAccess.update(hostedValues, true);

AddAllCharsets.update(hostedValues, true);
IncludeAllLocales.update(hostedValues, true);
AllowJRTFileSystem.update(hostedValues, true);
EnableURLProtocols.update(hostedValues, "http,https,ftp,jar,file,mailto,jrt,jmod");
AdditionalSecurityProviders.update(hostedValues, getSecurityProvidersCSV());
}
}

private static String getSecurityProvidersCSV() {
StringJoiner joiner = new StringJoiner(",");
for (Provider provider : Security.getProviders()) {
Class<? extends Provider> aClass = provider.getClass();
String typeName = aClass.getTypeName();
joiner.add(typeName);
}
return joiner.toString();
}

public static void registerPreservedClasses(NativeImageClassLoaderSupport classLoaderSupport) {
Expand Down
Loading