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

java.lang.RuntimeException: can not merge I and Z #11

Open
ajinabraham opened this issue May 13, 2015 · 4 comments
Open

java.lang.RuntimeException: can not merge I and Z #11

ajinabraham opened this issue May 13, 2015 · 4 comments

Comments

@ajinabraham
Copy link

classes-errors.zip : https://mega.co.nz/#!qkxwTQTb!9kE-_dhSV1-zREysVsSp4ERHFynrVTWUAU_HijsY4rA

@pxb1988
Copy link
Owner

pxb1988 commented May 14, 2015

java.lang.RuntimeException: can not merge I and Z on following method

.method public b(Z)V
    .registers 4
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    invoke-static { v0 }, Lcom/twitter/android/TweetActivity;->b(Lcom/twitter/android/TweetActivity;)Z
    move-result v0
    if-nez v0, :L0
    if-eqz p1, :L0
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    const v1, 2131624898
    invoke-virtual { v0, v1 }, Lcom/twitter/android/TweetActivity;->findViewById(I)Landroid/view/View;
    move-result-object v0
    const/4 v1, 0
    invoke-virtual { v0, v1 }, Landroid/view/View;->setVisibility(I)V
    :L0
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    invoke-static { v0, p1 }, Lcom/twitter/android/TweetActivity;->a(Lcom/twitter/android/TweetActivity;I)Z
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    iget-object v0, v0, Lcom/twitter/android/TweetActivity;->g:Landroid/widget/Button;
    iget-object v1, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    iget-object v1, v1, Lcom/twitter/android/TweetActivity;->e:Lcom/twitter/android/composer/TweetBox;
    invoke-virtual { v1 }, Lcom/twitter/android/composer/TweetBox;->j()Z
    move-result v1
    invoke-virtual { v0, v1 }, Landroid/widget/Button;->setEnabled(Z)V
    return-void
.end method

notice the line invoke-static { v0, p1 }, Lcom/twitter/android/TweetActivity;->a(Lcom/twitter/android/TweetActivity;I)Z.
p1 is defined as Z (boolean) but used as I(int)

the problem is caused by strict type calculation, because in java syntaxt, a boolean can not assign to an inteager. so dex2jar forbid merge type Z and I. It is simple to fix

  • modify the dex by hand and add the following code before invoke-static { v0, p1 }, Lcom/twitter/android/TweetActivity;->a(Lcom/twitter/android/TweetActivity;I)Z
if-eqz p1, :LZERO
    const p1, 1
    goto :Lend
:LZERO
    const p1, 0
:Lend
  • OR modify the dex2jar code. return Type I when merge I and Z at com.googlecode.dex2jar.ir.TypeClass.merge(TypeClass.java:100)

merge to #10

@pxb1988 pxb1988 changed the title Reporting a Bug java.lang.RuntimeException: can not merge I and Z May 14, 2015
@blackjack4494 blackjack4494 mentioned this issue May 23, 2015
@pxb1988 pxb1988 mentioned this issue Jan 22, 2016
@Dhoundiyal
Copy link

got same error dex2jar 2.0

@amitfegade121
Copy link

java.lang.RuntimeException: can not merge I and Z on following method

.method public b(Z)V
    .registers 4
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    invoke-static { v0 }, Lcom/twitter/android/TweetActivity;->b(Lcom/twitter/android/TweetActivity;)Z
    move-result v0
    if-nez v0, :L0
    if-eqz p1, :L0
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    const v1, 2131624898
    invoke-virtual { v0, v1 }, Lcom/twitter/android/TweetActivity;->findViewById(I)Landroid/view/View;
    move-result-object v0
    const/4 v1, 0
    invoke-virtual { v0, v1 }, Landroid/view/View;->setVisibility(I)V
    :L0
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    invoke-static { v0, p1 }, Lcom/twitter/android/TweetActivity;->a(Lcom/twitter/android/TweetActivity;I)Z
    iget-object v0, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    iget-object v0, v0, Lcom/twitter/android/TweetActivity;->g:Landroid/widget/Button;
    iget-object v1, p0, Lcom/twitter/android/vj;->a:Lcom/twitter/android/TweetActivity;
    iget-object v1, v1, Lcom/twitter/android/TweetActivity;->e:Lcom/twitter/android/composer/TweetBox;
    invoke-virtual { v1 }, Lcom/twitter/android/composer/TweetBox;->j()Z
    move-result v1
    invoke-virtual { v0, v1 }, Landroid/widget/Button;->setEnabled(Z)V
    return-void
.end method

notice the line invoke-static { v0, p1 }, Lcom/twitter/android/TweetActivity;->a(Lcom/twitter/android/TweetActivity;I)Z.
p1 is defined as Z (boolean) but used as I(int)

the problem is caused by strict type calculation, because in java syntaxt, a boolean can not assign to an inteager. so dex2jar forbid merge type Z and I. It is simple to fix

  • modify the dex by hand and add the following code before invoke-static { v0, p1 }, Lcom/twitter/android/TweetActivity;->a(Lcom/twitter/android/TweetActivity;I)Z
if-eqz p1, :LZERO
    const p1, 1
    goto :Lend
:LZERO
    const p1, 0
:Lend
  • OR modify the dex2jar code. return Type I when merge I and Z at com.googlecode.dex2jar.ir.TypeClass.merge(TypeClass.java:100)

merge to #10

Can you tell us please where to modify or make changes?
Thanks in advanced.

@Nirvanchik
Copy link

Got the same error when decoding my app. Mostly errors come from Google support-lib code.
Why not make a command-line flag to ignore this error?
Manipulation with bytecode is a hard job not worthing to spend time to (especially when my app has 72 errors of this type).

netlovehf pushed a commit to netlovehf/dex2jar that referenced this issue Oct 27, 2021
Fix some possible issues everywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants