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] Use of incorrect Object type in synthetic methods #913

Closed
bagipro opened this issue Apr 23, 2020 · 15 comments
Closed

[core] Use of incorrect Object type in synthetic methods #913

bagipro opened this issue Apr 23, 2020 · 15 comments
Labels
bug Core Issues in jadx-core module

Comments

@bagipro
Copy link
Collaborator

bagipro commented Apr 23, 2020

Hi, I've noticed that many synthetic methods are corrupted. Example in class com.google.android.gms.internal.measurement.Df

public final class Df implements android.os.Parcelable.Creator<com.google.android.gms.internal.measurement.zzx> {
    public final /* synthetic */ java.lang.Object createFromParcel(android.os.Parcel parcel) {
    public final /* synthetic */ java.lang.Object[] newArray(int i) {

Type com.google.android.gms.internal.measurement.zzx should be used instead of java.lang.Object

APK: https://drive.google.com/file/d/1ICfL4A22K-KhVkw5RwvWdLJA8111iYvG/view?usp=sharing

@bagipro bagipro added bug Core Issues in jadx-core module labels Apr 23, 2020
@bagipro
Copy link
Collaborator Author

bagipro commented May 10, 2020

@skylot
Can you please look at this one? It really breaks a lot of things and almost all method resolutions

@skylot
Copy link
Owner

skylot commented May 11, 2020

@sergey-wowwow I made a fix for this case, please check.

@skylot skylot closed this as completed May 11, 2020
@bagipro
Copy link
Collaborator Author

bagipro commented May 11, 2020

@skylot
Thanks, also fixes the most of the problems! But in class retrofit2.Retrofit

Before

    public <T> retrofit2.Converter<T, java.lang.String> stringConverter(java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotationArr) {
        retrofit2.Utils.checkNotNull(type, "type == null");
        retrofit2.Utils.checkNotNull(annotationArr, "annotations == null");
        int size = this.converterFactories.size();
        for (int i = 0; i < size; i++) {
            retrofit2.Converter stringConverter = this.converterFactories.get(i).stringConverter(type, annotationArr, this);
            if (stringConverter != null) {
                return stringConverter;
            }
        }
        return retrofit2.BuiltInConverters.ToStringConverter.INSTANCE;
    }

Now

    /* JADX WARN: Type inference failed for: r2v3, types: [retrofit2.Converter, retrofit2.Converter<T, java.lang.String>], assign insn: 0x001b: INVOKE  (r2v3 ? I:retrofit2.Converter) = 
      (r2v2 retrofit2.Converter$Factory)
      (r4v0 java.lang.reflect.Type)
      (r5v0 java.lang.annotation.Annotation[])
      (r3v0 'this' retrofit2.Retrofit A[THIS])
     type: VIRTUAL call: retrofit2.Converter.Factory.stringConverter(java.lang.reflect.Type, java.lang.annotation.Annotation[], retrofit2.Retrofit):retrofit2.Converter */
    public <T> retrofit2.Converter<T, java.lang.String> stringConverter(java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotationArr) {
        retrofit2.Utils.checkNotNull(type, "type == null");
        retrofit2.Utils.checkNotNull(annotationArr, "annotations == null");
        int size = this.converterFactories.size();
        for (int i = 0; i < size; i++) {
            ? stringConverter = this.converterFactories.get(i).stringConverter(type, annotationArr, this);
            if (stringConverter != 0) {
                return stringConverter;
            }
        }
        return retrofit2.BuiltInConverters.ToStringConverter.INSTANCE;
    }

@bagipro
Copy link
Collaborator Author

bagipro commented May 11, 2020

And one more in class com.google.android.gms.wallet.zzb

public final class zzb implements android.os.Parcelable.Creator<com.google.android.gms.wallet.zza> {
    @Override // android.os.Parcelable.Creator
    public final /* synthetic */ java.lang.Object[] newArray(int i) {
        return new com.google.android.gms.wallet.zza[i];
    }

@bagipro
Copy link
Collaborator Author

bagipro commented May 12, 2020

Sorry, tested on this APK https://drive.google.com/file/d/1qC3tlWs9AtPBpyS6iU9kcSphLryfJOxi/view?usp=sharing two last bugs

@skylot
Copy link
Owner

skylot commented May 12, 2020

@sergey-wowwow
The second case fixed.
For the first case, I made a useful workaround: type inference will fallback to raw type if generics can't be resolved correctly. To correctly fix this case additional casts must be inserted, check original source code (notice (Converter<T, String>) cast on returns). I will try to implement this later.

@bagipro
Copy link
Collaborator Author

bagipro commented May 12, 2020

@skylot
One more issue in class com.ebay.nautilus.domain.content.DmResultAdapter

    private static final class ContentAsResult<Data> extends com.ebay.nautilus.domain.content.DmResultAdapter<Data, com.ebay.nautilus.domain.content.Content<Data>> {
        //...

        @Override // com.ebay.nautilus.domain.content.DmResultAdapter
        @androidx.annotation.NonNull
        public com.ebay.nautilus.domain.content.Content<Data> createResult(@androidx.annotation.NonNull Data data) {
            return new com.ebay.nautilus.domain.content.Content<>((java.lang.Object) data); // invalid cast to Object
        }
    }

@bagipro
Copy link
Collaborator Author

bagipro commented May 12, 2020

And the last thing probably related to the root issue. Class com.google.android.gms.internal.ads.zzada

final class zzada implements com.google.android.gms.internal.ads.zzanl<com.google.android.gms.internal.ads.zzaqw> {
    //...

    @Override // com.google.android.gms.internal.ads.zzanl
    public final /* synthetic */ void zzh(java.lang.Object obj) { // Error! "com.google.android.gms.internal.ads.zzada" should be here
        ((com.google.android.gms.internal.ads.zzaqw) obj).destroy();
    }
}
package com.google.android.gms.internal.ads;

public interface zzanl<V> {
    void zzb(java.lang.Throwable th);

    void zzh(@javax.annotation.Nullable V v);
}

@bagipro
Copy link
Collaborator Author

bagipro commented May 12, 2020

And thanks for the fixes, I see that they resolve all the bugs and don't create new ones! :D

@bagipro
Copy link
Collaborator Author

bagipro commented May 16, 2020

@skylot
Let's please finish those ones to make method arguments correct :)

@skylot
Copy link
Owner

skylot commented May 17, 2020

@sergey-wowwow
Another fix. Not sure, but it can break something because depends on decompilation order :(

@bagipro
Copy link
Collaborator Author

bagipro commented May 17, 2020

Thanks @skylot,
Seems to fix all the listed problems!

Please check androidx.arch.core.internal.SafeIterableMap

    public V putIfAbsent(@androidx.annotation.NonNull K k, @androidx.annotation.NonNull V v) {
        androidx.arch.core.internal.SafeIterableMap.Entry entry = get(k); // should be parametrized with <K, V>
        if (entry != null) {
            return entry.mValue; // error!
        }
        put(k, v);
        return null;
    }

and similar thing in kotlinx.coroutines.internal.ArrayQueue

public class ArrayQueue<T> {
    private java.lang.Object[] elements = new java.lang.Object[16];
    //...

    @org.jetbrains.annotations.Nullable
    public final T removeFirstOrNull() {
        int i = this.head;
        if (i == this.tail) {
            return null;
        }
        T[] tArr = this.elements; // error!

@bagipro
Copy link
Collaborator Author

bagipro commented May 17, 2020

And one more thing, class io.reactivex.internal.operators.observable.ObservableAny

    public void subscribeActual(io.reactivex.Observer<? super java.lang.Boolean> observer) {

But java.lang.Boolean is a final class, and ? super java.lang.Boolean is illegal type

@bagipro
Copy link
Collaborator Author

bagipro commented May 29, 2020

@skylot
Let's finish this one please. For other similar bugs I will open new tickets

@bagipro
Copy link
Collaborator Author

bagipro commented Jun 17, 2020

@skylot
Just noticed it :D Thanks for the fix!

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