in ti/phase2/jars/core/src/java/org/apache/ti/compiler/internal/grammar/CatchGrammar.java [122:186]
protected void checkMethod(MethodDeclaration methodBeingChecked, AnnotationValue value,
AnnotationInstance[] parentAnnotations, MemberDeclaration classMember) {
//
// Make sure the current entity (class or action method) doesn't have two @Jpf.Catch annotations
// that refer to methods with duplicate @Jpf.Forwards.
//
Collection catches =
CompilerUtils.getAnnotationArrayValue(classMember, _annotationRootName, CATCHES_ATTR, true);
TypeDeclaration outerType = CompilerUtils.getOuterClass(classMember);
if (catches == null) {
return;
}
for (Iterator ii = catches.iterator(); ii.hasNext();) {
AnnotationInstance catchAnnotation = (AnnotationInstance) ii.next();
//
// Find the method referred to in this annotation. If we can't find it, do nothing -- this
// will get caught elsewhere in the checking.
//
String methodName = CompilerUtils.getString(catchAnnotation, METHOD_ATTR, false);
if (methodName.length() > 0 && ! methodName.equals(methodBeingChecked.getSimpleName())) {
MethodDeclaration otherMethod = findMethod(methodName, outerType);
if (otherMethod != null) {
//
// Look through this other method's forwards. None may have the same name (and different path)
// as the current one.
//
Collection otherForwards =
CompilerUtils.getAnnotationArrayValue(otherMethod, EXCEPTION_HANDLER_TAG_NAME,
FORWARDS_ATTR, false);
for (Iterator i2 = otherForwards.iterator(); i2.hasNext();) {
AnnotationInstance otherForward = (AnnotationInstance) i2.next();
String otherForwardName = CompilerUtils.getString(otherForward, NAME_ATTR, true);
String otherForwardPath = CompilerUtils.getString(otherForward, PATH_ATTR, true);
String otherFwdNavigateTo =
CompilerUtils.getEnumFieldName(otherForward, NAVIGATE_TO_ATTR, true);
Collection forwards =
CompilerUtils.getAnnotationArrayValue(methodBeingChecked,
EXCEPTION_HANDLER_TAG_NAME,
FORWARDS_ATTR, false);
for (Iterator i3 = forwards.iterator(); i3.hasNext();) {
AnnotationInstance forward = (AnnotationInstance) i3.next();
String forwardName = CompilerUtils.getString(forward, NAME_ATTR, true);
String forwardPath = CompilerUtils.getString(forward, PATH_ATTR, true);
String fwdNavigateTo = CompilerUtils.getEnumFieldName(forward, NAVIGATE_TO_ATTR, true);
if (forwardName != null && forwardName.equals(otherForwardName)) {
if ((forwardPath == null || ! forwardPath.equals(otherForwardPath))
&& (fwdNavigateTo == null || ! fwdNavigateTo.equals(otherFwdNavigateTo))) {
addError(value, "error.duplicate-exception-handler-forwards",
new Object[]{methodBeingChecked.getSimpleName(), methodName, forwardName});
}
}
}
}
}
}
}
}