APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.logger

public final Class LazyLoggers

extends Object
Class Inheritance
Imports
java.util.function.BiFunction, .BooleanSupplier, java.lang.System.LoggerFinder, .System.Logger, java.lang.ref.WeakReference, java.util.Objects, jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder, jdk.internal.misc.VM, sun.util.logging.PlatformLogger

This class is a factory for Lazy Loggers; only system loggers can be Lazy Loggers.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
LazyLoggers.LazyLoggerAccessor

The LazyLoggerAccessor class holds all the logic that delays the creation of the SPI logger until such a time that the VM is booted and the logger is actually used for logging.

private static class
LazyLoggers.LazyLoggerFactories<
Logger or a subclass of Logger.
L extends System.Logger
>

This class is used to hold the factories that a Lazy Logger will use to create (or map) its wrapped logger.

private static class
LazyLoggers.LazyLoggerWrapper

An implementation of Logger that redirects all calls to a wrapped instance of Logger.

pack-priv static interface

Field Summary

Modifier and TypeField and Description
private static final LazyLoggers.LazyLoggerFactories<System.Logger>
private static final BiFunction<String, Module, System.Logger>
private static volatile System.LoggerFinder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static System.LoggerFinder
public static final System.Logger

Returns:

a (possibly lazy) Logger instance.
getLazyLogger
(String
the logger name
name
,
Module
the module on behalf of which the logger is created.
module
)

Returns a (possibly lazy) Logger suitable for system classes.

public static final System.Logger

Returns:

a (possibly lazy) Logger instance.
getLogger
(String
the logger name
name
,
Module
The module on behalf of which the logger is created. If the module is not loaded from the Boot ClassLoader, the LoggerFinder is accessed and the logger returned by LoggerFinder#getLogger(java.lang.String, java.lang.Module) is returned to the caller directly. Otherwise, the logger returned by getLazyLogger(java.lang.String, java.lang.Module) is returned to the caller.
module
)

Returns a (possibly lazy) Logger for the caller.

pack-priv static System.Logger

Returns:

The logger returned by the LoggerFinder.
getLoggerFromFinder
(String
name of the logger
name
,
Module
module on behalf of which the logger is created
module
)

Gets a logger from the LoggerFinder.

pack-priv static System.Logger
makeLazyLogger(String name, Module module, BooleanSupplier isLoading)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoriesback to summary
private static final LazyLoggers.LazyLoggerFactories<System.Logger> factories
loggerSupplierback to summary
private static final BiFunction<String, Module, System.Logger> loggerSupplier
providerback to summary
private static volatile System.LoggerFinder provider

Constructor Detail

LazyLoggersback to summary
private LazyLoggers()

Method Detail

accessLoggerFinderback to summary
private static System.LoggerFinder accessLoggerFinder()
getLazyLoggerback to summary
public static final System.Logger getLazyLogger(String name, Module module)

Returns a (possibly lazy) Logger suitable for system classes. Whether the returned logger is lazy or not depend on the result returned by BootstrapLogger#useLazyLoggers().

Parameters
name:String

the logger name

module:Module

the module on behalf of which the logger is created.

Returns:System.Logger

a (possibly lazy) Logger instance.

getLoggerback to summary
public static final System.Logger getLogger(String name, Module module)

Returns a (possibly lazy) Logger for the caller.

Parameters
name:String

the logger name

module:Module

The module on behalf of which the logger is created. If the module is not loaded from the Boot ClassLoader, the LoggerFinder is accessed and the logger returned by LoggerFinder#getLogger(java.lang.String, java.lang.Module) is returned to the caller directly. Otherwise, the logger returned by getLazyLogger(java.lang.String, java.lang.Module) is returned to the caller.

Returns:System.Logger

a (possibly lazy) Logger instance.

getLoggerFromFinderback to summary
pack-priv static System.Logger getLoggerFromFinder(String name, Module module)

Gets a logger from the LoggerFinder. Creates the actual concrete logger.

Parameters
name:String

name of the logger

module:Module

module on behalf of which the logger is created

Returns:System.Logger

The logger returned by the LoggerFinder.

makeLazyLoggerback to summary
pack-priv static System.Logger makeLazyLogger(String name, Module module, BooleanSupplier isLoading)
jdk.internal.logger back to summary

private final Class LazyLoggers.JdkLazyLogger

extends LazyLoggerWrapper
Class Inheritance

Field Summary

Inherited from jdk.internal.logger.LazyLoggers.LazyLoggerWrapper:
loggerAccessor

Constructor Summary

AccessConstructor and Description
pack-priv
JdkLazyLogger(String name, Module module)

private

Method Summary

Inherited from jdk.internal.logger.LazyLoggers.LazyLoggerWrapper:
platformProxywrapped

Constructor Detail

JdkLazyLoggerback to summary
pack-priv JdkLazyLogger(String name, Module module)
JdkLazyLoggerback to summary
private JdkLazyLogger(LazyLoggers.LazyLoggerAccessor holder, Void unused)
jdk.internal.logger back to summary

pack-priv final Class LazyLoggers.LazyLoggerAccessor

