--- old/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java 2019-04-24 19:03:49.339005001 -0700 +++ new/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java 2019-04-24 19:03:49.003005001 -0700 @@ -80,10 +80,9 @@ */ public Set getSupportedOptions() { SupportedOptions so = this.getClass().getAnnotation(SupportedOptions.class); - if (so == null) - return Collections.emptySet(); - else - return arrayToSet(so.value(), false); + return (so == null) ? + Set.of() : + arrayToSet(so.value(), false, "option value", "@SupportedOptions"); } /** @@ -110,12 +109,13 @@ "No SupportedAnnotationTypes annotation " + "found on " + this.getClass().getName() + ", returning an empty set."); - return Collections.emptySet(); + return Set.of(); } else { boolean stripModulePrefixes = initialized && processingEnv.getSourceVersion().compareTo(SourceVersion.RELEASE_8) <= 0; - return arrayToSet(sat.value(), stripModulePrefixes); + return arrayToSet(sat.value(),stripModulePrefixes, + "annotation type", "@SupportedAnnotationTypes"); } } @@ -195,17 +195,27 @@ return initialized; } - private static Set arrayToSet(String[] array, - boolean stripModulePrefixes) { + private Set arrayToSet(String[] array, + boolean stripModulePrefixes, + String contentType, + String annotationName) { assert array != null; - Set set = new HashSet<>(array.length); + Set set = new HashSet<>(); for (String s : array) { if (stripModulePrefixes) { int index = s.indexOf('/'); if (index != -1) s = s.substring(index + 1); } - set.add(s); + boolean added = set.add(s); + if (!added && initialized) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, + "Duplicate " + contentType + + " ``" + s + "'' for processor " + + this.getClass().getName() + + " in its " + annotationName + + "annotation."); + } } return Collections.unmodifiableSet(set); }