modelmapper: Error mapping models with jdk 11.0.11 update
Yesterday oracle jdk 11.0.11 was released and mapping stopped working with the following error (model mapper version 2.3.9):
...
Caused by: org.modelmapper.MappingException: ModelMapper mapping errors:
1) Error mapping a.b.c.ModelA to a.b.c.ModelB
1 error
at org.modelmapper.internal.Errors.throwMappingExceptionIfErrorsExist(Errors.java:380)
at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:81)
at org.modelmapper.ModelMapper.mapInternal(ModelMapper.java:573)
at org.modelmapper.ModelMapper.map(ModelMapper.java:495)
... 254 common frames omitted
Caused by: java.lang.ClassCastException: null
MM configuration:
// ... here are some custom converters
modelMapper.getConfiguration().setFieldMatchingEnabled(true).setMatchingStrategy(MatchingStrategies.STRICT).setFieldAccessLevel(
Configuration.AccessLevel.PRIVATE).setUseOSGiClassLoaderBridging(true);
Rolling back to jdk 11.0.10 resolved the issue. Tried updating the library to 2.4.0 but it made no changes.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (7 by maintainers)
I managed find a simple example to generate the same exception, the exception is thrown after a couple hunderd iterations. This was tested using modelmapper version 2.3.9 and openjdk version 11.0.11
Minimum reproducible code created: https://github.com/chhsiao90/jdk-8257594-bug
Already submit a bug report to oracle.
ModelMapper v2.4.3 released!
Got the same error with model mapper 2.4.3 and OpenJDK Runtime Environment 18.9 (build 11.0.11+9), Getting the error
Caused by: java.lang.ClassCastException: null
only after multiple iterations (around 1000). Anyone having the same issue even after the version upgrade?https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8266615
FYI: The bug from java side was fixed in 11.0.13.
@chhsiao90 I confirm the issue here doesn’t reproduce on the latest master version.
Hi, I’ve checked this fix and it is working in my case. Thank You!
It looks like it’s caused by the change of JIT compiler optimization in JDK-8257594. But the root cause hadn’t been found.
I’m trying to fix the issue by #611. Can anyone in this thread check if the issue was fixed or not by the pull request?
Sure, will do once I have the time to investigate this further.