Java / MapStruct Java Interview questions part 2
Describe how MapStruct generates the mapper implementation class?
MapStruct hooks into the Java compiler through the standard annotation processing API (JSR 269). During compilation, javac invokes the MapStruct processor for every type annotated with @Mapper.
The processor inspects the abstract method's source and target types using the compiler's type model, matches properties by name (or by the rules given in @Mapping), and writes a new Java source file for the implementation class into the build's generated-sources folder.
That generated file is then compiled like any other source file in the same build, so the final .class file is ordinary bytecode with no runtime dependency on MapStruct's processor.
More Related questions...