javaobfuscationjavac

Java compiler automatically renaming parameters (obfuscating)


When I compile the code I am writing, then look at in a a JD Gui, methods show up with headers such as the following:

public void growSurface(Random paramRandom, int paramInt1, int paramInt2){

I am compiling through a .bat file. Is there a way to specify that I don't want to obfuscate the code.


Solution

  • By default javac is not including debug information in generated class files. This information is e.g. method parameter names (but method and field names are always stored to allow reflection). When the parameter names are not known, JD-GUI and other decompilers are making up some reasonable names. They are not obfuscated - simply they aren't there.

    Compile your code with -g flag:

    javac -g SomeClass.java
    

    Just checked JD-GUI - it shows correct parameter names then.