I am building some static analysis tools to help manage the architecture of a large project. For this I am doing a couple of regexes to parse information from Java files. One of these regexes is used to scan for an @WebService(... ) annotation.
I was wondering if there is a situation possible where there are parentheses in an @WebService annotation (withhelding the ones at the start and end, and any in String literals or comments). So the ones in
@WebService(serviceName="bla()" /* bla() */);
are ok; whereas the ones in
@WebService( ... ( ... ) ...);
are not.
Does the latter ever occur?
Yes, there can be parenthesis even outside of string literals.
In general, annotations can have constant expressions as arguments, that evaluate to a primitive, String, Class, Enum, Annotation or Array. String literals, annotations parameters and expressions can contain parenthesis. The following declaration is valid:
@WebService(serviceName="bla()" + ("bla") + (2 * 3));
The annotation could also contain comments that include parenthesis:
@WebService(serviceName="bla()" /* ( ) */);
@WebService( // ( )
serviceName="bla()");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With