, P extends PersistentProperty>
implements MappingContext, ApplicationEventPublisherAware, ApplicationContextAware, InitializingBean {
- private static final boolean IN_NATIVE_IMAGE = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
-
private final Optional NONE = Optional.empty();
private final Map, Optional> persistentEntities = new HashMap<>();
private final PersistentPropertyAccessorFactory persistentPropertyAccessorFactory;
@@ -109,7 +108,7 @@ protected AbstractMappingContext() {
this.persistentPropertyPathFactory = new PersistentPropertyPathFactory<>(this);
EntityInstantiators instantiators = new EntityInstantiators();
- PersistentPropertyAccessorFactory accessorFactory = IN_NATIVE_IMAGE ? BeanWrapperPropertyAccessorFactory.INSTANCE
+ PersistentPropertyAccessorFactory accessorFactory = NativeDetector.inNativeImage() ? BeanWrapperPropertyAccessorFactory.INSTANCE
: new ClassGeneratingPropertyAccessorFactory();
this.persistentPropertyAccessorFactory = new InstantiationAwarePropertyAccessorFactory(accessorFactory,
diff --git a/src/main/java/org/springframework/data/mapping/model/ClassGeneratingEntityInstantiator.java b/src/main/java/org/springframework/data/mapping/model/ClassGeneratingEntityInstantiator.java
index b6cc3413e0..0b997c9e1a 100644
--- a/src/main/java/org/springframework/data/mapping/model/ClassGeneratingEntityInstantiator.java
+++ b/src/main/java/org/springframework/data/mapping/model/ClassGeneratingEntityInstantiator.java
@@ -31,6 +31,7 @@
import org.springframework.asm.Opcodes;
import org.springframework.asm.Type;
import org.springframework.cglib.core.ReflectUtils;
+import org.springframework.core.NativeDetector;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.mapping.PreferredConstructor;
@@ -55,7 +56,6 @@
class ClassGeneratingEntityInstantiator implements EntityInstantiator {
private static final Log LOGGER = LogFactory.getLog(ClassGeneratingEntityInstantiator.class);
- private static final boolean IN_NATIVE_IMAGE = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
private static final Object[] EMPTY_ARGS = new Object[0];
@@ -142,7 +142,7 @@ protected EntityInstantiator doCreateEntityInstantiator(PersistentEntity, ?> e
*/
boolean shouldUseReflectionEntityInstantiator(PersistentEntity, ?> entity) {
- if (IN_NATIVE_IMAGE) {
+ if (NativeDetector.inNativeImage()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("graalvm.nativeimage - fall back to reflection for %s.", entity.getName()));