Sometimes data structures must have certain relationships that cannot be directly described in Java, but it is good to check as early as possible when the code is edited. Classical examples are that the array is large enough or that the enumerations in different modules have corresponding elements.
BOOST provides an excellent C ++ "static assertion" facility that even provides semi-decent errors when assertions fail; Does anyone know how to build a compile-time approval tool in Java?
Edit: I just saw a great example: this class from Eclipse has two constant arrays that are supposed to be the same length. If this was my code, I would like the compiler to tell me if they have different lengths.
java
James
source share