cuplv / TraceRunner

Tool for generating dynamic traces of android applications.
3 stars 0 forks source link

<init> does not have any overrides #17

Open ftc opened 7 years ago

ftc commented 7 years ago

Trace any android app and the activity initialization looks like the following:

msg {
  type: CALLBACK_ENTRY
  message_id: 0
  thread_id: 1
  callbackEntry {
    class_name: "plv.colorado.edu.mediaplayerexample.MainActivity"
    method_name: "void <init>()"
    param_list {
      type: "plv.colorado.edu.mediaplayerexample.MainActivity"
      object_id: "b2c3664"
    }
    callback_caller_class: "java.lang.Class"
    callback_caller_method: "newInstance"
    method_returnType: "void"
    receiver_first_framework_super: "android.support.v7.app.AppCompatActivity"
  }
  is_activity_thread: true
}

There should be a framework override of on AppCompatActivity.

This is related to isue cuplv/callback-verification#103

ftc commented 7 years ago

Problem: how do we define an init override? An initializer isn't really an override since it can have a different signature from the parent. Additionally we can have multiple inits.

For example

class Foo{
      Foo(int i){}
}

class Bar extends Foo{
    Bar(float j, int i){}
}
ftc commented 7 years ago

This is now a more critical problem as the following code:

public class MainActivity extends AppCompatActivity implements View.OnClickListener, MediaPlayer.OnPreparedListener {
    MediaPlayer m = new MediaPlayer();

Will cause the "new MediaPlayer()" to be executed in the \<init> callback. So having an [CB] |- [CB] is needed to prove correctness here.