(reflection) Class.getMethods() allows access to <clinit> of interfaces

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 1.2.0
    • Component/s: core-libs
    • None

      using getMethods() on interfaces allows you to see the static initializer for the interface if it has one. here's a test case.

      import java.lang.reflect.*;

      interface i {
          // cause the interface to have a static initializer
          Object o = new Object();
      }

      public class r {
          public static void main(String[] args) throws Exception {
      Method[] methods = Class.forName("i").getMethods();
      for (int i = 0; i < methods.length; i++) {
      if (methods[i].getName().equals("<clinit>"))
      throw new InternalError("shouldn't see clinit");
      }

          }
      }

            Assignee:
            William Maddox (Inactive)
            Reporter:
            Tom Rodriguez
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: