Skip to content

Commit 4a069aa

Browse files
committed
Remove obsolete AGENT_BUILD field
1 parent 0d3589e commit 4a069aa

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

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

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171

7272
import org.graalvm.compiler.options.OptionKey;
7373
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
74-
import org.graalvm.nativeimage.ImageInfo;
7574
import org.graalvm.nativeimage.Platform;
7675
import org.graalvm.nativeimage.ProcessProperties;
7776

@@ -1515,8 +1514,6 @@ protected Path createImageBuilderArgumentFile(List<String> imageBuilderArguments
15151514
}
15161515
}
15171516

1518-
private static final boolean AGENT_BUILD = ImageInfo.isSharedLibrary();
1519-
15201517
protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHashSet<Path> mp, ArrayList<String> imageArgs, LinkedHashSet<Path> imagecp,
15211518
LinkedHashSet<Path> imagemp) {
15221519
List<String> arguments = new ArrayList<>();
@@ -1544,49 +1541,36 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
15441541

15451542
Function<Path, Path> substituteModulePath = useBundle() ? bundleSupport::substituteModulePath : Function.identity();
15461543
List<Path> imageModulePath = imagemp.stream().map(substituteModulePath).collect(Collectors.toList());
1547-
List<Path> finalImageModulePath;
1548-
if (AGENT_BUILD) {
1549-
String unsupportedMsgTail = " is currently not supported in agent build mode";
1550-
if (!imageModulePath.isEmpty()) {
1551-
throw showError("Building modules into images" + unsupportedMsgTail);
1552-
}
1553-
if (!addModules.isEmpty()) {
1554-
throw showError("Using --add-modules" + unsupportedMsgTail);
1555-
}
1556-
finalImageModulePath = imageModulePath;
1557-
} else {
1558-
Map<String, Path> applicationModules = getModulesFromPath(imageModulePath);
1544+
Map<String, Path> applicationModules = getModulesFromPath(imageModulePath);
15591545

1560-
if (!applicationModules.isEmpty()) {
1561-
// Remove modules that we already have built-in
1562-
applicationModules.keySet().removeAll(getBuiltInModules());
1563-
// Remove modules that we get from the builder
1564-
applicationModules.keySet().removeAll(getModulesFromPath(mp).keySet());
1565-
}
1566-
finalImageModulePath = applicationModules.values().stream().toList();
1546+
if (!applicationModules.isEmpty()) {
1547+
// Remove modules that we already have built-in
1548+
applicationModules.keySet().removeAll(getBuiltInModules());
1549+
// Remove modules that we get from the builder
1550+
applicationModules.keySet().removeAll(getModulesFromPath(mp).keySet());
1551+
}
1552+
List<Path> finalImageModulePath = applicationModules.values().stream().toList();
15671553

1568-
if (!addModules.isEmpty()) {
1554+
if (!addModules.isEmpty()) {
15691555

1570-
arguments.add("-D" + ModuleSupport.PROPERTY_IMAGE_EXPLICITLY_ADDED_MODULES + "=" +
1571-
String.join(",", addModules));
1556+
arguments.add("-D" + ModuleSupport.PROPERTY_IMAGE_EXPLICITLY_ADDED_MODULES + "=" +
1557+
String.join(",", addModules));
15721558

1573-
List<String> addModulesForBuilderVM = new ArrayList<>();
1574-
for (String moduleNameInAddModules : addModules) {
1575-
if (!applicationModules.containsKey(moduleNameInAddModules)) {
1576-
/*
1577-
* Module names given to native-image --add-modules that are not referring
1578-
* to modules that are passed to native-image via -p/--module-path are
1579-
* considered to be part of the module-layer that contains the builder
1580-
* itself. Those module names need to be passed as --add-modules arguments
1581-
* to the builder VM.
1582-
*/
1583-
addModulesForBuilderVM.add(moduleNameInAddModules);
1584-
}
1559+
List<String> addModulesForBuilderVM = new ArrayList<>();
1560+
for (String moduleNameInAddModules : addModules) {
1561+
if (!applicationModules.containsKey(moduleNameInAddModules)) {
1562+
/*
1563+
* Module names given to native-image --add-modules that are not referring to
1564+
* modules that are passed to native-image via -p/--module-path are considered
1565+
* to be part of the module-layer that contains the builder itself. Those module
1566+
* names need to be passed as --add-modules arguments to the builder VM.
1567+
*/
1568+
addModulesForBuilderVM.add(moduleNameInAddModules);
15851569
}
1570+
}
15861571

1587-
if (!addModulesForBuilderVM.isEmpty()) {
1588-
arguments.add(DefaultOptionHandler.addModulesOption + "=" + String.join(",", addModulesForBuilderVM));
1589-
}
1572+
if (!addModulesForBuilderVM.isEmpty()) {
1573+
arguments.add(DefaultOptionHandler.addModulesOption + "=" + String.join(",", addModulesForBuilderVM));
15901574
}
15911575
}
15921576

0 commit comments

Comments
 (0)