} else {
throw new IllegalStateException("impossible");
}
if (!m.isStatic() && !m.getName().equals("<init>")) {
JavaClass c = Repository.lookupClass(className);
// get inherited annotation
TreeSet<AnnotationEnum> inheritedAnnotations = new TreeSet<AnnotationEnum>();
if (c.getSuperclassNameIndex() > 0) {
n = lookInOverriddenMethod(o, c.getSuperclassName(), m, getMinimal);
if (n != null) {
inheritedAnnotations.add(n);
}
}
for (String implementedInterface : c.getInterfaceNames()) {
n = lookInOverriddenMethod(o, implementedInterface, m, getMinimal);
if (n != null) {
inheritedAnnotations.add(n);
}
}
if (DEBUG) {
System.out.println("# of inherited annotations : " + inheritedAnnotations.size());
}
if (!inheritedAnnotations.isEmpty()) {
if (inheritedAnnotations.size() == 1) {
return inheritedAnnotations.first();
}
if (!getMinimal) {
return inheritedAnnotations.last();
}
AnnotationEnum min = inheritedAnnotations.first();
if (min.getIndex() == 0) {
inheritedAnnotations.remove(min);
min = inheritedAnnotations.first();
}
return min;
}
// check to see if method is defined in this class;
// if not, on't consider default annotations
if (!classDefinesMethod(c, m)) {
return null;
}
if (DEBUG) {
System.out.println("looking for default annotations: " + c.getClassName() + " defines " + m);
}
} // if not static
} // associated with method
else if (o instanceof XField) {
className = ((XField) o).getClassName();
kind = Target.FIELD;
} else if (o instanceof String) {
assert false;
className = (String) o;
kind = Target.CLASS;
} else {
throw new IllegalArgumentException("Can't look up annotation for " + o.getClass().getName());
}
// <init> method parameters for inner classes don't inherit default
// annotations
// since some of them are synthetic
if (isParameterToInitMethodofAnonymousInnerClass) {
return null;
}
// synthetic elements should not inherit default annotations
if (isSyntheticMethod) {
return null;
}
try {
XClass c = Global.getAnalysisCache().getClassAnalysis(XClass.class,
DescriptorFactory.createClassDescriptorFromDottedClassName(className));
if (c != null && c.isSynthetic()) {
return null;
}
} catch (CheckedAnalysisException e) {
assert true;
}