JakeWharton / hugo

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

Feature/prevent exec on synthetic constructors #120

Closed faradaj closed 8 years ago

faradaj commented 8 years ago

Just like preventing synthetic methods' logging (resolved in #112), synthetic constructor of a @DebugLog annotated inner class also should not be logged by Hugo.

Note: When the private constructor of an inner class is used, in addition to the synthetic constructor, an empty class will be created by compiler. At least for now, this is not a problem for Hugo. (i.e. Hugo is interested in methods and constructors.)

To demonstrate, access modifier of Charmer class' constructor is changed to private.

Before this, Hugo was logging for Charmer class' synthetic constructor too:

01-20 18:30:26.904    4298-4298/com.example.hugo V/Charmer﹕ ⇢ <init>(name="Jake")
01-20 18:30:26.905    4298-4298/com.example.hugo V/Charmer﹕ ⇠ <init> [0ms]
01-20 18:30:26.905    4298-4298/com.example.hugo V/Charmer﹕ ⇢ <init>(x0="Jake", x1=null)
01-20 18:30:26.905    4298-4298/com.example.hugo V/Charmer﹕ ⇠ <init> [0ms]

With this, Hugo now logs:

01-20 18:31:24.261    8835-8835/com.example.hugo V/Charmer﹕ ⇢ <init>(name="Jake")
01-20 18:31:24.261    8835-8835/com.example.hugo V/Charmer﹕ ⇠ <init> [0ms]
JakeWharton commented 8 years ago

Love it. Will merge when build passes.

faradaj commented 8 years ago

Great and :+1: for super-fast response as this should've been already resolved within #112 :)

JakeWharton commented 8 years ago

I always forget about the constructor synthetics too, or I would have commented on that original one.