-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
6u10
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
java.util.logging.Logger has the following field:
private boolean anonymous
In your current code, the only way that this field can get set to true (in order to create an actual anonymous logger, that bypasses security checks etc) is if you call the static getAnonymousLogger factory method.
But think about it: that's a disaster, since it means that it is actually impossible for a subclass of Logger to exist if that subclass needs the ability to be a truly anonymous Logger!
JUSTIFICATION :
People need to be able to create subclasses of Logger which can be created in truly anonymous versions (e.g. for use in applets).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the anonymous field to somehow be accessible for subclasses to set.
The best way for you to do this is to add a new constructor that takes a boolean anonymous parameter. In particular, in addition to the existing
protected Logger(String name, String resourceBundleName)
constructor, you should add one like this:
protected Logger(String name, String resourceBundleName, boolean anonymous)
ACTUAL -
There is no good way for subclasses to set this field.
CUSTOMER SUBMITTED WORKAROUND :
Nothing good.
You can have your Logger subclass have its own internal Logger field that you delegate most work to, and then if you need anonymous capability you can create that Logger field using Logger.getAnonymousLogger().
You also may be able to use reflection to bypass the access privleges of the private anonymous field.
But both solutions are nasty and you simply should not have to do them--Logger should have been designed to expose this functionality (e.g. via constructor as mentioned above).
java.util.logging.Logger has the following field:
private boolean anonymous
In your current code, the only way that this field can get set to true (in order to create an actual anonymous logger, that bypasses security checks etc) is if you call the static getAnonymousLogger factory method.
But think about it: that's a disaster, since it means that it is actually impossible for a subclass of Logger to exist if that subclass needs the ability to be a truly anonymous Logger!
JUSTIFICATION :
People need to be able to create subclasses of Logger which can be created in truly anonymous versions (e.g. for use in applets).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the anonymous field to somehow be accessible for subclasses to set.
The best way for you to do this is to add a new constructor that takes a boolean anonymous parameter. In particular, in addition to the existing
protected Logger(String name, String resourceBundleName)
constructor, you should add one like this:
protected Logger(String name, String resourceBundleName, boolean anonymous)
ACTUAL -
There is no good way for subclasses to set this field.
CUSTOMER SUBMITTED WORKAROUND :
Nothing good.
You can have your Logger subclass have its own internal Logger field that you delegate most work to, and then if you need anonymous capability you can create that Logger field using Logger.getAnonymousLogger().
You also may be able to use reflection to bypass the access privleges of the private anonymous field.
But both solutions are nasty and you simply should not have to do them--Logger should have been designed to expose this functionality (e.g. via constructor as mentioned above).