title: How to assert something at compile time in Java?
body: <p>Sometimes data structures should have certain relationships that can't be directly described in Java, but that are good to check as early as possible when code is edited. Classic examples are that an array is big enough or that enums in different modules have corresponding members.</p>
  
  <p>BOOST provides a fine "static assert" facility in C++ that even provides half-decent errors when assertions fail; does anyone know how to build a compile-time assertion facility in Java?</p>
  
  <p><strong>Edit:</strong> I just saw a perfect example: <a href="http://kickjava.com/src/org/eclipse/core/internal/localstore/ILocalStoreConstants.java.htm" rel="noreferrer">this</a> class from Eclipse has two constant arrays that are assumed to be the same length. If that were my code, I'd like the compiler to tell me if they have different lengths.</p>