Open xxh160 opened 1 year ago
@skylot I'd like to provide an additional example:
class T1<M> {
public M foo() {
return null;
}
}
class T2<W> extends T1<Double> {
}
public class Demo2 {
public static double d = new T2<String>().foo();
}
After decompilation with Jadx 1.4.7, the output is transformed as follows:
class T1<M> {
public M foo() {
return null;
}
}
class T2<W> extends T1<Double> {
}
public class Demo2 {
public static double d = new T2().foo().doubleValue();
}
In this case, the generic parameter of T2 in Demo2 is lost, leading to the foo() method's return value being conservatively judged as Object, which ultimately results in a compilation error:
./out/sources/defpackage/Demo2.java:5: error: cannot find symbol
public static double d = new T2().foo().doubleValue();
^
symbol: method doubleValue()
location: class Object
1 error
I hope this will be helpful!
Issue details
In certain scenarios, the generic parameters of a generic class are lost. This leads to a compilation error when inheriting from a generic class that has final methods.
Relevant log output or stacktrace
Provide sample and class/method full name
The example code is as follows:
The decompiled code is as follows:
Jadx version
1.4.7