On 20/03/2017 10:56 PM, Daniel Fuchs wrote:
On 20/03/2017 12:37, David Holmes wrote:
What about those API's says there has to be a Java frame higher up. Why
can't an attached thread request a reference to the logger?
Hi David,
Did you look at the webrev?
1582 * @throws IllegalCallerException if there is no caller frame,
i.e.
1583 * when this {@code getLogger} method is called from JNI
1584 * and there is no Java frame on the stack.
This says there must be a frame higher up.
Yes but that is what you are adding. Given the basic method spec:
"Returns an instance of {@link Logger Logger} for the caller's use."
There is nothing about that which suggests any reason why the caller
must have a Java frame on their stack to make the call!
In the case of System.getLogger then the reason is that this
method eventually calls LoggerFinder.getLogger(name, module),
which requires a non null module.
That is an implementation detail.
I don't see any reason why we should accept null or why we should
substitute 'null' with a (randomly picked?) module, especially
since this looks like a pretty unusual corner case which can be
easily worked around (in this case) when the behavior of the method
in the presence of a null caller is known.
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?
Cheers,
David
best regards,
-- daniel