JakeWharton / hugo

Annotation-triggered method call logging for your debug builds.
Apache License 2.0
7.92k stars 797 forks source link

Prevent execution of synthetics #112

Closed faradaj closed 8 years ago

faradaj commented 8 years ago

Execution on synthetic methods of @DebugLog annotated classes is prevented. (Resolves #111)

Compiler generates a synthetic method after compiling, for example, an inner class with a private method like:

public class HugoActivity extends Activity {
    //...
    @DebugLog
    static class Greeter {
        private final String name;

        Greeter(String name) {
          this.name = name;
        }

        private String sayHello() {
          return "Hello, " + name;
        }
    }
    //...
}

Before this, Hugo was logging for access$000() synthetic method too:

01-05 10:30:37.503  23503-23503/com.example.hugo V/Greeter﹕ ⇢ <init>(name="Jake")
01-05 10:30:37.503  23503-23503/com.example.hugo V/Greeter﹕ ⇠ <init> [0ms]
01-05 10:30:37.503  23503-23503/com.example.hugo V/Greeter﹕ ⇢ access$000(x0=com.example.hugo.HugoActivity$Greeter@3ca37d8)
01-05 10:30:37.504  23503-23503/com.example.hugo V/Greeter﹕ ⇢ sayHello()
01-05 10:30:37.504  23503-23503/com.example.hugo V/Greeter﹕ ⇠ sayHello [0ms] = "Hello, Jake"
01-05 10:30:37.504  23503-23503/com.example.hugo V/Greeter﹕ ⇠ access$000 [0ms] = "Hello, Jake"

With this, Hugo now logs:

01-05 10:30:37.503  23503-23503/com.example.hugo V/Greeter﹕ ⇢ <init>(name="Jake")
01-05 10:30:37.503  23503-23503/com.example.hugo V/Greeter﹕ ⇠ <init> [0ms]
01-05 10:30:37.504  23503-23503/com.example.hugo V/Greeter﹕ ⇢ sayHello()
01-05 10:30:37.504  23503-23503/com.example.hugo V/Greeter﹕ ⇠ sayHello [0ms] = "Hello, Jake"
JakeWharton commented 8 years ago

Fantastic!