skylot / jadx

Dex to Java decompiler
Apache License 2.0
41.91k stars 4.89k forks source link

[gui]: missing log message cause #2329

Closed RuffaloLavoisier closed 3 weeks ago

RuffaloLavoisier commented 3 weeks ago

Issue details

https://github.com/skylot/jadx/blob/4d8a5d66713a198704af7c8b07e9e9a62fd1d713/jadx-plugins/jadx-smali-input/src/main/java/jadx/plugins/input/smali/SmaliConvert.java#L43

Is the grammar of the warning message wrong?

Is it correct to write it as below?

https://github.com/skylot/jadx/blob/4d8a5d66713a198704af7c8b07e9e9a62fd1d713/jadx-plugins/jadx-smali-input/src/main/java/jadx/plugins/input/smali/SmaliConvert.java#L40

Many messages are written in the same way as the first type, so the message is missing.

Jadx version

latest

Java version

17

OS

skylot commented 3 weeks ago

LOG.error("Smali process error", e);

Yes, this is a correct call to log throwable with slf4j, reference from javadoc:

    /**
     * Log an exception (throwable) at the ERROR level with an
     * accompanying message.
     *
     * @param msg the message accompanying the exception
     * @param t   the exception (throwable) to log
     */
    public void error(String msg, Throwable t);

@RuffaloLavoisier if you are not sure how method works please check docs, if still unclear write a simple test code to verify it, like this:

public class Test {
    private static final Logger LOG = LoggerFactory.getLogger(Test.class);

    public static void main(String[] args) {
        try {
            throw new RuntimeException("Test");
        } catch (Exception e) {
            LOG.error("Error", e);
        }
    }
}

will output:

ERROR - Error
java.lang.RuntimeException: Test
    at Test.main(Test.java:11)
RuffaloLavoisier commented 3 weeks ago

@skylot

Thanks, The parameter was 'Throwable'. I missed it.