title: Why isn't getClass() available as a static method?
body: <p>In static contexts, how come you can't call a static version of <code>getClass()</code> (rather than having to use <code>my.package.name.MyClassName.class</code>) ?</p>
  
  <p>Isn't the compiler smart enough to determine when to use object methods + when to use static methods?</p>
  
  <hr>
  
  <p>NOTE for clarity: </p>
  
  <p>I'm not saying that a <code>static getClass()</code> should be used <em>instead</em> of the non-static method <code>getClass()</code> (that's kind of obvious -- if <code>SpecialFoo</code> is a subclass of <code>Foo</code>, then the <code>getClass()</code> of a <code>Foo</code> could return <code>Foo.class</code> or <code>SpecialFoo.class</code> or something else and it has to be determined at runtime). </p>
  
  <p>I'm saying that I'm wondering why aren't there <em>two</em> versions of <code>getClass()</code>, one that is a static method which only applies in a static context, and the regular non-static method <code>getClass()</code>.  If it's not possible, then it's not possible, and that's the answer. If it's possible but just hasn't been done, then it's a historical choice, and maybe there's a good reason for it. That's what I'd like to know.</p>
  
  <p>It would be great to declare</p>
  
  <pre><code>final static Logger logger = LoggerFactory.getLogger(getClass());
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>final static Logger logger = LoggerFactory.getLogger(my.package.name.MyClass.class);
  </code></pre>
  
  <p>where the former could be copied verbatim from one class to the next, whereas the latter requires you to copy the class name in each file.</p>