@CallerSensitive as public API ?
David M. Lloyd
david.lloyd at redhat.com
Mon Jul 22 16:48:32 UTC 2013
On 07/22/2013 11:22 AM, Paul Benedict wrote:
> I find this issue tangentially related to some open source logging
> libraries. Some create a stack trace just so they can get the name of the
> calling Class instance.
>
> Example:
> Logger log = Logger.createLogger(); // for the current class
>
> Are there any thoughts to directly exposing
> sun.reflect.Reflection.getCallerClass() as a public API?
This is somewhat complicated by two factors: the sea of
loggers-which-log-to-loggers, and the usage of the data acquired. The
common practice is for the "outermost" layer to pass in its own class
name, so that the "innermost" layer can search back on the call stack to
find the last entry before the "outermost" layer, and use this entry to
get not only the class (and method) name, but also the file name and
line number from the stack trace entry.
--
- DML
More information about the core-libs-dev
mailing list