Javadoc (via Maven) is giving me the following error in one my Java JAX-RS interface method signatures:
error: element value must be a constant expression
Here is my JAX-RS interface:
public interface FooResource {
@Consumes(APPLICATION_FORM_URLENCODED_UTF_8)
public void bar();
}
Javdoc gives the error for @Consumes
. Here is the definition for APPLICATION_FORM_URLENCODED_UTF_8
, which appears in MyAppConstants
in the same project:
public static final String APPLICATION_FORM_URLENCODED_UTF_8 =
APPLICATION_FORM_URLENCODED + ";" + CHARSET_PARAMETER + "=UTF-8";
And here is the definition of APPLICATION_FORM_URLENCODED
, which appears in javax.ws.rs.core.MediaType
:
public final static String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
And here is the definition of CHARSET_PARAMETER
, which also appears in javax.ws.rs.core.MediaType
:
public static final String CHARSET_PARAMETER = "charset";
Now I ask you: what about APPLICATION_FORM_URLENCODED_UTF_8
is not constant at compile time?
The error message didn't say that I have to provide a literal. It said I had to provide a constant. So what about this is not a constant?
(I could almost swear that this worked at one time but suddenly stopped working.)
Update: Found cause, but still don't understand.
For some reason, merely including the swagger-maven-plugin
in the POM will trigger this problem! My code doesn't change at all, but as soon as I add the following dependency, suddenly I get Javadoc warnings for my existing code!!!
<dependency>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.5</version>
</dependency>
How can a single dependency make Javadoc work differently on a code file? What is swagger-maven-plugin
doing?
final
keyword is still there? Without it, the class variable loses its constant characteristic. – Trottaclean install
already? – Mitchellfinal
keyword is still there. Yep, I did amvn clean install
. – Mulliganswagger-maven-plugin
is triggering this. But how? See updated question. – Mulliganmvn dependency:tree
and seeing if an oldjavax.ws.rs:jsr311-api
is getting pulled in via some other dependency. – Mulligan