RFR: 8177136: Caller sensitive methods Logger.getLogger, Logger.getAnonymousLogger, and System.getLogger should throw IllegalCallerException if there is no caller on the stack.

Alan Bateman Alan.Bateman at oracle.com
Mon Mar 20 20:38:50 UTC 2017


On 20/03/2017 20:22, David Holmes wrote:

>
> I see this as a basic hole in the whole notion of "current module". 
> Surely if there is no module available then we should be in the 
> unnamed-module?
There isn't any notion of "current module". If there's no caller then 
you can't make any assumptions as to who the caller is. Having these 
methods assume java.base or the unnamed module of some class loader 
doesn't seem right as there just isn't enough context. So having the 
System.getLogger methods throw IllegalCallerException looks like sanest 
thing here. It also doesn't prevent taking a different approach in the 
future.

-Alan


More information about the core-libs-dev mailing list