Skip to content

Commit becbcf1

Browse files
committed
[GR-43506] [GR-43820] Native-Image API fixes.
PullRequest: graal/13527
2 parents 7c3cf83 + 8af50dd commit becbcf1

File tree

8 files changed

+45
-6
lines changed

8 files changed

+45
-6
lines changed

sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
1111
* Added automatic copying of language resources for embedding Truffle languages in native image. Documentation available [here](https://www.graalvm.org/reference-manual/embed-languages/#build-native-executables-from-polyglot-applications).
1212
* (GR-41716) Added `HostAccess.Builder.allowMutableTargetMappings(HostAccess.MutableTargetMapping[])` to explicitly enable type coercion from guest objects to mutable Java host objects such as `java.util.Map` or `java.util.List`.
1313
* (GR-42876) Added [FileSystem#newFileSystem](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/io/FileSystem.html#newFileSystem-java.nio.file.FileSystem-) creating a polyglot FileSystem for given Java NIO FileSystem.
14+
* (GR-43820) Deprecated `org.graalvm.nativeimage.RuntimeOptions#getOptions` methods and `org.graalvm.nativeimage.RuntimeOptions.OptionClass` enum. These elements were mistakenly made API and will be removed in a future version. If your codebase depends on any of these please let us know.
1415

1516
## Version 22.3.0
1617
* (GR-39852) Native Image API: Added FieldValueTransformer API

sdk/src/org.graalvm.nativeimage/snapshot.sigtest

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ meth public abstract void close() throws java.lang.Exception
99
CLSS public abstract interface java.lang.Comparable<%0 extends java.lang.Object>
1010
meth public abstract int compareTo({java.lang.Comparable%0})
1111

12+
CLSS public abstract interface !annotation java.lang.Deprecated
13+
anno 0 java.lang.annotation.Documented()
14+
anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
15+
anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE])
16+
intf java.lang.annotation.Annotation
17+
meth public abstract !hasdefault boolean forRemoval()
18+
meth public abstract !hasdefault java.lang.String since()
19+
1220
CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>>
1321
cons protected init(java.lang.String,int)
1422
innr public final static EnumDesc
@@ -434,12 +442,15 @@ CLSS public final org.graalvm.nativeimage.RuntimeOptions
434442
innr public final static !enum OptionClass
435443
meth public static <%0 extends java.lang.Object> {%%0} get(java.lang.String)
436444
meth public static org.graalvm.options.OptionDescriptors getOptions()
445+
anno 0 java.lang.Deprecated(boolean forRemoval=true, java.lang.String since="23.0")
437446
meth public static org.graalvm.options.OptionDescriptors getOptions(java.util.EnumSet<org.graalvm.nativeimage.RuntimeOptions$OptionClass>)
447+
anno 0 java.lang.Deprecated(boolean forRemoval=true, java.lang.String since="23.0")
438448
meth public static void set(java.lang.String,java.lang.Object)
439449
supr java.lang.Object
440450

441451
CLSS public final static !enum org.graalvm.nativeimage.RuntimeOptions$OptionClass
442452
outer org.graalvm.nativeimage.RuntimeOptions
453+
anno 0 java.lang.Deprecated(boolean forRemoval=true, java.lang.String since="23.0")
443454
fld public final static org.graalvm.nativeimage.RuntimeOptions$OptionClass Compiler
444455
fld public final static org.graalvm.nativeimage.RuntimeOptions$OptionClass VM
445456
meth public static org.graalvm.nativeimage.RuntimeOptions$OptionClass valueOf(java.lang.String)

sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/RuntimeOptions.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -74,10 +74,14 @@ public static <T> T get(String optionName) {
7474
}
7575

