Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5065057

(reflect) Class.getEnclosingMethod unclear spec for local and anon class in ctor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs

      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

            ahe Peter Ahe
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: