I doubt 303 will ever be able to constant fold a non-final virtual method in this manner.  Enums can override toString(), and can do so via separate compilation; this seems like it would be too big of a surprise to users.  Virtual methods are much riskier to constant fold than static ones (in part, because it's action-at-a-distance; a declaration modifier on a supertype causes folding of a method in a subtype.)

On 7/9/2018 4:52 AM, Maurizio Cimadamore wrote:
Remi is correct - 303 has the potential to special case toString() method calls on enums. One thing that 303 lacks, at least at the moment, is the ability to redefine what goes into places where a constant expression is expected (case labels, annotations, ...). That is, the additional constant propagation occurs *after* type-checking, and it's mostly there to support code generation. What you ask would have an impact on the language frontend (and would therefore require some spec text for it) - I'm unsure as to whether this falls within the scope of 303.

Maurizio


On 09/07/18 07:39, Remi Forax wrote:
JEP 303 (http://openjdk.java.net/jeps/303) allows to build such kind of constants, i don't know if it works in the context of annotations but it's a nice use case.


Reply via email to