7676
/**
77-
* Classes of options that can be queried through {@link #getOptions(EnumSet)}.
77+
* Classes of options that can be queried through {@code getOptions(EnumSet)}.
78+
*
79+
* @deprecated This class was mistakenly made API and will be removed in a future version. If
80+
* your codebase depends on it, let us know by creating an issue on GitHub.
7881
*
7982
* @since 19.0
8083
*/
84+
@Deprecated(since = "23.0", forRemoval = true)
8185
public enum OptionClass {
8286
VM,
8387
Compiler
@@ -86,17 +90,27 @@ public enum OptionClass {
8690
/**
8791
* Returns available run time options for the selected {@linkplain OptionClass option classes}.
8892
*
93+
* @deprecated This method was mistakenly made an API method and will be removed in a future
94+
* version. If your codebase depends on it, let us know by creating an issue on
95+
* GitHub.
96+
*
8997
* @since 19.0
9098
*/
99+
@Deprecated(since = "23.0", forRemoval = true)
91100
public static OptionDescriptors getOptions(EnumSet<OptionClass> classes) {
92101
return ImageSingletons.lookup(RuntimeOptionsSupport.class).getOptions(classes);
93102
}
94103

95104
/**
96105
* Returns all available run time options.
97106
*
107+
* @deprecated This method was mistakenly made an API method and will be removed in a future
108+
* version. If your codebase depends on it, let us know by creating an issue on
109+
* GitHub.
110+
*
98111
* @since 19.0
99112
*/
113+
@Deprecated(since = "23.0", forRemoval = true)
100114
public static OptionDescriptors getOptions() {
101115
return getOptions(EnumSet.allOf(OptionClass.class));
102116
}

sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/hosted/RuntimeSystemProperties.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -45,6 +45,12 @@
4545
import org.graalvm.nativeimage.ImageSingletons;
4646
import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport;
4747

48+
/**
49+
* This class provides methods that can be called during native image generation to define system
50+
* property setting for image runtime.
51+
*
52+
* @since 23.0
53+
*/
4854
public final class RuntimeSystemProperties {
4955

5056
/**

sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeOptionsSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -50,5 +50,6 @@ public interface RuntimeOptionsSupport {
5050

5151
<T> T get(String optionName);
5252

53+
@SuppressWarnings("deprecation")
5354
OptionDescriptors getOptions(EnumSet<OptionClass> classes);
5455
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,12 @@ public void setProperties(Properties props) {
202202
*/
203203
@Override
204204
public void initializeProperty(String key, String value) {
205+
initializeProperty(key, value, true);
206+
}
207+
208+
public void initializeProperty(String key, String value, boolean strict) {
205209
String prevValue = savedProperties.put(key, value);
206-
if (prevValue != null && !prevValue.equals(value)) {
210+
if (strict && prevValue != null && !prevValue.equals(value)) {
207211
VMError.shouldNotReachHere("System property " + key + " is initialized to " + value + " but was previously initialized to " + prevValue + ".");
208212
}
209213
properties.setProperty(key, value);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public <T> T get(String optionName) {
113113
return optionKey.getValue(RuntimeOptionValues.singleton());
114114
}
115115

116+
@SuppressWarnings({"unchecked", "deprecation"})
116117
@Override
117118
public OptionDescriptors getOptions(EnumSet<OptionClass> classes) {
118119
Iterable<OptionDescriptor> descriptors = RuntimeOptionParser.singleton().getDescriptors();
@@ -134,6 +135,7 @@ public OptionDescriptors getOptions(EnumSet<OptionClass> classes) {
134135
return OptionDescriptors.create(graalvmDescriptors);
135136
}
136137

138+
@SuppressWarnings("deprecation")
137139
private static OptionClass getOptionClass(OptionDescriptor descriptor) {
138140
if (descriptor.getOptionKey() instanceof RuntimeOptionKey) {
139141
return OptionClass.VM;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/properties/RuntimePropertyParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static String[] parse(String[] args) {
5656
}
5757
MapCursor<String, String> cursor = properties.getEntries();
5858
while (cursor.advance()) {
59-
SystemPropertiesSupport.singleton().initializeProperty(cursor.getKey(), cursor.getValue());
59+
SystemPropertiesSupport.singleton().initializeProperty(cursor.getKey(), cursor.getValue(), false);
6060
}
6161
if (newIdx == args.length) {
6262
/* We can be allocation free and just return the original arguments. */

0 commit comments

Comments
 (0)