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

Calling LogRecord.getSourceClassName() and getSourceMethodName() not trigger inference

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The use case:

      would like to be able to call LogRecord.getSourceClassName() and LogRecord.getSourceMethodName() but only to retrieve values set via the Setters (not trigger inference). (setSourceClassName and setSourceMethodName)

      this is currently not possible cleanly, since the getters will call inferCaller, and that has a performance cost and might not be possible in the context it is called (see https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4515935)

      Currently the only way to do this is via reflective access to LogRecord.needToInferCaller and and call when false of LogRecord.getSourceClassName() and LogRecord.getSourceMethodName()...

      Now since JDK 11+ the reflective access causes:
      WARNING: An illegal reflective access operation has occurred
      ...
      WARNING: All illegal access operations will be denied in a future release

      The simplest way would be to add aditional getters that do not trigger inferCaller().



            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: