Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8177155 Examine @CS methods when called from attached thread with no caller
  3. JDK-8281001

Class::forName(String) defaults to system class loader if the caller is null

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Fixed
    • P4
    • 19
    • 8
    • core-libs
    • None

    Description

      The current behavior of Class::forName(String className) if invoked via JNI code with no Java frame on the stack will use the boot loader to find class. In addition, the caller's loader is also used to check against the package access check (that check will be removed in the future. See JDK-8218203).

      JNI FindClass uses the system class loader instead if invoked via JNI invocation interface when there is no associated class loader.

      We should re-examine if we should make Class::forName when invoked by JNI code with no caller frame be consistent with JNI FindClass, i.e. use the system class loader if caller is null.

      The same behavior should apply to the following caller-sensitive methods related to class loading:
      Package::getPackage, Package::getPackages
      Runtime::load, Runtime::loadLibrary
      System::load, System::loadLibrary

      Attachments

        Issue Links

          Activity

            People

              tprinzing Tim Prinzing
              mchung Mandy Chung
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: