This is the current specification of java.lang.Class.getEnclosingMethod():
* If this <tt>Class</tt> object represents a local or anonymous
* class within a method, returns a {@link
* java.lang.reflect.Method Method} object representing the
* immediately enclosing method of the underlying class. Returns
* <tt>null</tt> otherwise.
*
* In particular, this method returns <tt>null</tt> if the underlying
* class is a local or anonymous class immediately enclosed by a type
* declaration, instance initializer or static initializer.
*
* @return the immediately enclosing method of the underlying class, if
* that class is a local or anonymous class; otherwise <tt>null</tt>.
* @since 1.5
It is not clear what should happen if this class is a local or anonymous class defined within a constructor. From the first paragraph one can assume that null will be returned, however, that second paragraph does not mention this case.
Currently, the method will throw InternalError("Enclosing method not found").
###@###.### 2004-06-17