Skip to content

[core] Redundant "synchronized" block on static synchronized methods #2493

@HelloOO7

Description

@HelloOO7

Issue details

When decompiling a method marked static synchronized, the JADX output looks like this:

public static synchronized void preload() {
    synchronized (AppCompatDrawableManager.class) {
        //method body
    }
}

Whereas the original source code (see AndroidX sources) looks like:

public static synchronized void preload() {
    //method body
}

This is in contrast to non-static synchronized methods, such as onConfigurationChanged in the same class, which looks "correct" in JADX as well:

public synchronized void onConfigurationChanged(Context context) {
    this.mResourceManager.onConfigurationChanged(context);
}

It seems that on static synchronized methods, JADX both interprets the declared-synchronized modifier and the compiler-generated monitor-enter/monitor-exit, which results in the "doubled" redundant locking pattern. I don't think this is more than a cosmetic issue, but the inconsistency with non-static methods leads me to believe that it could be a bug.

Relevant log output or stacktrace

Provide sample and class/method full name

Any class with a static synchronized and non-static synchronized method, such as those in AppCompat:
https://github.com/androidx/androidx/blob/androidx-main/appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatDrawableManager.java

Jadx version

Nightly r2441.ec726d6

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreIssues in jadx-core modulebug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions