启用时,android.enableR8.fullMode=true
我收到以下警告:
AGPBI: {
"kind": "warning",
"text": "The method `void org.apache.commons.logging.impl.Log4JLogger.<clinit>()`
does not type check and will be assumed to be unreachable.",
"sources": [{}],
"tool": "R8"
}
如何明确地org.apache.commons.logging.impl.Log4JLogger.<clinit>()
与 R8 保持一致?android.enableR8.fullMode=false
(默认设置)不是可接受的解决方法,即使static
初始化程序<clinit>
不会得到类似的优化。被剥离的代码是这样的:
// ------------------------------------------------------------
// Static Initializer.
//
// Note that this must come after the static variable declarations
// otherwise initialiser expressions associated with those variables
// will override any settings done here.
//
// Verify that log4j is available, and that it is version 1.2.
// If an ExceptionInInitializerError is generated, then LogFactoryImpl
// will treat that as meaning that the appropriate underlying logging
// library is just not present - if discovery is in progress then
// discovery will continue.
// ------------------------------------------------------------
static {
if (!Priority.class.isAssignableFrom(Level.class)) {
// nope, this is log4j 1.3, so force an ExceptionInInitializerError
throw new InstantiationError("Log4J 1.2 not available");
}
// Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
// versions do not. If TRACE is not available, then we have to map
// calls to Log.trace(...) onto the DEBUG level.
Priority _traceLevel;
try {
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
} catch(Exception ex) {
// ok, trace not available
_traceLevel = Level.DEBUG;
}
traceLevel = _traceLevel;
}