Argument of annotation needs to be a constant, but final val does not qualify

In this snippet,

@SwaggerDefinition(...authorizationUrl = SecurityConstants.authorizationUrl)

and given that

final object SecurityConstants {
  final val authorizationUrl: String =..

(only one of the two finals should be ok, but still)
I was expecting/hoping that this would compile with 2.12.3 but it is however giving
"annotation argument needs to be a constant; found: SecurityConstants.authorizationUrl
[error] authorizationUrl = SecurityConstants.authorizationUrl,"

Also calling Java static method System.getenv(“a”) in annotation brings the same error, that is

@SwaggerDefinition(...authorizationUrl = System.getenv("a"))

Please help,
Nicu M

See this recent discussion.

1 Like

Hi, Thanks, now with constant values it works. But as soon as I need to compute the value, from java static method calls like System.getProperty it fails. Can this be made to work? Thank you…