Calling a class “if”

Tags: , ,



I’m trying to decompile / recompile an obfuscated Java program. From the decompiled source code, it looks like the obfuscator has managed to call a class if:

public class hX extends il implements ciS {
   ...
   private bQk Llm = bQk.DwB();
   private final CAR lTV = new if(this);
   private final TYo RtQ = new ig(this);
   private final TYo G2Z = new ih(this);
   ...
}

Trying to recompile this class of course now results in an error:

[javac] Compiling 1 source file to /home/qdii/cld/dev/bar/build/classes
[javac] /home/qdii/cld/dev/bar/src/hX.java:53: error: <identifier> expected
[javac]     private final CAR lTV = new if(this);

Is there a way to tell the java compiler to accept if as a class name? Otherwise, what are my options? renaming the class and finding all the references to it?

Answer

Java source code may have that constraint, but bytecode and classloaders do not care.

It’s the compiler that enforces that. If you use an alternative compiler to javac, or otherwise manipulate or generate some bytecode, then you are potentially able to do things that are normally impossible.

That’s what an obfuscator is likely to do.

The obfuscator is presumably exploiting this impossibility to make deobfuscation either more difficult or fail completely. Basically, the problem you’re having is quite possibly by design.

Is there a way to tell the java compiler to accept if as a class name?

Nope.

Otherwise, what are my options? renaming the class and finding all the references to it?

Yup.



Source: stackoverflow