[9] RFR: 8177136: Caller sensitive method System.getLogger should specify what happens if there is no caller on the stack.

Mandy Chung mandy.chung at oracle.com
Wed Mar 22 16:26:44 UTC 2017


> On Mar 21, 2017, at 5:09 PM, David Holmes <david.holmes at oracle.com> wrote:
> 
> Hi Daniel,
> 
> On 22/03/2017 4:41 AM, Daniel Fuchs wrote:
>> Hi Brent,
>> 
>> Here is an updated webrev that incorporates your feedback:
>> 
>> http://cr.openjdk.java.net/~dfuchs/webrev_8177136/webrev.02
> 
> You could move all the detail to the @implSpec method as a clarification on the use of the caller e.g.:
> 
>     * @implSpec
>     * Instances returned by this method route messages to loggers
>     * obtained by calling {@link LoggerFinder#getLogger(java.lang.String,
>     * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where
>     * {@code module} is the caller's module. In cases where there is
>     * no Java caller on the stack (e.g when called directly from a JNI
>     * attached thread) an IllegalCallerException is thrown. To obtain
>     * a logger in such a context ...
> 
> then just:
> 
>   * @throws IllegalCallerException if there is no {@linkplain
>   *         StackWalker#getCallerClass() caller} frame, i.e. this method
>   *         is called from JNI and there is no Java frame on the stack.
> 

I agree this is better.  Also “caller” has been used in existing specs and no need to have the link to StackWalker#getCallerClass which seems not directly relevant here. 

Mandy


More information about the core-libs-dev mailing list