title: Java: Why no warning when referencing a field before it is defined?
body: <p>A static field cannot be referenced before it is defined or initialized:</p>
  
  <pre><code>static Integer j = i; /* compile error */
  static final Integer i = 5;
  </code></pre>
  
  <p>However, when it is referenced from an instance initialization block (in an anonymous inner class), not even a warning is generated.</p>
  
  <p>See example:</p>
  
  <pre><code>class StaticInitialization {
  
      static final Object o = new Object() {{
          j = i;
      }};
  
      static Integer j, k;
      static final Integer i = 5;
  
      static final Object o2 = new Object() {{
          k = i;
      }};
  }
  </code></pre>
  
  <p>The result is: <code>j == null</code>, <code>k == 5</code>, so clearly we've made a reference, order matters, and no warning or compilation error.</p>
  
  <p>Is this code legal?</p>