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

<clinit> being called on Class.forName and Class.getDeclaredMethod

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1
    • core-libs
    • None

      (See also Comments).

      Name: mc57594 Date: 02/27/97


      I've noticed that the static class initianalisers are being called when I do a 'Class.getDeclaredMethod'. It probably happens with all the other reflective Class methods as well. Is there no way of reflecting on a class without doing a <clinit>? This could prove really anoying!

      Class c = Class.forName("Test");
      c.getDeclaredMethod("someMethod", {});
      System.out.println("Does it ever get here?");

      class Test {
          static {
              while(true) {
                  System.out.println("Stop me if you can!!!");
              }
          }
      }

      Keep up the good work!

      company - Obsolete , email - ###@###.###
      ======================================================================

            apalanissunw Anand Palaniswamy (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: