Annotation Type Var
@Target({FIELD,PARAMETER,LOCAL_VARIABLE})
@Retention(RUNTIME)
@IncompatibleModifiers(modifier=FINAL)
public @interface Var
The parameter or local variable to which this annotation is applied is non-final.
Most references are never modified, and accidentally modifying a reference is a potential source of bugs. To prevent accidental modifications, the accompanying Error Prone check prevents parameters and local variables from being modified unless they are explicitly annotated with @Var.
Since Java 8 can infer whether a local variable or parameter is effectively final
, and
@Var
makes it clear whether any variable is non- final
, explicitly marking local
variables and parameters as final
is discouraged.
The annotation can also be applied to fields, to indicate that the field is deliberately non-final.