JDK-7054204 : further separate PlatformLogger from java.util.logging
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2011-06-13
  • Updated: 2012-01-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_minorUnresolved
Related Reports
Relates :  
Relates :  
Description
The PlatformLogger class was added by the following bug ID:

    6882376 4/4 Add internal support for JRE implementation to eliminate
                the dependency on logging

to separate the Java Platform's use of a "logging facility" from the
java.util.logging API and subsystem. This bug is filed to explore
making further changes to separate the PlatformLogger class from the
java.util.logging classes.

Comments
SUGGESTED FIX See the attached 7054204-webrev-cr0.tgz, 7054204-webrev-cr1.tgz and 7054204-webrev-cr2.tgz for the proposed fix at each round of code review.
01-07-2011

EVALUATION The new PlatformLogger method Object getInternalLogger(String name) was renamed to Object getUnderlyingLogger(String name). InternalLogger is an implementation detail that should be restricted to the LoggingProxyImpl class. The PlatformLogger, LoggingSupport, and LoggingProxy classes should talk about an "underlying logging facility" or an "underlying logger" rather than java.util.logging.Logger or InternalLogger.
01-07-2011

EVALUATION Changes to support migrating from j.u.l to PlatformLogger --------------------------------------------------------- PlatformLogger class: - add log(int level, String msg, Throwable t) for com/sun/jmx/trace/TraceManager as a wrapper around existing doLog(level, msg, t) - add logp(int level, String srcClass, String srcMethod, String msg) for com/sun/jmx/trace/TraceManager as a wrapper around new doLogp(level, srcClass, srcMethod, msg) - add logp(int level, String srcClass, String srcMethod, String msg, Throwable t) for com/sun/jmx/remote/util/ClassLogger as a wrapper around new doLogp(level, srcClass, srcMethod, msg, t) - add logp(int level, String srcClass, String srcMethod, String msg, Object param1) for com/sun/security/sasl/util/AbstractSaslImpl as a wrapper around new doLogp(level, srcClass, srcMethod, msg, param1) - add logp(int level, String srcClass, String srcMethod, String msg, Object[] params) for com/sun/security/sasl/util/AbstractSaslImpl as a wrapper around new doLogp(level, srcClass, srcMethod, msg, params) - add entering(String sourceClass, String sourceMethod) for javax/management/relation/MBeanServerNotificationFilter as a wrapper around previously new doLogp(level, srcClass, srcMethod, msg) - add entering(String sourceClass, String sourceMethod, Object param1) for javax/management/relation/MBeanServerNotificationFilter as a wrapper around previously new doLogp(level, srcClass, srcMethod, msg, param1) - add entering(String sourceClass, String sourceMethod, Object[] params) for javax/management/relation/RelationService as a wrapper around previously new doLogp(level, srcClass, srcMethod, msg, params) - add exiting(String sourceClass, String sourceMethod) for javax/management/relation/MBeanServerNotificationFilter as a wrapper around previously new doLogp(level, srcClass, srcMethod, msg) - add Object getInternalLogger(String name) for sun/rmi/runtime/Log as a wrapper around already existing LoggingSupport.getLogger(String) PlatformLogger.LoggerProxy class - add corresponding doLogp() methods to support additions of logp() methods to PlatformLogger class, e.g., a PlatformLogger.logp() method calls the corresponding LoggerProxy.doLogp() or JavaLogger.doLogp() method - refactored existing format(int level, String msg, Throwable thrown) to be a wrapper around new format method - added format(int level, String srcClass, String srcMethod, String msg, Throwable thrown) to handle new logp() support - added format(int level, String srcClass, String srcMethod, String msg, Object param1) to handle new logp() support - added format(int level, String srcClass, String srcMethod, String msg, Object[] params) to handle new logp() support PlatformLogger.JavaLogger class - change existing doLog(int level, String msg, Object... params) method to be a direct call to LoggingSupport.log(); no longer need to convert Objects to Strings since the destination is now an InternalLogger that is part of the Java Platform. - add corresponding doLogp() methods to support additions of logp() methods to PlatformLogger class, e.g., a PlatformLogger.logp() method calls the corresponding LoggerProxy.doLogp() or JavaLogger.doLogp() method LoggingSupport class: - add corresponding logp() methods to support additions of logp() methods to PlatformLogger class, e.g., a PlatformLogger.logp() method calls the corresponding JavaLogger.doLogp() method which calls the corresponding LoggingSupport.logp() method LoggingProxy interface: - add corresponding logp() methods to support additions of logp() methods to PlatformLogger class, e.g., a PlatformLogger.logp() method calls the corresponding JavaLogger.doLogp() method which calls the corresponding LoggingSupport.logp() method which calls the corresponding LoggingProxy.logp() method in the interface implementation LoggingProxyImpl class: - add corresponding logp() methods to support additions of logp() methods to PlatformLogger class, e.g., a PlatformLogger.logp() method calls the corresponding JavaLogger.doLogp() method which calls the corresponding LoggingSupport.logp() method which calls the corresponding LoggingProxyImpl.logp() method which calls the corresponding Logger.logp() method - LoggingProxyImpl.getLogger() calls LogManager.demandInteralLogger() instead of Logger.getLogger() to make sure that an InternaLogger is returned to the PlatformLogger.JavaLogger class. This is how we make sure that PlatformLogger uses get InternalLoggers instead of regular Loggers. - LoggingProxyImpl.getLevelName(Object level) casts the level parameter to InternalLevel. If a non-predefined Level is accidentally passed to LoggingSupport.getLevelName(), then a casting exception will get thrown. However, it doesn't look like current code uses LoggingSupport.getLevelName().
22-06-2011

