Skip to content

Commit e8e2ec0

Browse files
committed
[GR-45130] Replace --enable-experimental-bundle-support with a warning.
PullRequest: graal/14139
2 parents 1ec172b + 0cf0481 commit e8e2ec0

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ final class BundleSupport {
8888
Map<Path, Path> pathCanonicalizations = new HashMap<>();
8989
Map<Path, Path> pathSubstitutions = new HashMap<>();
9090

91+
private final boolean forceBuilderOnClasspath;
9192
private final List<String> nativeImageArgs;
9293
private List<String> updatedNativeImageArgs;
9394

@@ -97,7 +98,7 @@ final class BundleSupport {
9798
private static final int BUNDLE_FILE_FORMAT_VERSION_MAJOR = 0;
9899
private static final int BUNDLE_FILE_FORMAT_VERSION_MINOR = 9;
99100

100-
private static final String BUNDLE_INFO_MESSAGE_PREFIX = "GraalVM Native Image Bundle Support: ";
101+
private static final String BUNDLE_INFO_MESSAGE_PREFIX = "Native Image Bundles: ";
101102
private static final String BUNDLE_TEMP_DIR_PREFIX = "bundleRoot-";
102103
private static final String ORIGINAL_DIR_EXTENSION = ".orig";
103104

@@ -106,9 +107,6 @@ final class BundleSupport {
106107

107108
private final BundleProperties bundleProperties;
108109

109-
static boolean allowBundleSupport;
110-
static final String UNLOCK_BUNDLE_SUPPORT_OPTION = "--enable-experimental-bundle-support";
111-
112110
static final String BUNDLE_OPTION = "--bundle";
113111
static final String BUNDLE_FILE_EXTENSION = ".nib";
114112

@@ -122,11 +120,6 @@ String optionName() {
122120
}
123121

124122
static BundleSupport create(NativeImage nativeImage, String bundleArg, NativeImage.ArgumentQueue args) {
125-
if (!allowBundleSupport) {
126-
throw NativeImage.showError(
127-
"Bundle support is still experimental and needs to be unlocked with '" + UNLOCK_BUNDLE_SUPPORT_OPTION + "'. The unlock option must precede '" + bundleArg + "'.");
128-
}
129-
130123
try {
131124
String variant = bundleArg.substring(BUNDLE_OPTION.length() + 1);
132125
String bundleFilename = null;
@@ -211,7 +204,8 @@ private BundleSupport(NativeImage nativeImage) {
211204
} catch (IOException e) {
212205
throw NativeImage.showError("Unable to create bundle directory layout", e);
213206
}
214-
this.nativeImageArgs = nativeImage.getNativeImageArgs();
207+
forceBuilderOnClasspath = !nativeImage.config.modulePathBuild;
208+
nativeImageArgs = nativeImage.getNativeImageArgs();
215209
}
216210

217211
private BundleSupport(NativeImage nativeImage, String bundleFilenameArg) {
@@ -262,6 +256,8 @@ private BundleSupport(NativeImage nativeImage, String bundleFilenameArg) {
262256
}
263257

264258
bundleProperties.loadAndVerify();
259+
forceBuilderOnClasspath = bundleProperties.forceBuilderOnClasspath();
260+
nativeImage.config.modulePathBuild = !forceBuilderOnClasspath;
265261

266262
try {
267263
Path inputDir = rootDir.resolve("input");
@@ -615,7 +611,7 @@ private Path writeBundle() {
615611

616612
Path buildArgsFile = stageDir.resolve("build.json");
617613
try (JsonWriter writer = new JsonWriter(buildArgsFile)) {
618-
List<String> equalsNonBundleOptions = List.of(UNLOCK_BUNDLE_SUPPORT_OPTION, CmdLineOptionHandler.VERBOSE_OPTION, CmdLineOptionHandler.DRY_RUN_OPTION);
614+
List<String> equalsNonBundleOptions = List.of(CmdLineOptionHandler.VERBOSE_OPTION, CmdLineOptionHandler.DRY_RUN_OPTION);
619615
List<String> startsWithNonBundleOptions = List.of(BUNDLE_OPTION, DefaultOptionHandler.ADD_ENV_VAR_OPTION, nativeImage.oHPath);
620616
ArrayList<String> bundleArgs = new ArrayList<>(updatedNativeImageArgs != null ? updatedNativeImageArgs : nativeImageArgs);
621617
ListIterator<String> bundleArgsIterator = bundleArgs.listIterator();
@@ -772,6 +768,7 @@ private final class BundleProperties {
772768
private static final String PROPERTY_KEY_BUNDLE_FILE_VERSION_MAJOR = "BundleFileVersionMajor";
773769
private static final String PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR = "BundleFileVersionMinor";
774770
private static final String PROPERTY_KEY_BUNDLE_FILE_CREATION_TIMESTAMP = "BundleFileCreationTimestamp";
771+
private static final String PROPERTY_KEY_BUILDER_ON_CLASSPATH = "BuilderOnClasspath";
775772
private static final String PROPERTY_KEY_IMAGE_BUILT = "ImageBuilt";
776773
private static final String PROPERTY_KEY_BUILT_WITH_CONTAINER = "BuiltWithContainer";
777774
private static final String PROPERTY_KEY_NATIVE_IMAGE_PLATFORM = "NativeImagePlatform";
@@ -840,10 +837,16 @@ private void loadAndVerify() {
840837
bundlePlatform, currentPlatform);
841838
}
842839

840+
private boolean forceBuilderOnClasspath() {
841+
assert !properties.isEmpty() : "Needs to be called after loadAndVerify()";
842+
return Boolean.parseBoolean(properties.getOrDefault(PROPERTY_KEY_BUILDER_ON_CLASSPATH, Boolean.FALSE.toString()));
843+
}
844+
843845
private void write() {
844846
properties.put(PROPERTY_KEY_BUNDLE_FILE_VERSION_MAJOR, String.valueOf(BUNDLE_FILE_FORMAT_VERSION_MAJOR));
845847
properties.put(PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR, String.valueOf(BUNDLE_FILE_FORMAT_VERSION_MINOR));
846848
properties.put(PROPERTY_KEY_BUNDLE_FILE_CREATION_TIMESTAMP, ZonedDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
849+
properties.put(PROPERTY_KEY_BUILDER_ON_CLASSPATH, String.valueOf(forceBuilderOnClasspath));
847850
boolean imageBuilt = !nativeImage.isDryRun();
848851
properties.put(PROPERTY_KEY_IMAGE_BUILT, String.valueOf(imageBuilt));
849852
if (imageBuilt) {

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/CmdLineOptionHandler.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ private boolean consume(ArgumentQueue args, String headArg) {
141141
String optionNames = args.poll();
142142
nativeImage.setPrintFlagsWithExtraHelpOptionQuery(optionNames);
143143
return true;
144-
case BundleSupport.UNLOCK_BUNDLE_SUPPORT_OPTION:
145-
args.poll();
146-
BundleSupport.allowBundleSupport = true;
147-
return true;
148144
case VERBOSE_SERVER_OPTION:
149145
args.poll();
150146
NativeImage.showWarning("Ignoring server-mode native-image argument " + headArg + ".");

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,10 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
14401440
arguments.addAll(Arrays.asList(SubstrateOptions.WATCHPID_PREFIX, "" + ProcessProperties.getProcessID()));
14411441
}
14421442

1443+
if (useBundle()) {
1444+
showWarning("Native Image Bundles are an experimental feature.");
1445+
}
1446+
14431447
BiFunction<Path, BundleMember.Role, Path> substituteAuxiliaryPath = useBundle() ? bundleSupport::substituteAuxiliaryPath : (a, b) -> a;
14441448
Function<String, String> imageArgsTransformer = rawArg -> apiOptionHandler.transformBuilderArgument(rawArg, substituteAuxiliaryPath);
14451449
List<String> finalImageArgs = imageArgs.stream().map(imageArgsTransformer).collect(Collectors.toList());

0 commit comments

Comments
 (0)