orika-mapper / orika

Simpler, better and faster Java bean mapping framework
http://orika-mapper.github.io/orika-docs/
Apache License 2.0
1.29k stars 268 forks source link

Optimize MapperGenerator class so that there will be no method code length limit #393

Open Rayti opened 2 years ago

Rayti commented 2 years ago

Hello! Recently I encountered a problem with defining mapping for large legacy classes with many nested fields.

Class MapperGeneratorin method private Set<FieldMap> addMapMethod(SourceCodeContext code, boolean aToB, ClassMap<?, ?> classMap, StringBuilder logDetails) combines all class map field mappings into one method. So when there are many field mappings and fields have long names there might occur an "Method code too large exception" during initializing generated mapping classes at runtime. The standard limit in JDK for method length is 64k.

I looked up one of the generated mapping class in my code and it's method has almost 7k lines :). Is there any workaround for this problem?