extends Object
implements LoggerAccessor
Class Inheritance
All Implemented Interfaces
jdk.internal.logger.LazyLoggers.LoggerAccessor

The LazyLoggerAccessor class holds all the logic that delays the creation of the SPI logger until such a time that the VM is booted and the logger is actually used for logging. This class uses the services of the BootstrapLogger class to instantiate temporary loggers if appropriate.

Field Summary

Modifier and TypeField and Description
pack-priv final LazyLoggers.LazyLoggerFactories<? extends System.Logger>
private final BooleanSupplier
private final WeakReference<Module>
pack-priv final String
private volatile PlatformLogger.Bridge
p

private volatile System.Logger
w

Constructor Summary

AccessConstructor and Description
private
private
private
LazyLoggerAccessor(String name, LazyLoggers.LazyLoggerFactories<? extends System.Logger> factories, Module module, BooleanSupplier isLoading, Void unused)

Method Summary

Modifier and TypeMethod and Description
pack-priv System.Logger
pack-priv System.Logger
getConcreteLogger(BootstrapLogger
This accessor's bootstrap logger (usually this is 'w').
bootstrap
)

Replace 'w' by the real SPI logger and flush the log messages pending in the temporary 'bootstrap' Logger.

pack-priv PlatformLogger.Bridge
public String

Returns:

The name of the logger that is / will be lazily created.
getLoggerName
()

Implements jdk.internal.logger.LazyLoggers.LoggerAccessor.getLoggerName.

The logger name.

public static LazyLoggers.LazyLoggerAccessor

Returns:

A new LazyLoggerAccessor.
makeAccessor
(String
The logger name.
name
,
LazyLoggers.LazyLoggerFactories<? extends System.Logger>
The factories that should be used to create the wrapped logger.
factories
,
Module
The module for which the logger is being created
module
)

Creates a new lazy logger accessor for the named logger.

public PlatformLogger.Bridge

Returns:

A PlatformLogger.Bridge view of the wrapped logger.
platform
()

Implements jdk.internal.logger.LazyLoggers.LoggerAccessor.platform.

A PlatformLogger.Bridge view of the wrapped logger.

pack-priv void
release(SimpleConsoleLogger
The temporary logger too be released.
temporary
,
boolean
Whether the released logger should be eagerly replaced.
replace
)

Makes this accessor release a temporary logger.

private void
public System.Logger

Returns:

the logger SPI object.
wrapped
()

Implements jdk.internal.logger.LazyLoggers.LoggerAccessor.wrapped.

Returns the logger SPI object, creating it if 'w' is still null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoriesback to summary
pack-priv final LazyLoggers.LazyLoggerFactories<? extends System.Logger> factories
isLoadingThreadback to summary
private final BooleanSupplier isLoadingThread
moduleRefback to summary
private final WeakReference<Module> moduleRef
nameback to summary
pack-priv final String name
pback to summary
private volatile PlatformLogger.Bridge p
wback to summary
private volatile System.Logger w

Constructor Detail

LazyLoggerAccessorback to summary
private LazyLoggerAccessor(String name, LazyLoggers.LazyLoggerFactories<? extends System.Logger> factories, Module module)
LazyLoggerAccessorback to summary
private LazyLoggerAccessor(String name, LazyLoggers.LazyLoggerFactories<? extends System.Logger> factories, Module module, BooleanSupplier isLoading)
LazyLoggerAccessorback to summary
private LazyLoggerAccessor(String name, LazyLoggers.LazyLoggerFactories<? extends System.Logger> factories, Module module, BooleanSupplier isLoading, Void unused)

Method Detail

createLoggerback to summary
pack-priv System.Logger createLogger()
getConcreteLoggerback to summary
pack-priv System.Logger getConcreteLogger(BootstrapLogger bootstrap)

Replace 'w' by the real SPI logger and flush the log messages pending in the temporary 'bootstrap' Logger. Called by BootstrapLogger when this accessor's bootstrap logger is accessed and BootstrapLogger notices that the VM is no longer booting.

Parameters
bootstrap:BootstrapLogger

This accessor's bootstrap logger (usually this is 'w').

getConcretePlatformLoggerback to summary
pack-priv PlatformLogger.Bridge getConcretePlatformLogger(BootstrapLogger bootstrap)
getLoggerNameback to summary
public String getLoggerName()

Implements jdk.internal.logger.LazyLoggers.LoggerAccessor.getLoggerName.

The logger name.

Returns:String

The name of the logger that is / will be lazily created.

Annotations
@Override
makeAccessorback to summary
public static LazyLoggers.LazyLoggerAccessor makeAccessor(String name, LazyLoggers.LazyLoggerFactories<? extends System.Logger> factories, Module module)

Creates a new lazy logger accessor for the named logger. The given factories will be use when it becomes necessary to actually create the logger.

Parameters
name:String

The logger name.

factories:LazyLoggers.LazyLoggerFactories<? extends System.Logger>

The factories that should be used to create the wrapped logger.

module:Module

The module for which the logger is being created

Returns:LazyLoggers.LazyLoggerAccessor

A new LazyLoggerAccessor.

platformback to summary
public PlatformLogger.Bridge platform()

