diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ConfigurationCondition.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ConfigurationCondition.java index f6deb0279b14..d7c56dc0dd98 100644 --- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ConfigurationCondition.java +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ConfigurationCondition.java @@ -44,11 +44,18 @@ /** * A condition that describes if a reflectively-accessed element in Native Image is visible by the - * user. + * user at run time. *
- * Currently, there is only one type of condition (typeReached
) so this is a final
- * class instead of the class hierarchy. The {@link ConfigurationCondition#type} represents the
- * {@link Class<>} that needs to be reached by analysis in order for an element to be visible.
+ * Currently, there is only two types of condition:
+ *
typeReached
(the default) that signifies that the type must be both reachable by
+ * static analysis at build time, and reached at run time. A type is reached at run time, right
+ * before the class-initialization routine starts for that type, or any of the type's subtypes are
+ * reached.typeReachable
(legacy) that signifies that the type must be reachable by static
+ * analysis at build time.
+ * When {@link ConfigurationCondition#runtimeChecked} is true
denotes that this is a
+ * typeReached
condition.
*/
public final class ConfigurationCondition {
@@ -63,6 +70,25 @@ public static ConfigurationCondition alwaysTrue() {
private final boolean runtimeChecked;
+ /**
+ * Creates the default type-reached condition that is satisfied when the type is reached at
+ * runtime.
+ *
+ * @param type that has to be reached for this condition to be satisfied
+ * @return instance of the condition
+ */
+ public static ConfigurationCondition create(Class> type) {
+ return create(type, true);
+ }
+
+ /**
+ * Creates either a type-reached condition ({@code runtimeChecked = true}) or a type-reachable
+ * condition.
+ *
+ * @param type that has to be reached (or reachable) for this condition to be satisfied
+ * @param runtimeChecked makes this a type-reachable condition when false
+ * @return instance of the condition
+ */
public static ConfigurationCondition create(Class> type, boolean runtimeChecked) {
Objects.requireNonNull(type);
if (JAVA_LANG_OBJECT_REACHED.getType().equals(type)) {
diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/UnresolvedConfigurationCondition.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/UnresolvedConfigurationCondition.java
index ffaf597dcdbe..fb7a182cda99 100644
--- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/UnresolvedConfigurationCondition.java
+++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/UnresolvedConfigurationCondition.java
@@ -53,6 +53,10 @@ public final class UnresolvedConfigurationCondition implements Comparable