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

A new Class.forName(String cn, boolean initialize) method

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • tbd
    • 8
    • core-libs
    • None

    Description

      Class.forName(String cn) is a convenient method equivalent to:
         Class.forName(cn, true, currentLoader);

      Class.forName(String) method will load a class and its <clinit> will
      be invoked.

      To load a class but to skip class initialization using the defining loader
      of the caller's class, it will have to call, e.g. if call from an instance method:
         Class.forName(cn, false, this.getClass().getClassLoader());

      Additional comment from Remi Forax [1]:
      > In fact, this method is really useful, most of the tools that does
      > bytecode transformation at runtime (most O/R mappers,
      > dynamic language runtimes, profilers, code coverage tools, etc)
      > are now required to compute the stack frame attribute which requires to
      > compute the lower upper bound of a set of types. For that, being able
      > to crawle the type hierachy without loading the static initializer
      > is a must have.

      [1] http://mail.openjdk.java.net/pipermail/jigsaw-dev/2012-May/002529.html

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mchung Mandy Chung
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Imported:
                Indexed: