From 2ca4ce5fd52504cdaa707d575a8ecb1e6a21e8fc Mon Sep 17 00:00:00 2001 From: Christian Schuster Date: Tue, 23 Sep 2014 21:40:05 +0200 Subject: [PATCH] #297 check presence of @Mapper annotation --- .../src/main/java/org/mapstruct/ap/MappingProcessor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/processor/src/main/java/org/mapstruct/ap/MappingProcessor.java b/processor/src/main/java/org/mapstruct/ap/MappingProcessor.java index 2feb87429..dba726ef1 100644 --- a/processor/src/main/java/org/mapstruct/ap/MappingProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/MappingProcessor.java @@ -42,6 +42,7 @@ import javax.tools.Diagnostic.Kind; import org.mapstruct.ap.model.Mapper; import org.mapstruct.ap.option.Options; import org.mapstruct.ap.option.ReportingPolicy; +import org.mapstruct.ap.prism.MapperPrism; import org.mapstruct.ap.processor.DefaultModelElementProcessorContext; import org.mapstruct.ap.processor.ModelElementProcessor; import org.mapstruct.ap.processor.ModelElementProcessor.ProcessorContext; @@ -134,6 +135,12 @@ public class MappingProcessor extends AbstractProcessor { for ( Element mapperElement : roundEnvironment.getElementsAnnotatedWith( annotation ) ) { TypeElement mapperTypeElement = asTypeElement( mapperElement ); + // on some JDKs, RoundEnvironment.getElementsAnnotatedWith( ... ) returns types with + // annotations unknown to the compiler, even though they are not declared Mappers + if ( MapperPrism.getInstanceOn( mapperTypeElement ) == null ) { + continue; + } + // create a new context for each generated mapper in order to have imports of referenced types // correctly managed; // note that this assumes that a new source file is created for each mapper which must not