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

Most upvoted comments

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:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.modelmapper.internal.PropertyInfoImpl$AbstractMethodInfo (file:/app/lib/modelmapper-2.3.0.jar) to method java.util.Date.getCalendarDate()
WARNING: Please consider reporting this to the maintainers of org.modelmapper.internal.PropertyInfoImpl$AbstractMethodInfo
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

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:

    @Bean
    ModelMapper createModelMapper() {
        ModelMapper modelMapper = new ModelMapper();

        modelMapper.getConfiguration()
                .setFieldAccessLevel(org.modelmapper.config.Configuration.AccessLevel.PRIVATE)
                .setFieldMatchingEnabled(true);

        return modelMapper;
    }

Everything works as expected, except that I’m getting the famous An illegal reflective access operation has occurred warning:

WARNING: Illegal reflective access by org.modelmapper.internal.PropertyInfoImpl$FieldPropertyInfo (file:/home/martin/.m2/repository/org/modelmapper/modelmapper/2.3.2/modelmapper-2.3.2.jar) to field java.math.BigDecimal.intVal

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:

ModelMapper modelMapper = new ModelMapper();
modelMapper.addMappings(new PropertyMap<Source, Dest>() {
          @Override
          protected void configure() {
              skip(source.getSomething());
          }
      });

but this doesn’t:

ModelMapper modelMapper = new ModelMapper();
modelMapper.typeMap(Source.class, Dest.class).addMappings(
            mapper -> mapper.skip(Dest::setSomething));

Using modelmapper 2.3.8.

JVM Version: 14.0.1+7 modelmapper 2.3.8

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on org.modelmapper.internal.ProxyFactory 
(file:/Users/*****/IdeaProjects/*****/WEB-INF/lib/modelmapper-2.3.8.jar) to interface java.util.Map
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

Similar problem with jdk 11.0.6 and modelmapper 2.3.7: image

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