For further consideration...

Mark Thornton mthornton at optrak.co.uk
Mon Mar 30 14:32:02 PDT 2009


David Goodenough wrote:
> 5 years as near to indefinitely as matters).  I need compiler checkability
> for field references now.
>
>   
Define an annotation

@interface @fieldReference {
    String name();
}

class MyClass {
    @fieldReference("myField") static FieldRef FIELD_REF;

    static {
       // use reflection to set initialise static fields with 
@fieldReference annotations
    }
}

You could use an annotation processor to verify that the @fieldReference 
named valid fields and was attached to a suitable reference field. There 
are probably other ways of doing this, but it does give you the compile 
time check you want without requiring a language change.

Regards
Mark Thornton




More information about the coin-dev mailing list