From 9e2c6e7629eeb2a50550be6dea17ec81a2dd09ff Mon Sep 17 00:00:00 2001
From: Loic Ottet
Date: Tue, 27 Aug 2024 14:41:50 +0200
Subject: [PATCH] Adapt configuration parser to 23.1
---
.../test/config/OmitPreviousConfigTests.java | 4 +-
.../config/ResourceConfigurationTest.java | 4 +-
.../svm/configure/ConfigurationBase.java | 7 +-
.../config/ConfigurationFileCollection.java | 70 +++++--
.../configure/config/ConfigurationSet.java | 9 +-
.../config/ParserConfigurationAdapter.java | 58 +++---
.../PredefinedClassesConfiguration.java | 8 +-
.../configure/config/ProxyConfiguration.java | 12 +-
.../config/ResourceConfiguration.java | 8 +-
.../config/SerializationConfiguration.java | 8 +-
.../configure/config/TypeConfiguration.java | 16 +-
.../PartialConfigurationWithOrigins.java | 6 +-
.../configure/ConditionalRuntimeValue.java | 69 ------
.../ConfigurationConditionResolver.java | 18 +-
.../core/configure/ConfigurationFiles.java | 108 +++-------
.../core/configure/ConfigurationParser.java | 65 +++---
.../ConfigurationTypeDescriptor.java | 2 +-
.../LegacyReflectionConfigurationParser.java | 14 +-
.../LegacyResourceConfigurationParser.java | 55 ++++-
...egacySerializationConfigurationParser.java | 31 ++-
.../NamedConfigurationTypeDescriptor.java | 2 +-
.../configure/ProxyConfigurationParser.java | 28 ++-
.../ProxyConfigurationTypeDescriptor.java | 5 +-
.../ReflectionConfigurationParser.java | 31 ++-
...ReflectionConfigurationParserDelegate.java | 46 ++--
.../configure/ReflectionMetadataParser.java | 14 +-
.../ResourceConfigurationParser.java | 140 ++++++++-----
.../configure/ResourceMetadataParser.java | 12 +-
.../svm/core/configure/ResourcesRegistry.java | 43 +++-
.../core/configure/RuntimeConditionSet.java | 197 ------------------
.../SerializationConfigurationParser.java | 23 +-
.../SerializationMetadataParser.java | 8 +-
.../ReflectionConfigurationFilesHelp.txt | 2 +-
.../SerializationConfigurationFilesHelp.txt | 2 +-
.../core/jdk/proxy/DynamicProxyRegistry.java | 2 +-
...java_lang_invoke_MethodHandles_Lookup.java | 7 +
.../reflect/proxy/DynamicProxySupport.java | 6 +-
.../ConditionalConfigurationRegistry.java | 4 +-
.../oracle/svm/hosted/ResourcesFeature.java | 12 +-
.../config/ConfigurationParserUtils.java | 14 +-
.../config/ReflectionRegistryAdapter.java | 80 +++----
.../svm/hosted/config/RegistryAdapter.java | 153 ++++++++------
.../svm/hosted/jni/JNIAccessFeature.java | 17 +-
.../svm/hosted/reflect/ReflectionFeature.java | 14 +-
.../reflect/proxy/DynamicProxyFeature.java | 4 +-
.../hosted/reflect/proxy/ProxyRegistry.java | 2 +-
.../serialize/SerializationFeature.java | 15 +-
47 files changed, 693 insertions(+), 762 deletions(-)
delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConditionalRuntimeValue.java
delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/RuntimeConditionSet.java
diff --git a/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/OmitPreviousConfigTests.java b/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/OmitPreviousConfigTests.java
index 38c5440b0fe..6c70847ea12 100644
--- a/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/OmitPreviousConfigTests.java
+++ b/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/OmitPreviousConfigTests.java
@@ -229,8 +229,8 @@ class TypeMethodsWithFlagsTest {
final Map methodsThatMustExist = new HashMap<>();
final Map methodsThatMustNotExist = new HashMap<>();
- final TypeConfiguration previousConfig = new TypeConfiguration();
- final TypeConfiguration currentConfig = new TypeConfiguration();
+ final TypeConfiguration previousConfig = new TypeConfiguration("");
+ final TypeConfiguration currentConfig = new TypeConfiguration("");
TypeMethodsWithFlagsTest(ConfigurationMemberDeclaration methodKind) {
this.methodKind = methodKind;
diff --git a/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/ResourceConfigurationTest.java b/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/ResourceConfigurationTest.java
index 600b21440bb..edb48f64a3b 100644
--- a/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/ResourceConfigurationTest.java
+++ b/substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/ResourceConfigurationTest.java
@@ -38,9 +38,9 @@
import org.junit.Test;
import com.oracle.svm.configure.config.ResourceConfiguration;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ResourceConfigurationParser;
import com.oracle.svm.core.configure.ResourcesRegistry;
+import com.oracle.svm.core.util.json.JsonWriter;
public class ResourceConfigurationTest {
@@ -117,7 +117,7 @@ public void addClassBasedResourceBundle(ConfigurationCondition condition, String
}
};
- ResourceConfigurationParser rcp = new ResourceConfigurationParser(registry, true);
+ ResourceConfigurationParser rcp = ResourceConfigurationParser.create(false, registry, true);
writerThread.start();
rcp.parseAndRegister(pr);
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationBase.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationBase.java
index 26a7c7a596d..25962c52983 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationBase.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationBase.java
@@ -26,10 +26,11 @@
import java.util.function.Consumer;
-import com.oracle.svm.core.util.json.JsonPrintable;
-import com.oracle.svm.core.configure.ConfigurationParser;
import org.graalvm.nativeimage.impl.ConfigurationCondition;
+import com.oracle.svm.core.configure.ConfigurationParser;
+import com.oracle.svm.core.util.json.JsonPrintable;
+
public abstract class ConfigurationBase, P> implements JsonPrintable {
public abstract boolean isEmpty();
@@ -68,5 +69,5 @@ public T copyAndFilter(P predicate) {
return copyAnd(copy -> copy.removeIf(predicate));
}
- public abstract ConfigurationParser createParser();
+ public abstract ConfigurationParser createParser(boolean strictMetadata);
}
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationFileCollection.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationFileCollection.java
index fbc031bc840..cf2fc9046ad 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationFileCollection.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationFileCollection.java
@@ -24,10 +24,14 @@
*/
package com.oracle.svm.configure.config;
+import static com.oracle.svm.core.configure.ConfigurationParser.JNI_KEY;
+import static com.oracle.svm.core.configure.ConfigurationParser.REFLECTION_KEY;
+
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
@@ -35,13 +39,16 @@
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
import com.oracle.svm.core.configure.ConfigurationFile;
import com.oracle.svm.core.configure.ConfigurationParser;
+import com.oracle.svm.core.util.VMError;
public class ConfigurationFileCollection {
public static final Function FAIL_ON_EXCEPTION = e -> e;
+ private final Set reachabilityMetadataPaths = new LinkedHashSet<>();
private final Set jniConfigPaths = new LinkedHashSet<>();
private final Set reflectConfigPaths = new LinkedHashSet<>();
private final Set proxyConfigPaths = new LinkedHashSet<>();
@@ -51,6 +58,7 @@ public class ConfigurationFileCollection {
private Set lockFilePaths;
public void addDirectory(Path path) {
+ reachabilityMetadataPaths.add(path.resolve(ConfigurationFile.REACHABILITY_METADATA.getFileName()).toUri());
jniConfigPaths.add(path.resolve(ConfigurationFile.JNI.getFileName()).toUri());
reflectConfigPaths.add(path.resolve(ConfigurationFile.REFLECTION.getFileName()).toUri());
proxyConfigPaths.add(path.resolve(ConfigurationFile.DYNAMIC_PROXY.getFileName()).toUri());
@@ -70,24 +78,51 @@ private void detectAgentLock(T location, Predicate exists, Function fileResolver) {
- jniConfigPaths.add(fileResolver.apply(ConfigurationFile.JNI.getFileName()));
- reflectConfigPaths.add(fileResolver.apply(ConfigurationFile.REFLECTION.getFileName()));
- proxyConfigPaths.add(fileResolver.apply(ConfigurationFile.DYNAMIC_PROXY.getFileName()));
- resourceConfigPaths.add(fileResolver.apply(ConfigurationFile.RESOURCES.getFileName()));
- serializationConfigPaths.add(fileResolver.apply(ConfigurationFile.SERIALIZATION.getFileName()));
- predefinedClassesConfigPaths.add(fileResolver.apply(ConfigurationFile.PREDEFINED_CLASSES_NAME.getFileName()));
+ addFile(reachabilityMetadataPaths, fileResolver, ConfigurationFile.REACHABILITY_METADATA);
+ addFile(jniConfigPaths, fileResolver, ConfigurationFile.JNI);
+ addFile(reflectConfigPaths, fileResolver, ConfigurationFile.REFLECTION);
+ addFile(proxyConfigPaths, fileResolver, ConfigurationFile.DYNAMIC_PROXY);
+ addFile(resourceConfigPaths, fileResolver, ConfigurationFile.RESOURCES);
+ addFile(serializationConfigPaths, fileResolver, ConfigurationFile.SERIALIZATION);
+ addFile(predefinedClassesConfigPaths, fileResolver, ConfigurationFile.PREDEFINED_CLASSES_NAME);
detectAgentLock(fileResolver.apply(ConfigurationFile.LOCK_FILE_NAME), Objects::nonNull, Function.identity());
}
+ private static void addFile(Set metadataPaths, Function fileResolver, ConfigurationFile configurationFile) {
+ URI uri = fileResolver.apply(configurationFile.getFileName());
+ if (uri != null) {
+ metadataPaths.add(uri);
+ }
+ }
+
public Set getDetectedAgentLockPaths() {
return (lockFilePaths != null) ? lockFilePaths : Collections.emptySet();
}
public boolean isEmpty() {
- return jniConfigPaths.isEmpty() && reflectConfigPaths.isEmpty() && proxyConfigPaths.isEmpty() &&
+ return reachabilityMetadataPaths.isEmpty() && jniConfigPaths.isEmpty() && reflectConfigPaths.isEmpty() && proxyConfigPaths.isEmpty() &&
resourceConfigPaths.isEmpty() && serializationConfigPaths.isEmpty() && predefinedClassesConfigPaths.isEmpty();
}
+ public Set getPaths(ConfigurationFile configurationFile) {
+ Set uris;
+ switch (configurationFile) {
+ case REACHABILITY_METADATA -> uris = getReachabilityMetadataPaths();
+ case DYNAMIC_PROXY -> uris = getProxyConfigPaths();
+ case RESOURCES -> uris = getResourceConfigPaths();
+ case JNI -> uris = getJniConfigPaths();
+ case REFLECTION -> uris = getReflectConfigPaths();
+ case SERIALIZATION -> uris = getSerializationConfigPaths();
+ case PREDEFINED_CLASSES_NAME -> uris = getPredefinedClassesConfigPaths();
+ default -> throw VMError.shouldNotReachHere("Cannot get paths for configuration file " + configurationFile);
+ }
+ return uris.stream().map(Paths::get).collect(Collectors.toSet());
+ }
+
+ public Set getReachabilityMetadataPaths() {
+ return reachabilityMetadataPaths;
+ }
+
public Set getJniConfigPaths() {
return jniConfigPaths;
}
@@ -113,35 +148,37 @@ public Set getPredefinedClassesConfigPaths() {
}
public TypeConfiguration loadJniConfig(Function exceptionHandler) throws Exception {
- return loadTypeConfig(jniConfigPaths, exceptionHandler);
+ return loadTypeConfig(JNI_KEY, jniConfigPaths, exceptionHandler);
}
public TypeConfiguration loadReflectConfig(Function exceptionHandler) throws Exception {
- return loadTypeConfig(reflectConfigPaths, exceptionHandler);
+ return loadTypeConfig(REFLECTION_KEY, reflectConfigPaths, exceptionHandler);
}
public ProxyConfiguration loadProxyConfig(Function exceptionHandler) throws Exception {
ProxyConfiguration proxyConfiguration = new ProxyConfiguration();
- loadConfig(proxyConfigPaths, proxyConfiguration.createParser(), exceptionHandler);
+ loadConfig(proxyConfigPaths, proxyConfiguration.createParser(false), exceptionHandler);
return proxyConfiguration;
}
public PredefinedClassesConfiguration loadPredefinedClassesConfig(Path[] classDestinationDirs, Predicate shouldExcludeClassesWithHash,
Function exceptionHandler) throws Exception {
PredefinedClassesConfiguration predefinedClassesConfiguration = new PredefinedClassesConfiguration(classDestinationDirs, shouldExcludeClassesWithHash);
- loadConfig(predefinedClassesConfigPaths, predefinedClassesConfiguration.createParser(), exceptionHandler);
+ loadConfig(predefinedClassesConfigPaths, predefinedClassesConfiguration.createParser(false), exceptionHandler);
return predefinedClassesConfiguration;
}
public ResourceConfiguration loadResourceConfig(Function exceptionHandler) throws Exception {
ResourceConfiguration resourceConfiguration = new ResourceConfiguration();
- loadConfig(resourceConfigPaths, resourceConfiguration.createParser(), exceptionHandler);
+ loadConfig(reachabilityMetadataPaths, resourceConfiguration.createParser(true), exceptionHandler);
+ loadConfig(resourceConfigPaths, resourceConfiguration.createParser(false), exceptionHandler);
return resourceConfiguration;
}
public SerializationConfiguration loadSerializationConfig(Function exceptionHandler) throws Exception {
SerializationConfiguration serializationConfiguration = new SerializationConfiguration();
- loadConfig(serializationConfigPaths, serializationConfiguration.createParser(), exceptionHandler);
+ loadConfig(reachabilityMetadataPaths, serializationConfiguration.createParser(true), exceptionHandler);
+ loadConfig(serializationConfigPaths, serializationConfiguration.createParser(false), exceptionHandler);
return serializationConfiguration;
}
@@ -152,9 +189,10 @@ public ConfigurationSet loadConfigurationSet(Function ex
loadPredefinedClassesConfig(predefinedConfigClassDestinationDirs, predefinedConfigClassWithHashExclusionPredicate, exceptionHandler));
}
- private static TypeConfiguration loadTypeConfig(Collection uris, Function exceptionHandler) throws Exception {
- TypeConfiguration configuration = new TypeConfiguration();
- loadConfig(uris, configuration.createParser(), exceptionHandler);
+ private TypeConfiguration loadTypeConfig(String combinedFileKey, Collection uris, Function exceptionHandler) throws Exception {
+ TypeConfiguration configuration = new TypeConfiguration(combinedFileKey);
+ loadConfig(reachabilityMetadataPaths, configuration.createParser(true), exceptionHandler);
+ loadConfig(uris, configuration.createParser(false), exceptionHandler);
return configuration;
}
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationSet.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationSet.java
index 166eb517974..4397508d5fa 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationSet.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ConfigurationSet.java
@@ -24,6 +24,9 @@
*/
package com.oracle.svm.configure.config;
+import static com.oracle.svm.core.configure.ConfigurationParser.JNI_KEY;
+import static com.oracle.svm.core.configure.ConfigurationParser.REFLECTION_KEY;
+
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -32,10 +35,10 @@
import com.oracle.svm.configure.ConfigurationBase;
import com.oracle.svm.configure.config.conditional.ConditionalConfigurationPredicate;
-import com.oracle.svm.core.util.json.JsonPrintable;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConfigurationFile;
import com.oracle.svm.core.util.VMError;
+import com.oracle.svm.core.util.json.JsonPrintable;
+import com.oracle.svm.core.util.json.JsonWriter;
public class ConfigurationSet {
@FunctionalInterface
@@ -66,7 +69,7 @@ public ConfigurationSet(ConfigurationSet other) {
}
public ConfigurationSet() {
- this(new TypeConfiguration(), new TypeConfiguration(), new ResourceConfiguration(), new ProxyConfiguration(), new SerializationConfiguration(),
+ this(new TypeConfiguration(REFLECTION_KEY), new TypeConfiguration(JNI_KEY), new ResourceConfiguration(), new ProxyConfiguration(), new SerializationConfiguration(),
new PredefinedClassesConfiguration(new Path[0], hash -> false));
}
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ParserConfigurationAdapter.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ParserConfigurationAdapter.java
index 62a199c3a15..095ea107b67 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ParserConfigurationAdapter.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ParserConfigurationAdapter.java
@@ -31,6 +31,8 @@
import com.oracle.svm.configure.config.ConfigurationMemberInfo.ConfigurationMemberAccessibility;
import com.oracle.svm.configure.config.ConfigurationMemberInfo.ConfigurationMemberDeclaration;
import com.oracle.svm.core.TypeResult;
+import com.oracle.svm.core.configure.ConfigurationTypeDescriptor;
+import com.oracle.svm.core.configure.NamedConfigurationTypeDescriptor;
import com.oracle.svm.core.configure.ReflectionConfigurationParserDelegate;
public class ParserConfigurationAdapter implements ReflectionConfigurationParserDelegate {
@@ -42,114 +44,114 @@ public ParserConfigurationAdapter(TypeConfiguration configuration) {
}
@Override
- public TypeResult resolveCondition(String typeName) {
- return TypeResult.forType(typeName, ConfigurationCondition.create(typeName));
+ public TypeResult resolveType(ConfigurationCondition condition, ConfigurationTypeDescriptor typeDescriptor, boolean allowPrimitives) {
+ if (typeDescriptor instanceof NamedConfigurationTypeDescriptor namedDescriptor) {
+ String typeName = namedDescriptor.name();
+ ConfigurationType type = configuration.get(condition, typeName);
+ ConfigurationType result = type != null ? type : new ConfigurationType(condition, typeName);
+ return TypeResult.forType(typeName, result);
+ } else {
+ return TypeResult.forException(typeDescriptor.toString(), null);
+ }
}
@Override
- public TypeResult resolveType(ConfigurationCondition condition, String typeName, boolean allowPrimitives) {
- ConfigurationType type = configuration.get(condition, typeName);
- ConfigurationType result = type != null ? type : new ConfigurationType(condition, typeName);
- return TypeResult.forType(typeName, result);
- }
-
- @Override
- public void registerType(ConfigurationType type) {
+ public void registerType(ConfigurationCondition condition, ConfigurationType type) {
configuration.add(type);
}
@Override
- public void registerField(ConfigurationType type, String fieldName, boolean finalButWritable) {
+ public void registerField(ConfigurationCondition condition, ConfigurationType type, String fieldName, boolean finalButWritable) {
type.addField(fieldName, ConfigurationMemberDeclaration.PRESENT, finalButWritable);
}
@Override
- public boolean registerAllMethodsWithName(boolean queriedOnly, ConfigurationType type, String methodName) {
+ public boolean registerAllMethodsWithName(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type, String methodName) {
type.addMethodsWithName(methodName, ConfigurationMemberDeclaration.PRESENT, queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
return true;
}
@Override
- public boolean registerAllConstructors(boolean queriedOnly, ConfigurationType type) {
+ public boolean registerAllConstructors(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.addMethodsWithName(ConfigurationMethod.CONSTRUCTOR_NAME, ConfigurationMemberDeclaration.PRESENT,
queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
return true;
}
@Override
- public void registerUnsafeAllocated(ConfigurationType type) {
+ public void registerUnsafeAllocated(ConfigurationCondition condition, ConfigurationType type) {
type.setUnsafeAllocated();
}
@Override
- public void registerMethod(boolean queriedOnly, ConfigurationType type, String methodName, List methodParameterTypes) {
+ public void registerMethod(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type, String methodName, List methodParameterTypes) {
type.addMethod(methodName, ConfigurationMethod.toInternalParamsSignature(methodParameterTypes), ConfigurationMemberDeclaration.PRESENT,
queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
}
@Override
- public void registerConstructor(boolean queriedOnly, ConfigurationType type, List methodParameterTypes) {
+ public void registerConstructor(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type, List methodParameterTypes) {
type.addMethod(ConfigurationMethod.CONSTRUCTOR_NAME, ConfigurationMethod.toInternalParamsSignature(methodParameterTypes), ConfigurationMemberDeclaration.PRESENT,
queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
}
@Override
- public void registerPublicClasses(ConfigurationType type) {
+ public void registerPublicClasses(ConfigurationCondition condition, ConfigurationType type) {
type.setAllPublicClasses();
}
@Override
- public void registerDeclaredClasses(ConfigurationType type) {
+ public void registerDeclaredClasses(ConfigurationCondition condition, ConfigurationType type) {
type.setAllDeclaredClasses();
}
@Override
- public void registerRecordComponents(ConfigurationType type) {
+ public void registerRecordComponents(ConfigurationCondition condition, ConfigurationType type) {
type.setAllRecordComponents();
}
@Override
- public void registerPermittedSubclasses(ConfigurationType type) {
+ public void registerPermittedSubclasses(ConfigurationCondition condition, ConfigurationType type) {
type.setAllPermittedSubclasses();
}
@Override
- public void registerNestMembers(ConfigurationType type) {
+ public void registerNestMembers(ConfigurationCondition condition, ConfigurationType type) {
type.setAllNestMembers();
}
@Override
- public void registerSigners(ConfigurationType type) {
+ public void registerSigners(ConfigurationCondition condition, ConfigurationType type) {
type.setAllSigners();
}
@Override
- public void registerPublicFields(ConfigurationType type) {
+ public void registerPublicFields(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.setAllPublicFields();
}
@Override
- public void registerDeclaredFields(ConfigurationType type) {
+ public void registerDeclaredFields(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.setAllDeclaredFields();
}
@Override
- public void registerPublicMethods(boolean queriedOnly, ConfigurationType type) {
+ public void registerPublicMethods(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.setAllPublicMethods(queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
}
@Override
- public void registerDeclaredMethods(boolean queriedOnly, ConfigurationType type) {
+ public void registerDeclaredMethods(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.setAllDeclaredMethods(queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
}
@Override
- public void registerPublicConstructors(boolean queriedOnly, ConfigurationType type) {
+ public void registerPublicConstructors(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.setAllPublicConstructors(queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
}
@Override
- public void registerDeclaredConstructors(boolean queriedOnly, ConfigurationType type) {
+ public void registerDeclaredConstructors(ConfigurationCondition condition, boolean queriedOnly, ConfigurationType type) {
type.setAllDeclaredConstructors(queriedOnly ? ConfigurationMemberAccessibility.QUERIED : ConfigurationMemberAccessibility.ACCESSED);
}
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/PredefinedClassesConfiguration.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/PredefinedClassesConfiguration.java
index 40229ed4648..87e86fa0309 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/PredefinedClassesConfiguration.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/PredefinedClassesConfiguration.java
@@ -34,14 +34,15 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import com.oracle.svm.core.configure.ConfigurationParser;
import org.graalvm.nativeimage.impl.ConfigurationCondition;
import com.oracle.svm.configure.ConfigurationBase;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConfigurationFile;
+import com.oracle.svm.core.configure.ConfigurationParser;
import com.oracle.svm.core.configure.PredefinedClassesConfigurationParser;
import com.oracle.svm.core.hub.PredefinedClassesSupport;
+import com.oracle.svm.core.util.VMError;
+import com.oracle.svm.core.util.json.JsonWriter;
public final class PredefinedClassesConfiguration extends ConfigurationBase {
private final Path[] classDestinationDirs;
@@ -164,7 +165,8 @@ public void printJson(JsonWriter writer) throws IOException {
}
@Override
- public ConfigurationParser createParser() {
+ public ConfigurationParser createParser(boolean strictMetadata) {
+ VMError.guarantee(!strictMetadata, "Predefined classes configuration is not supported with strict metadata");
return new PredefinedClassesConfigurationParser(this::add, true);
}
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ProxyConfiguration.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ProxyConfiguration.java
index 9859a20d9e5..98715fbba05 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ProxyConfiguration.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ProxyConfiguration.java
@@ -31,13 +31,14 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import com.oracle.svm.core.configure.ConfigurationParser;
-import com.oracle.svm.core.configure.ProxyConfigurationParser;
import org.graalvm.nativeimage.impl.ConfigurationCondition;
import com.oracle.svm.configure.ConfigurationBase;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConditionalElement;
+import com.oracle.svm.core.configure.ConfigurationParser;
+import com.oracle.svm.core.configure.ProxyConfigurationParser;
+import com.oracle.svm.core.util.VMError;
+import com.oracle.svm.core.util.json.JsonWriter;
public final class ProxyConfiguration extends ConfigurationBase {
private final Set>> interfaceLists = ConcurrentHashMap.newKeySet();
@@ -129,8 +130,9 @@ public static void printProxyInterfaces(JsonWriter writer, List interfaceLists.add(new ConditionalElement<>(cond, intfs)));
}
@Override
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ResourceConfiguration.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ResourceConfiguration.java
index 803fbb86fa3..b990bdca9b4 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ResourceConfiguration.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ResourceConfiguration.java
@@ -38,13 +38,13 @@
import org.graalvm.nativeimage.impl.ConfigurationCondition;
import com.oracle.svm.configure.ConfigurationBase;
-import com.oracle.svm.core.util.json.JsonPrinter;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConditionalElement;
import com.oracle.svm.core.configure.ConfigurationParser;
import com.oracle.svm.core.configure.ResourceConfigurationParser;
import com.oracle.svm.core.configure.ResourcesRegistry;
import com.oracle.svm.core.util.VMError;
+import com.oracle.svm.core.util.json.JsonPrinter;
+import com.oracle.svm.core.util.json.JsonWriter;
public final class ResourceConfiguration extends ConfigurationBase {
@@ -249,8 +249,8 @@ public void printJson(JsonWriter writer) throws IOException {
}
@Override
- public ConfigurationParser createParser() {
- return new ResourceConfigurationParser(new ResourceConfiguration.ParserAdapter(this), true);
+ public ConfigurationParser createParser(boolean strictMetadata) {
+ return ResourceConfigurationParser.create(strictMetadata, new ResourceConfiguration.ParserAdapter(this), true);
}
private static void printResourceBundle(BundleConfiguration config, JsonWriter writer) throws IOException {
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SerializationConfiguration.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SerializationConfiguration.java
index 1ed2ed4d756..c59d78976a5 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SerializationConfiguration.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SerializationConfiguration.java
@@ -37,11 +37,11 @@
import org.graalvm.nativeimage.impl.RuntimeSerializationSupport;
import com.oracle.svm.configure.ConfigurationBase;
-import com.oracle.svm.core.util.json.JsonPrintable;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConditionalElement;
import com.oracle.svm.core.configure.ConfigurationParser;
import com.oracle.svm.core.configure.SerializationConfigurationParser;
+import com.oracle.svm.core.util.json.JsonPrintable;
+import com.oracle.svm.core.util.json.JsonWriter;
public final class SerializationConfiguration extends ConfigurationBase
implements RuntimeSerializationSupport {
@@ -123,8 +123,8 @@ public void printJson(JsonWriter writer) throws IOException {
}
@Override
- public ConfigurationParser createParser() {
- return new SerializationConfigurationParser(this, true);
+ public ConfigurationParser createParser(boolean strictMetadata) {
+ return SerializationConfigurationParser.create(strictMetadata, this, true);
}
private void printProxies(JsonWriter writer) throws IOException {
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/TypeConfiguration.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/TypeConfiguration.java
index b90efed5dfd..32d02920d90 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/TypeConfiguration.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/TypeConfiguration.java
@@ -32,24 +32,28 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import com.oracle.svm.core.configure.ConfigurationParser;
-import com.oracle.svm.core.configure.ReflectionConfigurationParser;
import org.graalvm.nativeimage.impl.ConfigurationCondition;
import com.oracle.svm.configure.ConfigurationBase;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConditionalElement;
+import com.oracle.svm.core.configure.ConfigurationParser;
+import com.oracle.svm.core.configure.ReflectionConfigurationParser;
import com.oracle.svm.core.util.VMError;
+import com.oracle.svm.core.util.json.JsonWriter;
public final class TypeConfiguration extends ConfigurationBase {
private final ConcurrentMap, ConfigurationType> types = new ConcurrentHashMap<>();
- public TypeConfiguration() {
+ private final String combinedFileKey;
+
+ public TypeConfiguration(String combinedFileKey) {
+ this.combinedFileKey = combinedFileKey;
}
public TypeConfiguration(TypeConfiguration other) {
other.types.forEach((key, value) -> types.put(key, new ConfigurationType(value)));
+ this.combinedFileKey = other.combinedFileKey;
}
@Override
@@ -142,8 +146,8 @@ public void printJson(JsonWriter writer) throws IOException {
}
@Override
- public ConfigurationParser createParser() {
- return new ReflectionConfigurationParser<>(new ParserConfigurationAdapter(this), true, false);
+ public ConfigurationParser createParser(boolean strictMetadata) {
+ return ReflectionConfigurationParser.create(combinedFileKey, strictMetadata, new ParserConfigurationAdapter(this), true, false);
}
@Override
diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/conditional/PartialConfigurationWithOrigins.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/conditional/PartialConfigurationWithOrigins.java
index e7ee09dd8cc..cb56f8c7c52 100644
--- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/conditional/PartialConfigurationWithOrigins.java
+++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/conditional/PartialConfigurationWithOrigins.java
@@ -33,10 +33,10 @@
import org.graalvm.util.json.JSONParserException;
import com.oracle.svm.configure.config.ConfigurationSet;
-import com.oracle.svm.core.util.json.JsonPrintable;
-import com.oracle.svm.core.util.json.JsonWriter;
import com.oracle.svm.core.configure.ConfigurationFile;
import com.oracle.svm.core.configure.ConfigurationParser;
+import com.oracle.svm.core.util.json.JsonPrintable;
+import com.oracle.svm.core.util.json.JsonWriter;
public class PartialConfigurationWithOrigins extends ConfigurationParser implements JsonPrintable {
private static final ConfigurationSet emptyConfigurationSet = new ConfigurationSet();
@@ -169,7 +169,7 @@ private static void parseConfigurationSet(EconomicMap configJson, Con
if (configType == null) {
throw new JSONParserException("Invalid configuration type: " + configName);
}
- configurationSet.getConfiguration(configType).createParser().parseAndRegister(cursor.getValue(), origin);
+ configurationSet.getConfiguration(configType).createParser(false).parseAndRegister(cursor.getValue(), origin);
}
}
}
diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConditionalRuntimeValue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConditionalRuntimeValue.java
deleted file mode 100644
index d7853365392..00000000000
--- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConditionalRuntimeValue.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.svm.core.configure;
-
-import org.graalvm.nativeimage.Platform;
-import org.graalvm.nativeimage.Platforms;
-
-/**
- * A image-heap stored {@link ConditionalRuntimeValue#value} that is guarded by run-time computed
- * {@link ConditionalRuntimeValue#conditions}.
- *
- * {@link ConditionalRuntimeValue#conditions} are stored as an array to save space in the image
- * heap. This is subject to further optimizations.
- *
- * @param type of the stored value.
- */
-public final class ConditionalRuntimeValue {
- RuntimeConditionSet conditions;
- volatile T value;
-
- public ConditionalRuntimeValue(RuntimeConditionSet conditions, T value) {
- this.conditions = conditions;
- this.value = value;
- }
-
- @Platforms(Platform.HOSTED_ONLY.class)
- public T getValueUnconditionally() {
- return value;
- }
-
- public RuntimeConditionSet getConditions() {
- return conditions;
- }
-
- public T getValue() {
- if (conditions.satisfied()) {
- return value;
- } else {
- return null;
- }
- }
-
- @Platforms(Platform.HOSTED_ONLY.class)
- public void updateValue(T newValue) {
- this.value = newValue;
- }
-}
diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationConditionResolver.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationConditionResolver.java
index bfbba32b23c..f63e5947d04 100644
--- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationConditionResolver.java
+++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationConditionResolver.java
@@ -24,27 +24,27 @@
*/
package com.oracle.svm.core.configure;
-import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;
+import org.graalvm.nativeimage.impl.ConfigurationCondition;
import com.oracle.svm.core.TypeResult;
-public interface ConfigurationConditionResolver {
+public interface ConfigurationConditionResolver {
- static ConfigurationConditionResolver identityResolver() {
- return new ConfigurationConditionResolver<>() {
+ static ConfigurationConditionResolver identityResolver() {
+ return new ConfigurationConditionResolver() {
@Override
- public TypeResult resolveCondition(UnresolvedConfigurationCondition unresolvedCondition) {
+ public TypeResult resolveCondition(ConfigurationCondition unresolvedCondition) {
return TypeResult.forType(unresolvedCondition.getTypeName(), unresolvedCondition);
}
@Override
- public UnresolvedConfigurationCondition alwaysTrue() {
- return UnresolvedConfigurationCondition.alwaysTrue();
+ public ConfigurationCondition alwaysTrue() {
+ return ConfigurationCondition.alwaysTrue();
}
};
}
- TypeResult resolveCondition(UnresolvedConfigurationCondition unresolvedCondition);
+ TypeResult resolveCondition(ConfigurationCondition unresolvedCondition);
- T alwaysTrue();
+ ConfigurationCondition alwaysTrue();
}
diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationFiles.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationFiles.java
index 53bfa1a703e..d3258173267 100644
--- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationFiles.java
+++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationFiles.java
@@ -34,16 +34,15 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue;
+import org.graalvm.compiler.options.Option;
+import org.graalvm.compiler.options.OptionStability;
+import org.graalvm.compiler.options.OptionType;
+
import com.oracle.svm.core.option.BundleMember;
import com.oracle.svm.core.option.HostedOptionKey;
-import com.oracle.svm.core.option.OptionMigrationMessage;
+import com.oracle.svm.core.option.LocatableMultiOptionValue;
import com.oracle.svm.core.util.UserError;
-import jdk.graal.compiler.options.Option;
-import jdk.graal.compiler.options.OptionStability;
-import jdk.graal.compiler.options.OptionType;
-
/**
* Gathers configuration files from specified directories without having to provide each
* configuration file individually.
@@ -51,118 +50,75 @@
public final class ConfigurationFiles {
public static final class Options {
-
@Option(help = "Directories directly containing configuration files for dynamic features at runtime.", type = OptionType.User, stability = OptionStability.STABLE)//
@BundleMember(role = BundleMember.Role.Input)//
- static final HostedOptionKey ConfigurationFileDirectories = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ static final HostedOptionKey ConfigurationFileDirectories = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resource path above configuration resources for dynamic features at runtime.", type = OptionType.User)//
- public static final HostedOptionKey ConfigurationResourceRoots = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey ConfigurationResourceRoots = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
- @OptionMigrationMessage("Use a reflect-config.json in your META-INF/native-image// directory instead.")//
@Option(help = "file:doc-files/ReflectionConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey ReflectionConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ public static final HostedOptionKey ReflectionConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made available for reflection (see ReflectionConfigurationFiles).", type = OptionType.User)//
- public static final HostedOptionKey ReflectionConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey ReflectionConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
- @OptionMigrationMessage("Use a proxy-config.json in your META-INF/native-image// directory instead.")//
- @Option(help = "file:doc-files/ProxyConfigurationFilesHelp.txt", type = OptionType.User, deprecated = true)//
+ @Option(help = "file:doc-files/ProxyConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey DynamicProxyConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
- @Option(help = "Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).", type = OptionType.User, deprecated = true, //
- deprecationMessage = "This can be caused by a proxy-config.json file in your META-INF directory. " +
- "Consider including proxy configuration in the reflection section of reachability-metadata.md instead.")//
- public static final HostedOptionKey DynamicProxyConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
-
- @OptionMigrationMessage("Use a serialization-config.json in your META-INF/native-image// directory instead.")//
+ public static final HostedOptionKey DynamicProxyConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ @Option(help = "Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).", type = OptionType.User)//
+ public static final HostedOptionKey DynamicProxyConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+
@Option(help = "file:doc-files/SerializationConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey SerializationConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ public static final HostedOptionKey SerializationConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made available for serialization (see SerializationConfigurationFiles).", type = OptionType.User)//
- public static final HostedOptionKey SerializationConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey SerializationConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
- @OptionMigrationMessage("Use a serialization-config.json in your META-INF/native-image// directory instead.")//
@Option(help = "file:doc-files/SerializationConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey SerializationDenyConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ public static final HostedOptionKey SerializationDenyConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements that must not be made available for serialization.", type = OptionType.User)//
- public static final HostedOptionKey SerializationDenyConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey SerializationDenyConfigurationResources = new HostedOptionKey<>(
+ LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
- @OptionMigrationMessage("Use a resource-config.json in your META-INF/native-image// directory instead.")//
@Option(help = "Files describing Java resources to be included in the image according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey ResourceConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ public static final HostedOptionKey ResourceConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing Java resources to be included in the image according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json", type = OptionType.User)//
- public static final HostedOptionKey ResourceConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey ResourceConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
- @OptionMigrationMessage("Use a jni-config.json in your META-INF/native-image// directory instead.")//
- @Option(help = "Files describing program elements to be made accessible via JNI according to the schema at " +
- "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json", type = OptionType.User)//
+ @Option(help = "Files describing program elements to be made accessible via JNI (for syntax, see ReflectionConfigurationFiles)", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey JNIConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
- @Option(help = "Resources describing program elements to be made accessible via JNI according to the schema at " +
- "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json", type = OptionType.User)//
- public static final HostedOptionKey JNIConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey JNIConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ @Option(help = "Resources describing program elements to be made accessible via JNI (see JNIConfigurationFiles).", type = OptionType.User)//
+ public static final HostedOptionKey JNIConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
@Option(help = "Resources describing reachability metadata needed for the program " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reachability-metadata-schema-v1.0.0.json", type = OptionType.User)//
- public static final HostedOptionKey ReachabilityMetadataResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey ReachabilityMetadataResources = new HostedOptionKey<>(
+ LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
@Option(help = "Files describing stubs allowing foreign calls.", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey ForeignConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ public static final HostedOptionKey ForeignConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing stubs allowing foreign calls.", type = OptionType.User)//
- public static final HostedOptionKey ForeignResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey ForeignResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
- @OptionMigrationMessage("Use a predefined-classes-config.json in your META-INF/native-image// directory instead.")//
@Option(help = "Files describing predefined classes that can be loaded at runtime according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
- public static final HostedOptionKey PredefinedClassesConfigurationFiles = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
+ public static final HostedOptionKey PredefinedClassesConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing predefined classes that can be loaded at runtime according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", type = OptionType.User)//
- public static final HostedOptionKey PredefinedClassesConfigurationResources = new HostedOptionKey<>(
- AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
+ public static final HostedOptionKey PredefinedClassesConfigurationResources = new HostedOptionKey<>(
+ LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
@Option(help = "When configuration files do not match their schema, abort the image build instead of emitting a warning.")//
public static final HostedOptionKey StrictConfiguration = new HostedOptionKey<>(false);
- @Option(help = "Testing flag: the 'typeReachable' condition is treated as typeReached so the semantics of programs can change.")//
- public static final HostedOptionKey TreatAllTypeReachableConditionsAsTypeReached = new HostedOptionKey<>(false);
-
- @Option(help = "Testing flag: the 'name' is treated as 'type' in reflection configuration.")//
- public static final HostedOptionKey TreatAllNameEntriesAsType = new HostedOptionKey<>(false);
-
- @Option(help = "Testing flag: the 'typeReached' condition is always satisfied however it prints the stack trace where it would not be satisfied.")//
- public static final HostedOptionKey TrackUnsatisfiedTypeReachedConditions = new HostedOptionKey<>(false);
-
- @Option(help = "Testing flag: print 'typeReached' conditions that are used on interfaces without default methods at build time.")//
- public static final HostedOptionKey TrackTypeReachedOnInterfaces = new HostedOptionKey<>(false);
-
- @Option(help = "Testing flag: every type is considered as it participates in a typeReachable condition.")//
- public static final HostedOptionKey TreatAllUserSpaceTypesAsTrackedForTypeReached = new HostedOptionKey<>(false);
-
@Option(help = "Warn when reflection and JNI configuration files have elements that could not be found on the classpath or modulepath.", type = OptionType.Expert)//
public static final HostedOptionKey WarnAboutMissingReflectionOrJNIMetadataElements = new HostedOptionKey<>(false);
}
diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java
index cc28760d089..9333a6955ab 100644
--- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java
+++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java
@@ -24,10 +24,6 @@
*/
package com.oracle.svm.core.configure;
-import static com.oracle.svm.core.configure.ConfigurationFiles.Options.TreatAllTypeReachableConditionsAsTypeReached;
-import static org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition.TYPE_REACHABLE_KEY;
-import static org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition.TYPE_REACHED_KEY;
-
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -46,16 +42,15 @@
import java.util.Set;
import org.graalvm.collections.EconomicMap;
-import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;
+import org.graalvm.nativeimage.impl.ConfigurationCondition;
+import org.graalvm.util.json.JSONParser;
+import org.graalvm.util.json.JSONParserException;
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.jdk.JavaNetSubstitutions;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.LogUtils;
-import jdk.graal.compiler.util.json.JsonParser;
-import jdk.graal.compiler.util.json.JsonParserException;
-
public abstract class ConfigurationParser {
public static InputStream openStream(URI uri) throws IOException {
URL url = uri.toURL();
@@ -67,6 +62,8 @@ public static InputStream openStream(URI uri) throws IOException {
}
public static final String CONDITIONAL_KEY = "condition";
+ public static final String TYPE_REACHABLE_KEY = "typeReachable";
+ public static final String TYPE_REACHED_KEY = "typeReached";
public static final String NAME_KEY = "name";
public static final String TYPE_KEY = "type";
public static final String PROXY_KEY = "proxy";
@@ -76,6 +73,8 @@ public static InputStream openStream(URI uri) throws IOException {
public static final String RESOURCES_KEY = "resources";
public static final String BUNDLES_KEY = "bundles";
public static final String GLOBS_KEY = "globs";
+ public static final String MODULE_KEY = "module";
+ public static final String GLOB_KEY = "glob";
private final Map> seenUnknownAttributesByType = new HashMap<>();
private final boolean strictSchema;
@@ -85,7 +84,7 @@ protected ConfigurationParser(boolean strictConfiguration) {
public void parseAndRegister(URI uri) throws IOException {
try (Reader reader = openReader(uri)) {
- parseAndRegister(new JsonParser(reader).parse(), uri);
+ parseAndRegister(new JSONParser(reader).parse(), uri);
} catch (FileNotFoundException e) {
/*
* Ignore: *-config.json files can be missing when reachability-metadata.json is
@@ -99,7 +98,7 @@ protected static BufferedReader openReader(URI uri) throws IOException {
}
public void parseAndRegister(Reader reader) throws IOException {
- parseAndRegister(new JsonParser(reader).parse(), null);
+ parseAndRegister(new JSONParser(reader).parse(), null);
}
public abstract void parseAndRegister(Object json, URI origin) throws IOException;
@@ -115,7 +114,7 @@ public static List