Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard ate my Object.wait()

I just found that ProGuard removed a .wait() call which I used to synchronize threads, which lead to a race condition which lead to a day of happy debugging :) Anyway...

I tracked it down to following piece of proguard configuration:

-assumenosideeffects public class android.util.Log {
    <methods>;
}

I want to understand WHY this happened. I am not sure why assuming that removal of Log class has no side effects leads to removal of .wait() on different class/object.

I saw ProGuard optimization also remove #wait() calls where Eric explains that such things may happen. However, he doesn't explain why.

Also, I found example how to remove Logs here (http://proguard.sourceforge.net/index.html#manual/examples.html). So, I can replace this piece of proguard of configuration (but it's not the point of this question).

like image 561
Victor Ronin Avatar asked May 30 '13 22:05

Victor Ronin


1 Answers

Your original configuration matches all methods of Log (explicit or inherited), including Object#wait(). It tells ProGuard that the wait() method has no side-effects and that it can be removed without harming the program. This is obviously not true, as you have noticed. With -assumenosideeffects, you should always explicitly list the methods that are safe to remove.

like image 195
Eric Lafortune Avatar answered Nov 01 '22 14:11

Eric Lafortune