modelmapper: WARNING: Illegal reflective access using Lookup on org.modelmapper.internal.ProxyFactory to interface java.util.Set
Hi, i have a warning in console when i convert Set to String separated by comma. How to fix it? ModelMapper version 2.3.1 Compiled with jdk 11 and jdk 10
WARNING: Illegal reflective access using Lookup on org.modelmapper.internal.ProxyFactory (file:/C:/Users/dev/.m2/repository/org/modelmapper/modelmapper/2.3.0/modelmapper-2.3.0.jar) to interface java.util.Set
class ClassWithSet {
private Set<Human> people;
// getter, setter
}
class ClassWithString {
private String names;
// getter, setter
}
class Human {
private String name;
private String surname;
// getter, setter
}
Converter<Set<Human>, String> setToStringComma =
source -> source.getSource().stream().map(Human::getName).collect(Collectors.joining(","));
modelMapper.typeMap(ClassWithSet.class, ClassWithString.class)
.addMappings(mapper -> mapper.using(setToStringComma).map(ClassWithSet::getPeople, ClassWithString::setNames));
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 22 (2 by maintainers)
Commits related to this issue
- Eliminate warnings while defining explicit mapping on collections Jdk 9 and newer JDK display warning messages while we are trying to proxy a java colleciton type java collection type. To fix this is... — committed to modelmapper/modelmapper by chhsiao90 3 years ago
- Eliminate warnings while defining explicit mapping on collections Jdk 9 and newer JDK display warning messages while we are trying to proxy a java colleciton type java collection type. To fix this is... — committed to modelmapper/modelmapper by chhsiao90 3 years ago
- Fix illegal reflective access warning due to modelmapper private field access https://github.com/modelmapper/modelmapper/issues/414 — committed to aesy/yumme-server by aesy 3 years ago
This is issue is still occurring in jdk 11.0.4. If it is not resolved we will have to refactor to not use ModelMapper altogether
Seeing the same warnings with latest springboot , jdk 11 while mapping between two classes… Any plans of fixing this???
Having the same issue:
This is Issue exists since over one year, is there no intention to fix it (or is it my fault?)?
ModelMapper 2.4.0 released.
Hi @chhsiao90,
I’m having a similar issue caused by Java module system, but on a slightly different scenario.
I have 2 classes with no getters/setters that I want to use mapping on and in order to do that I have field access set as follows:
Everything works as expected, except that I’m getting the famous An illegal reflective access operation has occurred warning:
Please let me know if I should open a new ticket for this or if you need more information on the setup.
For anyone reading this that is in a similar situation as me. On JDK 11 and modelMapper version 2.3.8. I had the following config.
ModelMapper modelMapper = new ModelMapper(); modelMapper.getConfiguration() .setFieldMatchingEnabled(true) .setFieldAccessLevel(org.modelmapper.config.Configuration.AccessLevel.PRIVATE) .setMatchingStrategy(MatchingStrategies.STRICT); return modelMapper;
Since I didn’t strictly need setFieldAccessLevel for my usecase, removing
.setFieldAccessLevel(org.modelmapper.config.Configuration.AccessLevel.PRIVATE)
removed the warning for me.I found out that this type mapping config will cause this issue:
but this doesn’t:
Using modelmapper 2.3.8.
JVM Version: 14.0.1+7 modelmapper 2.3.8
Similar problem with jdk 11.0.6 and modelmapper 2.3.7:
There hasn’t been any feedback from members of the project on this issue since 2018, could we just get a brief status of the situation on this issue ? @chhsiao90 @jhalterman