diff --git a/common/src/main/java/com/google/auto/common/AnnotationMirrors.java b/common/src/main/java/com/google/auto/common/AnnotationMirrors.java index bc6255d2fb..9ce5cd9bc0 100644 --- a/common/src/main/java/com/google/auto/common/AnnotationMirrors.java +++ b/common/src/main/java/com/google/auto/common/AnnotationMirrors.java @@ -18,6 +18,7 @@ import static com.google.auto.common.MoreElements.isAnnotationPresent; import static com.google.auto.common.MoreStreams.toImmutableSet; import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.Collections.unmodifiableMap; import com.google.common.base.Equivalence; import com.google.common.collect.ImmutableMap; @@ -94,9 +95,10 @@ public static Equivalence equivalence() { public static ImmutableMap getAnnotationValuesWithDefaults( AnnotationMirror annotation) { ImmutableMap.Builder values = ImmutableMap.builder(); + // Use unmodifiableMap to eliminate wildcards, which cause issues for our nullness checker. @SuppressWarnings("GetElementValues") - Map declaredValues = - annotation.getElementValues(); + Map declaredValues = + unmodifiableMap(annotation.getElementValues()); for (ExecutableElement method : ElementFilter.methodsIn(annotation.getAnnotationType().asElement().getEnclosedElements())) { // Must iterate and put in this order, to ensure consistency in generated code.