Bug for instruction AALOAD when evaluation simplification
Java class file shrinker, optimizer, obfuscator, and preverifier
Brought to you by:
guardsquare
Consider the following method:
public Object test()
{
Object[] o = null;
return o[0];
}
When doing code simplification, code is transformed like this:
public static Object test()
{
return null;
}
To avoid this, in method EvaluationSimplifier.replaceReferencePushInstruction(), the test:
if (pushedValue.isParticular())
should be replaced by:
if (pushedValue.isParticular() && (instruction.opcode != InstructionConstants.OP_AALOAD))
The milestone is for ProGuard 4.11.
I disagree that this is a bug ...
quote from http://proguard.sourceforge.net/#manual/limitations.html
This optimization indeed is intentional. I have introduced the java system property "optimize.conservatively" in ProGuard 4.9 to optionally be more strict about such cases, at the expense of other optimization opportunities. I'll see if I can add it under the same umbrella.
Hello,
Eric, optimize conservatively does not manage this.
If you optimize the following code :
public static Object test(Object a)
{
Object[] o = null;
o[0] = a;
return o[0];
}
It is translated to :
public static Object test(Object a)
{
null[0] = a;
}
the reference of the array is confused with the element inside of the array.
}
This indeed still needs to be handled, most likely joining other corner-cases with the flag "optimize.conservatively".
ProGuard now handles this case, with -Doptimize.conservatively, in the upcoming version 5.0 beta1.
Hello Eric,
Using ProGuard 5.1 with 'optimize conservaively', these issue is still existing.
I still have to do what I described previosuly :
"To avoid this, in method EvaluationSimplifier.replaceReferencePushInstruction(), the test:
if (pushedValue.isParticular())
should be replaced by:
if (pushedValue.isParticular() && (instruction.opcode != InstructionConstants.OP_AALOAD))"