|
71 | 71 |
|
72 | 72 | import org.graalvm.compiler.options.OptionKey; |
73 | 73 | import org.graalvm.compiler.serviceprovider.JavaVersionUtil; |
74 | | -import org.graalvm.nativeimage.ImageInfo; |
75 | 74 | import org.graalvm.nativeimage.Platform; |
76 | 75 | import org.graalvm.nativeimage.ProcessProperties; |
77 | 76 |
|
@@ -1515,8 +1514,6 @@ protected Path createImageBuilderArgumentFile(List<String> imageBuilderArguments |
1515 | 1514 | } |
1516 | 1515 | } |
1517 | 1516 |
|
1518 | | - private static final boolean AGENT_BUILD = ImageInfo.isSharedLibrary(); |
1519 | | - |
1520 | 1517 | protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHashSet<Path> mp, ArrayList<String> imageArgs, LinkedHashSet<Path> imagecp, |
1521 | 1518 | LinkedHashSet<Path> imagemp) { |
1522 | 1519 | List<String> arguments = new ArrayList<>(); |
@@ -1544,49 +1541,36 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa |
1544 | 1541 |
|
1545 | 1542 | Function<Path, Path> substituteModulePath = useBundle() ? bundleSupport::substituteModulePath : Function.identity(); |
1546 | 1543 | 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); |
1559 | 1545 |
|
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(); |
1567 | 1553 |
|
1568 | | - if (!addModules.isEmpty()) { |
| 1554 | + if (!addModules.isEmpty()) { |
1569 | 1555 |
|
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)); |
1572 | 1558 |
|
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); |
1585 | 1569 | } |
| 1570 | + } |
1586 | 1571 |
|
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)); |
1590 | 1574 | } |
1591 | 1575 | } |
1592 | 1576 |
|
|
0 commit comments