EVALUATION This bug is being used to make two types of changes to the PlatformLogger infrastructure: - further separate or isolate PlatformLogger from the java.util.logging API - add new infrastructure to support migrating more classes in the JDK repo from java.util.logging to PlatformLogger. Changes to further separate PlatformLogger and j.u.l ---------------------------------------------------- LogManager class: - add package level addAndGetLogger(Logger) that can add a Logger or InternalLogger as needed; returns a ref to the Logger or InternalLogger if it was added or to the existing Logger or InternalLogger if one was found. If the caller is trying to add an InternalLogger, then that InternalLogger will replace any existing regular Logger. This new method solves the no-strong-ref GC problem that exists with addLogger(Logger) followed by getLogger(String). - change addLogger(Logger) to be a wrapper around the new addAndGetLogger() method; had to add a check for a corner case where addLogger(foo) followed by addLogger(foo) returned true in both cases. This method is still synchronized to prevent racing addLogger(foo) calls indifferent threads from both returning true. - change package level demandLogger(String) to use the new addAndGetLogger() method; add a comment warning about trying to over optimize this method. - add new package level demandInternalLogger(String) method so that PlatformLoggers can be sure to get an InternalLogger instead of an arbitrary Logger Logger class: - add new InternalLogger subclass of j.u.l.Logger to permit restricting semantics - change Logger.log() to only allow InternalLoggers to traverse parent Loggers that are part of the Java Platform; note that the "global" Logger and the "root" Logger/RootLogger can be traversed because they are part of the Java Platform. - change private Logger.findResourceBundle(String) to not cache ResourceBundles in InternalLoggers that are not part of the Java Platform - change private Logger.getEffectiveResourceBundleName() to not allow an InternalLogger to traverse parent Loggers that are not part of the Java Platform - InternalLogger.getLogger(String) and InternalLogger.getLogger(String, String) throw a RuntimeException to prevent their use by PlatformLoggers - the various methods that take a Level parameter, e.g., InternalLogger.setLevel(Level), throw a RuntimeException if the specified Level is not part of the Java Platform. Level class: - add new InternalLevel subclass of j.u.l.Level to permit restricting semantics - add package private Level.isPlatformClass(Object) that returns true of the class of the specified object is part of the Java Platform. A class is part of the Java Platform if it was loaded by the bootstrap class loader or the extension class loader. - convert predefined Level values to InternalLevel - change Level.getLocalizedName() to only allow InternalLevels to use a ResourceBundle that is part of the Java Platform. - change Level.readResolve() from private to package level to permit InternalLevel serialization to work - InternalLevel.parse() only parses predefined InternalLevels LogRecord class: - change private LogRecord.isLoggerImplFrame() to recognize InternalLogger as part of the logging implementation
22-06-2011