Browse Source

Improve ConstantFieldFeature compatibility

This commit makes ConstantFieldFeature
compatible with GraalVM 22.2 while retaining
GraalVM 22.1 compatibility.

See gh-28624
pull/28759/head
Sébastien Deleuze 2 years ago
parent
commit
b64edebadc
  1. 4
      spring-core/graalvm/src/main/java/org/springframework/aot/graalvm/ConstantFieldFeature.java
  2. 7
      spring-core/graalvm/src/main/java/org/springframework/aot/graalvm/ConstantReadableJavaField.java

4
spring-core/graalvm/src/main/java/org/springframework/aot/graalvm/ConstantFieldFeature.java

@ -41,9 +41,9 @@ class ConstantFieldFeature implements Feature { @@ -41,9 +41,9 @@ class ConstantFieldFeature implements Feature {
DebugContext debug = access.getDebugContext();
try (DebugContext.Scope scope = debug.scope("ConstantFieldFeature.duringSetup")) {
debug.log("Installing constant field substitution processor : " + scope);
ClassLoader applicationClassLoader = access.getApplicationClassLoader();
ClassLoader classLoader = ConstantFieldFeature.class.getClassLoader();
ConstantFieldSubstitutionProcessor substitutionProcessor =
new ConstantFieldSubstitutionProcessor(debug, applicationClassLoader);
new ConstantFieldSubstitutionProcessor(debug, classLoader);
access.registerSubstitutionProcessor(substitutionProcessor);
}
}

7
spring-core/graalvm/src/main/java/org/springframework/aot/graalvm/ConstantReadableJavaField.java

@ -18,6 +18,7 @@ package org.springframework.aot.graalvm; @@ -18,6 +18,7 @@ package org.springframework.aot.graalvm;
import java.lang.annotation.Annotation;
import com.oracle.graal.pointsto.infrastructure.WrappedElement;
import com.oracle.svm.core.meta.ReadableJavaField;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaType;
@ -31,7 +32,7 @@ import jdk.vm.ci.meta.ResolvedJavaType; @@ -31,7 +32,7 @@ import jdk.vm.ci.meta.ResolvedJavaType;
* @author Phillip Webb
* @since 6.0
*/
class ConstantReadableJavaField implements ReadableJavaField {
class ConstantReadableJavaField implements ReadableJavaField, WrappedElement {
private final ResolvedJavaField original;
@ -109,4 +110,8 @@ class ConstantReadableJavaField implements ReadableJavaField { @@ -109,4 +110,8 @@ class ConstantReadableJavaField implements ReadableJavaField {
return true;
}
@Override
public Object getWrapped() {
return this.original;
}
}

Loading…
Cancel
Save