Remove array initialization
Java class file shrinker, optimizer, obfuscator, and preverifier
Brought to you by:
guardsquare
A private static final byte[] field is removed as field, but nevertheless, locally a new byte[] is created an initialized in a static{ .. } code block. The local reference is unused besides initialization. In my optinion, that should also be removed.
This is for ProGuard 4.11, tested with Java 1.6 u20.
I'm sorry - somehow the summary got lost.
Thanks for your observation. As you describe, the array instance is used, because the initialization code writes values to it. ProGuard doesn't remove the instantiation or the initialization code as a result -- a sort of catch-22. Removing the code requires escape analysis, to make sure the array is not used in any other way. Currently, only DexGuard performs escape analysis and indeed removes the array entirely. I may add it to ProGuard at some point, but it doesn't have a high priority.
Many thanks for you analysis and reply.
Why isn't the static field removed completely by "write only fields removal"?
If I'm not mistaking, the field itself should be removed.