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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: