Skip to content

Commit 604d2e1

Browse files
committed
[GR-36905] Implement --link-at-build-time and @<prop-values-file>.
PullRequest: graal/11033
2 parents 9d941ab + 1655cb2 commit 604d2e1

File tree

44 files changed

+956
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+956
-264
lines changed

sdk/mx.sdk/mx_sdk_vm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def add_relative_home_path(self, language, path):
159159
class LauncherConfig(AbstractNativeImageConfig):
160160
def __init__(self, destination, jar_distributions, main_class, build_args, is_main_launcher=True,
161161
default_symlinks=True, is_sdk_launcher=False, custom_launcher_script=None, extra_jvm_args=None,
162-
use_modules=None, main_module=None, option_vars=None, home_finder=True, **kwargs):
162+
use_modules=None, main_module=None, link_at_build_time=True, option_vars=None, home_finder=True, **kwargs):
163163
"""
164164
:param str main_class
165165
:param bool is_main_launcher
@@ -174,6 +174,7 @@ def __init__(self, destination, jar_distributions, main_class, build_args, is_ma
174174
self.main_module = main_module
175175
assert self.use_modules is None or self.main_module
176176
self.main_class = main_class
177+
self.link_at_build_time = link_at_build_time
177178
self.is_main_launcher = is_main_launcher
178179
self.default_symlinks = default_symlinks
179180
self.is_sdk_launcher = is_sdk_launcher

sdk/mx.sdk/mx_sdk_vm_impl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,8 @@ def contents(self):
12561256
build_args += ['-ea', '-H:-AOTInline', '-H:+PreserveFramePointer', '-H:-DeleteLocalSymbols']
12571257
if _get_svm_support().is_debug_supported():
12581258
build_args += ['-g']
1259+
if getattr(image_config, 'link_at_build_time', True):
1260+
build_args += ['--link-at-build-time']
12591261

12601262
graalvm_dist = get_final_graalvm_distribution()
12611263
graalvm_location = dirname(graalvm_dist.find_single_source_location('dependency:' + self.subject.name))

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This changelog summarizes major changes to GraalVM Native Image.
88
* Remove support for JDK8. As a result, `JDK8OrEarlier` and `JDK11OrLater` have been deprecated and will be removed in a future release.
99
* (GR-26814) (GR-37018) (GR-37038) Red Hat added support for the following JFR events: `SafepointBegin`, `SafepointEnd`, `GarbageCollection`, `GCPhasePause`, and `GCPhasePauseLevel*`. All GC-related JFR events are currently limited to the serial GC.
1010
* (GR-35721) Deprecate `-H:±BuildOutputUseNewStyle` option. The old build output style will be removed in a future release.
11+
* (GR-36905) Allow incomplete classes at build-time is now default. Add --link-at-build-time option and @<prop-values-file> support for native-image.properties. Add --link-at-build-time-paths option.
1112

1213
## Version 22.0.0
1314
* (GR-33930) Decouple HostedOptionParser setup from classpath/modulepath scanning (use ServiceLoader for collecting options).

substratevm/mx.substratevm/macro-junit.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ ImageClasspath = ${.}/junit-tool.jar:${.}/junit.jar:${.}/hamcrest.jar
88
Args = -H:Features=com.oracle.svm.junit.JUnitFeature \
99
-H:Class=com.oracle.svm.junit.SVMJUnitRunner \
1010
-H:TestFile=${*} \
11-
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest
11+
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest \
12+

substratevm/mx.substratevm/macro-junitcp.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ ImageClasspath = ${.}/junit-support.jar:${.}/junit-tool.jar:${.}/junit.jar:${.}/
77
Args = -H:Features=com.oracle.svm.junit.JUnitFeature \
88
-H:Class=com.oracle.svm.junit.SVMJUnitRunner \
99
-H:TestFile=${*} \
10-
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest
10+
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest \
11+

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@
16031603
"description" : "Native-image based junit testing support",
16041604
"layout" : {
16051605
"native-image.properties" : "file:mx.substratevm/macro-junit.properties",
1606+
"svm-junit.packages" : "file:mx.substratevm/svm-junit.packages",
16061607
},
16071608
},
16081609

@@ -1611,6 +1612,7 @@
16111612
"description" : "Native-image based junit testing support but with running image-builder on classpath",
16121613
"layout" : {
16131614
"native-image.properties" : "file:mx.substratevm/macro-junitcp.properties",
1615+
"svm-junit.packages" : "file:mx.substratevm/svm-junit.packages",
16141616
},
16151617
},
16161618

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
com.oracle.mxtool.junit
2+
junit.framework
3+
junit.runner
4+
org.hamcrest
5+
org.hamcrest.core
6+
org.hamcrest.internal
7+
org.junit
8+
org.junit.internal
9+
org.junit.internal.builders
10+
org.junit.internal.runners.model
11+
org.junit.internal.runners.statements
12+
org.junit.rules
13+
org.junit.runner
14+
org.junit.runner.manipulation
15+
org.junit.runner.notification
16+
org.junit.runners
17+
org.junit.runners.model
18+
org.junit.validator

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,18 @@ public final class ReflectionConfigurationParser<T> extends ConfigurationParser
4747
private static final String CONSTRUCTOR_NAME = "<init>";
4848

4949
private final ReflectionConfigurationParserDelegate<T> delegate;
50-
private final boolean allowIncompleteClasspath;
5150
private static final List<String> OPTIONAL_REFLECT_CONFIG_OBJECT_ATTRS = Arrays.asList("allDeclaredConstructors", "allPublicConstructors",
5251
"allDeclaredMethods", "allPublicMethods", "allDeclaredFields", "allPublicFields",
5352
"allDeclaredClasses", "allPermittedSubclasses", "allPublicClasses", "methods", "queriedMethods", "fields", CONDITIONAL_KEY,
5453
"queryAllDeclaredConstructors", "queryAllPublicConstructors", "queryAllDeclaredMethods", "queryAllPublicMethods");
5554

5655
public ReflectionConfigurationParser(ReflectionConfigurationParserDelegate<T> delegate) {
57-
this(delegate, false, true);
56+
this(delegate, true);
5857
}
5958

60-
public ReflectionConfigurationParser(ReflectionConfigurationParserDelegate<T> delegate, boolean allowIncompleteClasspath, boolean strictConfiguration) {
59+
public ReflectionConfigurationParser(ReflectionConfigurationParserDelegate<T> delegate, boolean strictConfiguration) {
6160
super(strictConfiguration);
6261
this.delegate = delegate;
63-
this.allowIncompleteClasspath = allowIncompleteClasspath;
6462
}
6563

6664
@Override
@@ -282,19 +280,15 @@ private String formatMethod(T clazz, String methodName, List<T> paramTypes) {
282280
return delegate.getTypeName(clazz) + '.' + methodName + '(' + parameterTypeNames + ')';
283281
}
284282

285-
private void handleError(String message) {
283+
private static void handleError(String message) {
286284
handleError(message, null);
287285
}
288286

289-
private void handleError(String msg, Throwable cause) {
287+
private static void handleError(String msg, Throwable cause) {
290288
String message = msg;
291289
if (cause != null) {
292290
message += " Reason: " + formatError(cause) + '.';
293291
}
294-
if (allowIncompleteClasspath) {
295-
System.err.println("Warning: " + message);
296-
} else {
297-
throw new JSONParserException(message + " To allow unresolvable reflection configuration, use option --allow-incomplete-classpath");
298-
}
292+
System.err.println("Warning: " + message);
299293
}
300294
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/LocatableMultiOptionValue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
import java.util.stream.Collectors;
3030
import java.util.stream.Stream;
3131

32-
import com.oracle.svm.common.option.LocatableOption;
33-
import com.oracle.svm.common.option.MultiOptionValue;
3432
import org.graalvm.collections.Pair;
3533

34+
import com.oracle.svm.common.option.LocatableOption;
35+
import com.oracle.svm.common.option.MultiOptionValue;
3636
import com.oracle.svm.core.util.VMError;
3737
import com.oracle.svm.util.ClassUtil;
3838

@@ -76,8 +76,8 @@ public List<T> values() {
7676
return values.stream().map(Pair::getLeft).collect(Collectors.toList());
7777
}
7878

79-
public Stream<Pair<T, String>> getValuesWithOrigins() {
80-
return values.stream();
79+
public Stream<Pair<T, OptionOrigin>> getValuesWithOrigins() {
80+
return values.stream().map(pair -> Pair.create(pair.getLeft(), OptionOrigin.from(pair.getRight())));
8181
}
8282

8383
@Override

0 commit comments

Comments
 (0)