[JSR308] Expression annotations

Eugene Kuleshov eu at javatx.org
Mon Jun 4 22:33:11 EDT 2007


Michael Ernst wrote:
>>   The only argument I have for supporting expression annotations is to 
>> provide some information about expression boundaries in the bytecode. 
>> So, the major difference between expression annotation and cast is that 
>> cast annotation associated with a value, and expression annotation 
>> should be associated with several code ranges.
>>   Unless of course cast annotation would have code ranges association in 
>> the bytecode.
>>     
> Your description of the difference is correct.  Cast annotations do not have
> code ranges:  the cast annotation refers to the type of the value computed
> by the expression, not to the expression itself.
>
> Statement annotations must have code ranges, just as expression annotations
> would.  Thus, statement annotations could serve as a surrogate for
> expression annotations (with the minor inconvenience that a programmer must
> factor out the given expression into a separate statement).  
  That could be troublesome, at least for 
LocalVariableDeclarationStatement production, because it would introduce 
ambiguity for variable declaration annotation.

  One option to address that is to require variable declaration 
annotation should be presented in the bytecode with code ranges for the 
right part of the declaration. Since current variable declarations 
aren't presented in the bytecode, we don't have conflict there.
> Since I believe that there are more good use cases for statement annotations than
> for expression annotations, and since many of the implementation issues are
> the same, I think we should focus first on statement annotations.  If
> statement annotations work out well, then we can decide whether we also
> want expression annotations.
>   
  Make sense to me, but it would be interesting to hear opinions from 
other members of the expert group.

  regards,
  Eugene





More information about the JSR308 mailing list