Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Recompilation issue with incomplete type hierarchy and nested classes #1512

Closed
nitram84 opened this issue Jun 4, 2022 · 1 comment
Labels
bug Core Issues in jadx-core module

Comments

@nitram84
Copy link
Contributor

nitram84 commented Jun 4, 2022

In this example I'm trying to decompile a library which references a dependent lib that is not available for decompilation with jadx. Let's take these two classes:

// defined in dependent lib, not reachable for jadx
package jadx;
public class BaseClass {

  public int doSomething() {
    return 0;
  }
}
// Target class for recompilation
package jadx;
public class OuterClass {

  public static class NestedClass extends BaseClass {

    @Override
    public int doSomething() {
      return super.doSomething();
    }
  }
}

If BaseClass is not available for decompilation jadx (latest git version) generates this non compilable code:

package jadx;
public class OuterClass {

  public static class NestedClass extends BaseClass {

    public int doSomething() {
      return OuterClass.super.doSomething();
    }
  }
}

We can simulate the missing base class with two smali files:

.class public Ljadx/OuterClass;
.super Ljava/lang/Object;
.source "OuterClass.java"

.annotation system Ldalvik/annotation/MemberClasses;
  value = {
    Ljadx/OuterClass$NestedClass;
  }
.end annotation

.method public constructor <init>()V
  .registers 1
  .prologue
  .line 2
    invoke-direct { p0 }, Ljava/lang/Object;-><init>()V
    return-void
.end method
.class public Ljadx/OuterClass$NestedClass;
.super Ljadx/BaseClass;
.source "OuterClass.java"

.annotation system Ldalvik/annotation/EnclosingClass;
  value = Ljadx/OuterClass;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
  accessFlags = 9
  name = "NestedClass"
.end annotation

.method public constructor <init>()V
  .registers 1
  .prologue
  .line 5
    invoke-direct { p0 }, Ljadx/BaseClass;-><init>()V
    return-void
.end method

.method public doSomething()I
  .registers 2
  .prologue
  .line 8
    invoke-super { p0 }, Ljadx/BaseClass;->doSomething()I
    move-result v0
    return v0
.end method

I'm aware that most cases with missing type hierarchy aren't fixable. But according to smali representation, I think this one is fixable.

@nitram84 nitram84 added bug Core Issues in jadx-core module labels Jun 4, 2022
@skylot
Copy link
Owner

skylot commented Jun 5, 2022

@nitram84 thanks for test case! It helps me to resolve several root causes of this issue 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants