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

Execution of static intializer blocks is premature

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      generic, x86
    • OS:
      solaris_2.5.1, windows_95, windows_nt
    • Verification:
      Not verified

      Description



      Name: sg39081 Date: 08/22/97


        From the VM specification section 2.16.4-

      Initialization of a class consists of executing its static initializers
      and the initializers for static fields declared in the class... A class
      or interface of type T will be initialized at its first active use,
      which occurs if

        T is a class and a method declared in T is invoked
        T is a class and a constructor for class T is invoked
        A non constant field declared in T is used or assigned.

      The current JDK (on all platforms) executes the
      static initializer blocks at class load time
      rather than under one of the conditions given
      above. This has the effect that under JavaSoft's
      VM a Class.forName() will cause the static
      intializer block to be executed in the loaded
      class while under VMs that are correctly
      implemented, this does not happen.
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gbrachasunw Gilad Bracha (Inactive)
              Reporter:
              sgoodsunw Sheri Good (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: