in ti/phase2/jars/core/src/java/org/apache/ti/compiler/internal/CompilerUtils.java [728:788]
public static boolean annotationsAreEqual(AnnotationInstance a1, AnnotationInstance a2, boolean allowExactDuplicates,
AnnotationProcessorEnvironment env) {
assert a1 != null;
if (a2 == null) return false;
//
// TODO: This entire method is a workaround for a bug in APT where an annotation may not equal itelf.
// If this behavior changes, we want to rely on equals(), not this deep comparison, which is more expensive
// and wrong if the two annotations 'look' exactly the same.
//
if (! allowExactDuplicates
&& env instanceof ExtendedAnnotationProcessorEnvironment
&& ((ExtendedAnnotationProcessorEnvironment) env).useEqualsToCompareAnnotations()) {
return a1.equals(a2);
}
Map vals1 = a1.getElementValues();
Map vals2 = a2.getElementValues();
if (vals1.size() != vals2.size()) return false;
Iterator ents1 = vals1.entrySet().iterator();
Iterator ents2 = vals2.entrySet().iterator();
while (ents1.hasNext()) {
Map.Entry entry1 = (Map.Entry) ents1.next();
Map.Entry entry2 = (Map.Entry) ents2.next();
if (! ((AnnotationTypeElementDeclaration) entry1.getKey()).getSimpleName().equals(((AnnotationTypeElementDeclaration) entry2.getKey()).getSimpleName())) return false;
Object val1 = ((AnnotationValue) entry1.getValue()).getValue();
Object val2 = ((AnnotationValue) entry2.getValue()).getValue();
if (val1 instanceof Collection) {
if (! (val2 instanceof Collection)) return false;
Collection list1 = (Collection) val1;
Collection list2 = (Collection) val2;
if (list1.size() != list2.size()) return false;
Iterator j1 = list1.iterator();
Iterator j2 = list2.iterator();
while (j1.hasNext()) {
Object o1 = ((AnnotationValue) j1.next()).getValue();
Object o2 = ((AnnotationValue) j2.next()).getValue();
if (o1 instanceof AnnotationInstance) {
if (! (o2 instanceof AnnotationInstance)) return false;
if (! annotationsAreEqual((AnnotationInstance) o1, (AnnotationInstance) o2, allowExactDuplicates, env)) return false;
} else {
if (! o1.equals(o2)) return false;
}
}
} else if (val1 instanceof AnnotationInstance) {
if (! (val2 instanceof AnnotationInstance)) return false;
if (! annotationsAreEqual((AnnotationInstance) val1, (AnnotationInstance) val2, allowExactDuplicates, env)) return false;
} else if (! val1.equals(val2)) {
return false;
}
}
return true;
}