1

I develop a web service with spring boot and I use model mapper. I have changed my project sdk from jdk 1.8 to jdk 11 (oracle open jdk) and this warning is appeared:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on org.modelmapper.internal.ProxyFactory (file:/home/omid/.m2/repository/org/modelmapper/modelmapper/2.3.8/modelmapper-2.3.8.jar) to interface java.util.Set
WARNING: Please consider reporting this to the maintainers of org.modelmapper.internal.ProxyFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I config model mapper to skip some fields of some objects such as:

this.modelMapper.addMappings(new PropertyMap<SourceObject, DestinationObject>() {
        @Override
        protected void configure() {
            skip(destination.getField1());
            skip(destination.getField2());
        }
    });

I am using spring boot v2.2.6.RELEASE and modelmapper v2.3.8. Why does this error appear?

Omid
  • 314
  • 1
  • 13
  • 2
    Does this answer your question? [what is an illegal reflective access](https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access) – Jeroen Steenbeeke Aug 06 '20 at 07:57
  • @JeroenSteenbeeke Thanks for your comment. This question is very helpful for me but how I change my model mapper config to avoid this warning – Omid Aug 06 '20 at 08:13
  • 2
    Usually with this error it's not a matter of configuration, but a matter of the library maintainers having to make changes to avoid this error. In fact, this issue has already been reported: https://github.com/modelmapper/modelmapper/issues/414. For now, it's safe to ignore, but it might become a problem in a future Java version – Jeroen Steenbeeke Aug 06 '20 at 08:20
  • 1
    This is a dependency version issue. Try with ModelMapper 2.4.0 released – AlejoDev Apr 01 '21 at 17:28
  • @AlejoDev Thanks a lot. This is correct solution. – Omid Apr 04 '21 at 11:08

0 Answers0