2

启用时,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;
}
4

1 回答 1

0

这是按预期工作的,分析的详细信息可以在http://issuetracker.google.com/146478391中看到。

这些也存在一个可能的解决方案,其中涉及确保级别和优先级(级别扩展优先级)之间的关系对于 R8 编译是已知的。

于 2020-01-13T09:26:32.660 回答