Skip to content
Merged
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 @@ -147,13 +147,13 @@ public void clearDynamicAccessSelectors() {
}

public boolean isPreserveMode() {
return !preserveSelectors.classpathEntries.isEmpty() || !preserveSelectors.moduleNames.isEmpty() || !preserveSelectors.packages.isEmpty() || preserveAll();
return !preserveSelectors.classpathEntries.isEmpty() || !preserveSelectors.moduleNames.isEmpty() || !preserveSelectors.packages.isEmpty() || isPreserveAll();
}

/**
* @return true if {@link PreserveOptionsSupport#PRESERVE_ALL preserve all} is enabled.
*/
private boolean preserveAll() {
public boolean isPreserveAll() {
return preserveAllOrigin().isPresent();
}

Expand Down Expand Up @@ -312,7 +312,7 @@ private ModuleFinder getModulePathsFinder() {
public void loadAllClasses(ForkJoinPool executor, ImageClassLoader imageClassLoader) {
VMError.guarantee(!includeConfigSealed, "This method should be executed only once.");

if (preserveAll()) {
if (isPreserveAll()) {
String msg = """
This image build includes all classes from the classpath and the JDK via the %s option. This will lead to noticeably bigger images and increased startup times.
If you notice '--initialize-at-build-time' related errors during the build, this is because unanticipated types ended up in the image heap.\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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.core.metadata.MetadataTracer.Options.MetadataTracingSupport;
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;
Expand All @@ -40,6 +41,7 @@
import java.security.Security;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Stream;
Expand Down Expand Up @@ -140,19 +142,32 @@ public static void parsePreserveOption(EconomicMap<OptionKey<?>, Object> hostedV
}
});
if (classLoaderSupport.isPreserveMode()) {
/* Significantly speeds up analysis */
if (UseConservativeUnsafeAccess.hasBeenSet(optionValues)) {
UserError.guarantee(UseConservativeUnsafeAccess.getValue(optionValues), "%s can not be used together with %s. Please unset %s.",
SubstrateOptionsParser.commandArgument(UseConservativeUnsafeAccess, "-"),
SubstrateOptionsParser.commandArgument(Preserve, "<value>"),
SubstrateOptionsParser.commandArgument(UseConservativeUnsafeAccess, "-"));
}
UseConservativeUnsafeAccess.update(hostedValues, true);
}

if (classLoaderSupport.isPreserveAll()) {
/* Include all parts of native image that are stripped */
AddAllCharsets.update(hostedValues, true);
IncludeAllLocales.update(hostedValues, true);
AllowJRTFileSystem.update(hostedValues, true);
EnableURLProtocols.update(hostedValues, "http,https,ftp,jar,file,mailto,jrt,jmod");

/* Should be removed with GR-61365 */
var missingJDKProtocols = List.of("http", "https", "ftp", "jar", "mailto", "jrt", "jmod");
for (String missingProtocol : missingJDKProtocols) {
EnableURLProtocols.update(hostedValues, missingProtocol);
}

AdditionalSecurityProviders.update(hostedValues, getSecurityProvidersCSV());

/* Allow metadata tracing in preserve all images */
MetadataTracingSupport.update(hostedValues, true);
}
}

Expand Down