ucla-pls / jreduce

JReduce is a tool to reduce Java ByteCode
BSD 3-Clause "New" or "Revised" License
12 stars 2 forks source link

NotSubtype thrown while typechecking an ArrayStore opcode #3

Closed akshayutture closed 3 years ago

akshayutture commented 3 years ago

Even without the --dump option, the benchmark below crashes for Jreduce

Here is the app+lib.jar file https://drive.google.com/file/d/1ZJuoszSs6eDEsoimyyQMCMWBR4ppnqGO/view?usp=sharing

Here is the command used and the output

kalhauge commented 3 years ago

The main error that you encounter is while type checking the method:

io/reactivex/internal/operators/observable/ObservableAmb.subscribeActual:(Lio/reactivex/Observer;)V

and at the opcode:

Just (ByteCodeInst {offset = 104, opcode = ArrayStore ARef})

the typechecker throw:

NotSubtype (TRef ["Lio/reactivex/ObservableSource;"]) (TRef ["Lio/reactivex/Observable;","Lio/reactivex/ObservableSource;"])

I think that the error code should be improved, to me more readable, but that will not fix the problem you are facing.

Inspecting the app+lib.jar, here ObservableSource is a super interface of Observable. Which means that correctly that ObservableSource is not a subtype of Observable and ObservableSource.

It looks like the problem might be due to a typing problem, while storing in an array, in Java: https://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29#Covariant_arrays_in_Java_and_C.23

And currently, Jreduce, sadly, does not support covariant arrays.

Inspecting the decompiled code, my hypothesis seems to be correct, but if you have access to the source code, can you verify that the code in io/reactivex/internal/operators/observable/ObservableAmb.subscribeActual uses arrays covariance.

akshayutture commented 3 years ago

No there is no source code available. That class is from the library code. I guess we will have to rely on the decompiler output (assuming the decompiler will add back Generics that were erased in compilation)

Okay, I shall skip this benchmark in that case.