Hi Joe,
Thanks, I appreciate your feedback very much!
There was one more thing I wanted to discuss: there is something that
might be improved in the AnnotationInvocationHandler#validateAnnotationMethods
and I wanted to know if it makes sense to go ahead with the change.
There are `if` statements that set the variable called `valid` to false
in case validation fails. Later, depending on the value of the `valid`, an
instance of AnnotationFormatError being thrown. I was thinking if it makes sense
to simplify the validation loop (this is not the complete diff - just gives a
gist of what I mean):
@@ -493,10 +493,7 @@ class AnnotationInvocationHandler implements
InvocationHandler, Serializable {
* Specification citations below are from JLS
* 9.6.1. Annotation Type Elements
*/
- boolean valid = true;
- Method currentMethod = null;
for(Method method : memberMethods) {
- currentMethod = method;
int modifiers = method.getModifiers();
// Skip over methods that may be a static initializer or
// similar construct. A static initializer may be used for
@@ -524,8 +521,7 @@ class AnnotationInvocationHandler implements
InvocationHandler, Serializable {
method.isDefault() ||
method.getParameterCount() != 0 ||
method.getExceptionTypes().length != 0) {
- valid = false;
- break;
+ throw newAnnotationFormatErrorOf(method);
}
...
}
- if (valid)
- return;
- else
- throw new AnnotationFormatError("Malformed method on an annotation
type: " +
- currentMethod.toString());
+ }
+
+ private static AnnotationFormatError newAnnotationFormatErrorOf(Method
malformedMethod) {
+ return new AnnotationFormatError("Malformed method on an annotation
type: " + malformedMethod);
}
What do you think? Does it make sense?
Thanks,
Sergei
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, July 6th, 2021 at 16:01, Joe Darcy <[email protected]> wrote:
> Hello,
>
> I should be able to look at this within the next week or two; thanks,
>
> -Joe
>