-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
None
-
generic
-
generic
I've just found out that there does not seem to be a way to write:
Logger.global.warning("watch out");
in JDK1.5, so it is not deprecated in JDK1.6.
This forms a slight problem for NetBeans as we just switched to use java.util.logging extensively, and we need to compile on 1.5 as well as 1.6. Right now our code, compiled on 1.6 will throw tons of deprecations and we have no way to prevent them.
The explanation why Logger.global says that this is due to possible deadlocks, but I belive that there could be another solution that would prevent the deadlocks and kept the field usable. Just create a logger delegate:
public static Logger global = new GlobalLoggerDelegate();
class GlobalLoggerDelegate extends Logger {
private Logger delegate;
// overrwites all methods to do lazy init first, then the impl
public void warning(String msg) {
lazyInit();
delegate.warning(msg);
}
private void lazyInit() {
if (delegate == null) {
delegate = getLogger("global");
}
}
}
Logger.global.warning("watch out");
in JDK1.5, so it is not deprecated in JDK1.6.
This forms a slight problem for NetBeans as we just switched to use java.util.logging extensively, and we need to compile on 1.5 as well as 1.6. Right now our code, compiled on 1.6 will throw tons of deprecations and we have no way to prevent them.
The explanation why Logger.global says that this is due to possible deadlocks, but I belive that there could be another solution that would prevent the deadlocks and kept the field usable. Just create a logger delegate:
public static Logger global = new GlobalLoggerDelegate();
class GlobalLoggerDelegate extends Logger {
private Logger delegate;
// overrwites all methods to do lazy init first, then the impl
public void warning(String msg) {
lazyInit();
delegate.warning(msg);
}
private void lazyInit() {
if (delegate == null) {
delegate = getLogger("global");
}
}
}
- duplicates
-
JDK-6476146 Add convenience method for deprecated Logger.global
-
- Closed
-