-
Notifications
You must be signed in to change notification settings - Fork 687
AbstractMappingContext with JDK 17 crashing with InaccessibleObjectException #2844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
The problem here is that |
I believe this bug should be reopened. Jackson has no issue dealing with them in ObjectMapper and considering them as beans in Spring Data via opening up their fields to reflection seems seriously flawed. The following is a standalone reproducer of the issue, using just package com.example.spring;
import org.junit.jupiter.api.Test;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.context.AbstractMappingContext;
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
import org.springframework.data.mapping.model.BasicPersistentEntity;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.NonNull;
import java.math.BigDecimal;
/**
* Reproducer for <a href="https://github.com/spring-projects/spring-data-commons/issues/2844">spring-data-commons #2844</a>
*/
public class AbstractMappingContextTest {
public static class TestProperty extends AnnotationBasedPersistentProperty<TestProperty> {
public TestProperty(Property property, PersistentEntity<?, TestProperty> owner, SimpleTypeHolder simpleTypeHolder) {
super(property, owner, simpleTypeHolder);
}
@Override
@NonNull
protected Association<TestProperty> createAssociation() {
throw new UnsupportedOperationException();
}
}
public static class TestMappingContext extends AbstractMappingContext<BasicPersistentEntity<?, TestProperty>, TestProperty> {
@Override
@NonNull
protected <T> BasicPersistentEntity<T, TestProperty> createPersistentEntity(@NonNull TypeInformation<T> typeInformation) {
return new BasicPersistentEntity<>(typeInformation);
}
@Override
@NonNull
protected TestProperty createPersistentProperty(@NonNull Property property, @NonNull BasicPersistentEntity<?, TestProperty> owner, @NonNull SimpleTypeHolder simpleTypeHolder) {
return new TestProperty(property, owner, simpleTypeHolder);
}
public <T> void addEntityClass(Class<T> entityClass) {
addPersistentEntity(entityClass);
}
}
public static class MyEntity {
private BigDecimal value;
}
@Test
public void testAMC() {
TestMappingContext tmc = new TestMappingContext();
tmc.addEntityClass(MyEntity.class);
}
} |
You're right, many XML and JSON libraries handle That being said, we cannot pretend that In theory, you could ask |
Right, I agree that not all Spring Data implementations will natively support
Yes, you could do so, but I find this exceedingly unlikely after the analysis above. I would argue that most if not all classes in spring-data-commons/src/main/java/org/springframework/data/mapping/model/SimpleTypeHolder.java Line 158 in 19e2a1c
type.getName().startsWith("java.math") in that case.
|
Uh oh!
There was an error while loading. Please reload this page.
Hi, have you seen the issue with AbstractMappingContext and latest JDK?
Here are few details:
Environment:
Looking forward for your help.
The text was updated successfully, but these errors were encountered: