LVTI diagnostics anomaly?

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Sep 19 20:09:01 UTC 2017


In the first case, 's' is a local variable in the code; in the second 
case, 's' is a field, which is why it's not allowed. Does it makes sense?

I understand that, looking at the plain diagnostic output w/o also 
looking at the source might be surprising, but I think in  a real world 
case it would be clear as to why it's not allowed?

Of course the 'not allowed' diagnostic can be improved an 'qualified' a 
bit so that it includes some more context.

Maurizio


On 19/09/17 17:30, Stephan Janssen wrote:
> Hey,
>
> The LVTI diagnostics error messages have (according to me) an inconsistency.
> LocalRedundantType.java
>
> examples/LocalRedundantType.java:31: warning: Redundant type for local
> variable (replace explicit type with 'var'). String s = ""; ^ 1 warning
>
>
> The above makes a suggestion to replace the explicit type with 'var', which
> is great.
>
> However, VarNotAllowedHere.java mentions that the above
>
> var s = "";
>
> is not allowed, which confuses me.
> VarNotAllowedHere.java
>
> examples/VarNotAllowedHere.java:29: error: 'var' is not allowed here var s
> = ""; ^ 1 error
>
> Hopefully this helps?
>
> Cheers,
>
> Stephan



More information about the amber-dev mailing list