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

Provide a replacement for sun.reflect.Reflection.getCallerClass

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed
    • P2
    • Resolution: Duplicate
    • 8
    • 9
    • core-libs

    Description

      Class.getResource and ClassLoader.getResource are the APIs to obtain resource files associated with the class and/or classloader. An example in the JDK: ResourceBundle.getBundle finds the caller's class and uses the caller class loader to load a resource bundle. Libraries and frameworks such as Groovy, Log4j need similar capability and also need the ability to filter their implementation classes. Existing code has been using sun.reflect.Reflection.getCallerClass(int depth).

      There is no current way for libraries to support loading resource files on behalf of its immediate caller without explicitly passing the calling Class (for example localization data in GUI applications). See discussion in [1].

      [1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/018353.html

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: