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

Caller sensitive method System::getLogger should specify what happens if there is no caller on the stack.

XMLWordPrintable

        Caller sensitive methods System.getLogger(name) and System.getLogger(name, resourceBundle) currently throw an undocumented NullPointerException if they are called from JNI and there is no Java frame on the stack. These methods are specified to call LoggerFinder to obtain a logger, which requires the module of the caller class.
        When there is no java frame on the stack, then the caller information cannot be obtained and there is not enough context to know which module would be appropriate in this case.
        The NullPointerException should be documented - or another more specific exception should be thrown (and documented) in this case.

        Note: should a JNI attached thread need to obtain a System::Logger it can do so by two other means:

            a) use an auxiliary class that will implicitly be identified as the caller. The module given to the LoggerFinder will then be the auxillary class module.
            or b) access the system LoggerFinder instance (LoggerFinder.getLoggerFinder()) and obtain a logger from it.

        Note however that b) may force the eager initialization of the underlying logging system.

              dfuchs Daniel Fuchs
              dfuchs Daniel Fuchs
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: