title: Why does Java prohibit static fields in inner classes?
body: <pre><code>class OuterClass {
   class InnerClass {
    static int i = 100; // compile error
    static void f() { } // compile error
   }
  } 
  </code></pre>
  
  <p>Although it's not possible to access the static field with <code>OuterClass.InnerClass.i</code>, if I want to record something that should be static, e.g. the number of InnerClass objects created, it would be helpful to make that field static. So <em>why</em> does Java prohibit static fields/methods in inner classes?</p>
  
  <p>EDIT: I know how to make the compiler happy with static nested class (or static inner class), but what I want to know is why java forbids static fields/methods inside inner classes (or ordinary inner class) from both the language design and implementation aspects, if someone knows more about it.</p>