proguard
proguard copied to clipboard
Empty class is not removed if instance with static modifier is used.
I'm trying to remove logging code but it cannot be removed totally. For example, empty "LogObject" class is present in a proguard's output. If "s_log" is commented out then "LogObject" class is also removed.
How to remove empty class?
Note: I've used jadx-gui tool to view proguard output.
If local variable is used then the class is removed.
In this case you have code like that:
if ( s_log == null ) {
s_log = new LogObject("Id2");
}
So ProGuard is not able to remove the field s_log as its also accessed for reading (the if (s_log == null) ).
As the field is kept and assigned with a LogObject class, the class itself is also kept.
Proguard output is
if (s_log == null) {
s_log = new LogObject();
}
and LogObject is empty class. So, these 3 lines is no operation. Therefore they should be removed. ?
Proguard has an optimization to remove write-only fields. In this case the field is accessed as well (null check), so its not removed.
That would actually be a good improvement, but its currently not supported.