ucla-pls / jreduce

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

JReduce does not work on inputs that does not typecheck #8

Closed kalhauge closed 3 years ago

kalhauge commented 3 years ago

JReduce does not work on inputs that have one or more methods that does not typecheck. As a rule this is not an unreasonable requirement, however there exist some cases where it would be nice to get around it.

One example is:

16:48:37 ├ JReduce
16:48:37 │ ├ Started JReduce.
16:48:37 │ ├ Reading inputs
16:48:37 │ │ └ 0.001s
16:48:37 │ ├ Calculating Initial Problem
16:48:37 │ │ ├ setup
16:48:37 │ │ │ └ 0.001s
16:48:37 │ │ ├ run
16:48:37 │ │ │ └ 0.012s
16:48:37 │ │ └ 0.013s
16:48:37 │ ├ Refining Problem
16:48:37 │ │ └ 0.009s
16:48:37 │ ├ Initializing key function
16:48:37 │ │ ├ Calculating the hierarchy
16:48:37 │ │ │ ├ Load stdlib stubs
16:48:44 │ │ │ │ └ 6.116s
16:48:44 │ │ │ ├ Load project stubs
16:48:44 │ │ │ │ └ 0.210s
16:48:44 │ │ │ ├ Compute hierarchy
16:48:44 │ │ │ │ ├ Could not find: org/apache/http/client/methods/HttpEntityEnclosingRequestBase
16:48:44 │ │ │ │ ├ Could not find: com/squareup/okhttp/RequestBody
16:48:44 │ │ │ │ ├ Could not find: org/apache/http/client/methods/HttpRequestBase
16:48:44 │ │ │ │ ├ Could not find: rx/Observable$OnSubscribe
16:48:44 │ │ │ │ ├ Could not find: org/apache/http/entity/AbstractHttpEntity
16:48:44 │ │ │ │ └ 0.436s
16:48:44 │ │ │ └ 6.763s
16:48:44 │ │ ├ Found 11448 items.
16:48:44 │ │ ├ Found 11440 facts.
16:48:44 │ │ ├ The core is 0 of them.
16:48:44 │ │ └ 6.789s
16:48:44 │ ├ Compute CNF
16:48:44 │ │ ├ Warnings found while computing logical dependencies for okhttp3/internal/Platform$Android.log:(Ljava/lang/String;)V!code
16:48:44 │ │ ├ Could not find "android/util/Log.d:(Ljava/lang/String;Ljava/lang/String;)I"
16:48:45 │ │ ├ Warnings found while computing logical dependencies for retrofit/Platform$Android$2$1.run:()V!code
16:48:45 │ │ ├ Could not find "android/os/Process.setThreadPriority:(I)V"
16:48:45 │ │ ├ Warnings found while computing logical dependencies for retrofit/Platform$Android.defaultClient:()Lretrofit/client/Client$Provider;!code
16:48:45 │ │ ├ Could not find "android/os/Build$VERSION.SDK_INT:I"
16:48:45 │ │ ├ Warnings found while computing logical dependencies for retrofit/Platform.findPlatform:()Lretrofit/Platform;!code
16:48:45 │ │ ├ Could not find "android/os/Build$VERSION.SDK_INT:I"
16:48:45 │ │ ├ Warnings found while computing logical dependencies for retrofit/RxSupport$1.call:(Lrx/Subscriber;)V!code
16:48:45 │ │ ├ Could not find "rx/subscriptions/Subscriptions.from:(Ljava/util/concurrent/Future;)Lrx/Subscription;"
16:48:45 │ │ ├ Could not find "rx/Subscriber.add:(Lrx/Subscription;)V"
16:48:45 │ │ ├ Warnings found while computing logical dependencies for retrofit/RxSupport$2.run:()V!code
16:48:45 │ │ ├ Could not find "rx/Subscriber.isUnsubscribed:()Z"
16:48:45 │ │ ├ Could not find "rx/Subscriber.onNext:(Ljava/lang/Object;)V"
16:48:45 │ │ ├ Could not find "rx/Subscriber.onCompleted:()V"
16:48:45 │ │ ├ Could not find "rx/Subscriber.onError:(Ljava/lang/Throwable;)V"
jreduce: "retrofit/RxSupport.createRequestObservable:(Lretrofit/RxSupport$Invoker;)Lrx/Observable;" Just (ByteCodeInst {offset = 9, opcode = Invoke (InvkStatic (AbsVariableMethodId {variableIsInterface = False, variableMethodId = InRefType {inRefType = "Lrx/Observable;", inRefTypeId = "create:(Lrx/Observable$OnSubscribe;)Lrx/Observable;"}}))}) NotSubtype (TRef ["Lretrofit/RxSupport$1;"]) (TRef ["Lrx/Observable$OnSubscribe;"])
CallStack (from HasCallStack):
  error, called at src/JReduce/Logic.hs:982:31 in jreduce-0.1.0-39Tg3eJEoHe4PbF4qun7ub:JReduce.Logic
kalhauge commented 3 years ago

One solutions is to remove all the methods or depend on false. There are no real support for this yet, but we could do that.

Alternatively, we could make a dependency to a 'bottom' item which in turns depends on all other items. This solution will still allow the tool to do no reduction.

kalhauge commented 3 years ago

Potential work-around to this is to run classes reduction first and then run items+json next.