Search code examples
javarefactoringdeobfuscation

Java IXOR ~ [one side] equality refactoring question


public byte[] method(int var1)
{
        if(var1 == ~L.length) //<- this
            return a(i1, 0, false);
}

how would I go upon fixing

if(var1 == ~L.length)

to remove the ~

must I change == to != ?

if(var1 != L.length)

Thanks this is probably the last question of this type.

ps.> Thanks for helping me out with the previous ones like

~(-1 + var1) < -1 to var1 > 1

~(var1 & 0x22) != -1 to (var1 & 0x22) != 0

~var1 < ~var2 to var1 > var2


Solution

  • As I told you before, you can replace ~x with -x - 1

    So, if(var1 == ~L.length) is equivalent to if(var1 == -L.length - 1)