String templates and constant expressions
Jens Lideström
jens at lidestrom.se
Sat Apr 15 17:46:07 UTC 2023
Dear experts and observers,
A recent message in the thread "Revisit the String template syntax" compared the Spring property annotation syntax with the proposed String template syntax.
@Value("${myproperty}")
private String myproperty;
I have the somewhat vague question: Are there any relation between the use case of these property annotations and the use case of string templates?
The argument of the @Value annotation must be a String constant expression.
Can a string template be used as a constant expression? Maybe if all its arguments are themselves are constants? Could a property syntax such as Spring's use string templates?
Could code like the following do anything sensible?:
@Value("\{someTemplateArg}")
private String someField;
Maybe like this:
@Value("\{MyProperties.SOME_PROPERTY_KEY}")
private String someField;
Maybe there is no relation and the answer is simply "no". But maybe it worth to think about.
I don't see constant expressions mentioned in the JEP: https://openjdk.org/jeps/430
Regards,
Jens Lideström
PS: This feature in general seems very good to me.
More information about the amber-spec-comments
mailing list