title: How to get source file-name/line-number from a java.lang.Class object
body: <p>Is it possible, given a <code>java.lang.Class</code> object, to get the source file name and the line number at which the class was declared? </p>
  
  <p>The data should be available in the <code>.class</code> file's debug info. The only place I know of, where the JDK returns such debug info is in <code>java.lang.StackTraceElement</code> but I'm not sure if it's possible to force Java to create a <code>java.lang.StackTraceElement</code> instance for an arbitrary class, because we are not executing a method in the class.</p>
  
  <p>My exact use case is an anonymous inner class which has a compiler generated name. I want to know the file name and the line number for the class declaration.</p>
  
  <p>I prefer not to use a byte-code manipulation framework, but I can fall back to it if I have to.</p>