Implements jdk.internal.logger.LazyLoggers.LoggerAccessor.platform.

A PlatformLogger.Bridge view of the wrapped logger.

Returns:PlatformLogger.Bridge

A PlatformLogger.Bridge view of the wrapped logger.

releaseback to summary
pack-priv void release(SimpleConsoleLogger temporary, boolean replace)

Makes this accessor release a temporary logger. This method is called by BootstrapLogger when JUL is the default backend and LogManager is initialized, in order to replace temporary SimpleConsoleLoggers by real JUL loggers. See BootstrapLogger for more details. If replace is true, then this method will force the accessor to eagerly recreate its wrapped logger.

Note

passing replace=false is no guarantee that the method will not actually replace the released logger.

Parameters
temporary:SimpleConsoleLogger

The temporary logger too be released.

replace:boolean

Whether the released logger should be eagerly replaced.

setWrappedIfNotSetback to summary
private void setWrappedIfNotSet(System.Logger wrapped)
wrappedback to summary
public System.Logger wrapped()

Implements jdk.internal.logger.LazyLoggers.LoggerAccessor.wrapped.

Returns the logger SPI object, creating it if 'w' is still null.

Returns:System.Logger

the logger SPI object.

jdk.internal.logger back to summary

private final Class LazyLoggers.LazyLoggerFactories<L extends System.Logger>

extends Object
Class Inheritance
Type Parameters
<L>
Logger or a subclass of Logger.

This class is used to hold the factories that a Lazy Logger will use to create (or map) its wrapped logger.

Field Summary

Modifier and TypeField and Description
pack-priv final BiFunction<String, Module, L>
loggerSupplier

A factory method to create an SPI logger.

Constructor Summary

AccessConstructor and Description
public
private
LazyLoggerFactories(BiFunction<String, Module, L> loggerSupplier, Void unused)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerSupplierback to summary
pack-priv final BiFunction<String, Module, L> loggerSupplier

A factory method to create an SPI logger. Usually, this will be something like LazyLoggers::getSystemLogger.

Constructor Detail

LazyLoggerFactoriesback to summary
public LazyLoggerFactories(BiFunction<String, Module, L> loggerSupplier)
LazyLoggerFactoriesback to summary
private LazyLoggerFactories(BiFunction<String, Module, L> loggerSupplier, Void unused)
jdk.internal.logger back to summary

private Class LazyLoggers.LazyLoggerWrapper

extends AbstractLoggerWrapper<System.Logger>
Class Inheritance
Known Direct Subclasses
jdk.internal.logger.LazyLoggers.JdkLazyLogger

An implementation of Logger that redirects all calls to a wrapped instance of Logger.

Field Summary

Modifier and TypeField and Description
pack-priv final LazyLoggers.LoggerAccessor

Constructor Summary

AccessConstructor and Description
public
private

Method Summary

Modifier and TypeMethod and Description
pack-priv PlatformLogger.Bridge
pack-priv final System.Logger
Inherited from jdk.internal.logger.AbstractLoggerWrapper:
getLoggerConfigurationgetNamegetWrappedisEnabledisLoggableisLoggableloglogloglogloglogloglogloglogloglogloglogplogplogplogplogplogrblogrblogrblogrb

Field Detail

loggerAccessorback to summary
pack-priv final LazyLoggers.LoggerAccessor loggerAccessor

Constructor Detail

LazyLoggerWrapperback to summary
public LazyLoggerWrapper(LazyLoggers.LazyLoggerAccessor loggerSinkSupplier)
LazyLoggerWrapperback to summary
private LazyLoggerWrapper(LazyLoggers.LazyLoggerAccessor loggerSinkSupplier, Void unused)

Method Detail

platformProxyback to summary
pack-priv PlatformLogger.Bridge platformProxy()

Implements abstract jdk.internal.logger.AbstractLoggerWrapper.platformProxy.

Annotations
@Override
wrappedback to summary
pack-priv final System.Logger wrapped()

Implements abstract jdk.internal.logger.AbstractLoggerWrapper.wrapped.

Annotations
@Override
jdk.internal.logger back to summary

pack-priv Interface LazyLoggers.LoggerAccessor

Known Direct Implementers
jdk.internal.logger.LazyLoggers.LazyLoggerAccessor

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The name of the logger that is / will be lazily created.
getLoggerName
()

The logger name.

public PlatformLogger.Bridge

Returns:

A PlatformLogger.Bridge view of the wrapped logger object.
platform
()

A PlatformLogger.Bridge view of the wrapped logger object.

public System.Logger

Returns:

the wrapped logger object.
wrapped
()

Returns the wrapped logger object.

Method Detail

getLoggerNameback to summary
public String getLoggerName()

The logger name.

Returns:String

The name of the logger that is / will be lazily created.

platformback to summary
public PlatformLogger.Bridge platform()

A PlatformLogger.Bridge view of the wrapped logger object.

Returns:PlatformLogger.Bridge

A PlatformLogger.Bridge view of the wrapped logger object.

wrappedback to summary
public System.Logger wrapped()

Returns the wrapped logger object.

Returns:System.Logger

the wrapped logger object.