Max
Max

Reputation: 87

Java Obscured Obfuscation

Similar Questions: Here and Here

I guess the situation is pretty uncommon to begin with, and so I admit it is probably too localized for SO.

The Problem

public class bqf implements azj
{
    ...

    public static float b = 0.0F;

    ...

    public void b(...)
    {
        ...

        /* b, in both references below,
         * is meant to be a class (in the
         * default package)
         *
         * It is being obscured by field
         * b on the right side of the
         * expression.
         */
        b var13 = b.a(var9, var2, new br());

        ...
    }
}

The error is: cannot invoke a(aji, String, br) on primitive type float.

Compromisable limitations:

Why

I am modifying an obfuscated program. For irrelevant[?], unknown (to me), and uncompromisable reasons the modification must be done via patching the original jar with .class files. Hence, renaming the public field b or class b would require modifying much of the program. Because all of the classes are in the default package, refactoring class b would require me to modify every class which references b (much of the program). Nevertheless there is a substantial amount of modification I do intend on doing, and it is a pain to do it at the bytecode level; just not enough to warrant renaming/refactoring.

Possible Solutions

Upvotes: 5

Views: 568

Answers (2)

Marko Topolnik
Marko Topolnik

Reputation: 200148

b.a(var9, var2, new br());

can easily be rewritten using reflection:

Class.forName("b").getMethod("a", argTypes...).invoke(null, var9, var2, new br());

The problem would also be solved with a way to force the java compiler to require the keyword "this".

I don't think how this would help you for a static member. Compiler would have to require us to qualify everything—basically, disallow simple names altogether except for locals.

Upvotes: 2

Write a helper method elsewhere that invokes b.a(). You can then call that.

Note: In Java the convention is that the class would be named B and not b(which goes for bqf and aqz too) and if that had been followed the problem would not have shown.

The real, long time cure, is not to put classes in the default package.

Upvotes: 1

Related Questions