Tools ObfuscateOverviewBasics The Class Names options The Field Names options The Method Names options The Miscellaneous options OverviewJava class (bytecode) files can be decompiled back to Java source code. There is little you can do to your bytecode to prevent this. However, Zelix KlassMaster can obfuscate your bytecode and encrypt your string literals so that the source code produced by a decompiler is much less readable.Obfuscation also reduces the size of your bytecode. Your classes can move across networks more quickly. Zelix KlassMaster is particularly effective in reducing bytecode size because it can obfuscate package names making fully qualified class names smaller. The obfuscation tool works on all loaded classes. It cannot obfuscate classes that have not been loaded and you cannot exclude loaded classes from obfuscation (except for the name of the class containing your "main" method). So you should load all the packages to be obfuscated and process them at the same time. |
|
BasicsYou may obfuscate your classes at any time by selecting the Tools Obfuscate names menu. This brings up the "Name Obfuscate Options" dialog. |
![]()
|
![]()
|
|
The "Class names" OptionsIf you are obfuscating all classes in an application or applet, it is recommended that you select "change all class names". If you are obfuscating a class library it is recommended that you select "don't change public class names".Change all class namesIf you select "change all class names" then all public and package (default) class names will be changed. The only exception would be a class specified in the "don't change main class name" option.Don't change public class namesIf you select "don't change public class names" then all package (default) class names will be changed. The only exception would be a class specified in the "don't change main class name" option. |
![]()
|
WarningIf any loaded classes are extended by classes that haven't been loaded then obfuscation of the extended class names will break the extending classes. Zelix KlassMaster does not check for this situation. |
|
Change package names belowZelix KlassMaster can obfuscate package names if you select the "change package names below" option. If the field to the right of this option is left blank then all package names will be obfuscated. If a package qualfier is entered then only package qualifiers below or independent of the specified qualifier will be obfuscated.For example, if there were three classes with the fully qualified names
Don't change main class nameApplications are started by running a class that contains a "main" method. It is usually desirable that this class have a user friendly name. To ensure this, select the "don't change main class name" option and select your main class from the list box. All loaded classes that contain a "main" method will appear in the list.The "Field names" OptionsIf you are obfuscating all classes in an application or applet, it is recommended that you select "change all field names". If you are obfuscating a class library it is recommended that you select "don't change public or protected field names".Change all field namesIf you select "change all field names" then all public, protected, package (default) and private field names will be changed.Don't change public field namesIf you select "don't change public field names" then all protected, package (default) and private field names will be changed.Don't change public or protected field namesIf you select "don't change public or protected field names" then only package (default) and private field names will be changed.The "Method names" OptionsIf you are obfuscating all classes in an application or applet, it is recommended that you select "change all method names". If you are obfuscating a class library it is recommended that you select "don't change public or protected method names".Change all method namesIf you select "change all method names" then all public, protected, package (default) and private method names will be changed. (See exceptions.)Don't change public method namesIf you select "don't change public method names" then all protected, package (default) and private method names will be changed. (See exceptions.)Don't change public or protected method namesIf you select "don't change public or protected method names" then only package (default) and private method names will be changed. (See exceptions.)ExceptionsThe name of the methods "main" and "<init>" (i.e. constructors) will never be changed.A method name will not be changed if
WarningIf any methods in loaded classes are overridden by classes that haven't been loaded then obfuscation of the overridden method names will break the extending classes. Zelix KlassMaster does not check for this situation.The "Miscellaneous" OptionsProduce a change log fileIf you select "produce a change log file" Zelix KlassMaster will write the name change details to a change log file. The change log file will be given the name that you entered in the input field to the right of the option. Note that only the latest changes will appear in the file. If you obfuscate twice with the same change log file name then only the second set of name changes will be retained.Encrypt string literalsWhen the "encrypt string literals" option is selected, Zelix KlassMaster will replace your string literals with encrypted strings and add instructions to your bytecode that will decrypt the strings at runtime. The advantage to doing this is that the java source produced by a decompiler is much more incomprehensible if the string literals are gibberish. The disadvantages are that your code will run slower and will be a little larger.How much slower and larger will depend upon the design of your classes. If all of the class's string literals are coded as static final variables (e.g. static final String s = "Hello World;") then the decryption will be done only once at the time of class initialization which greatly reduces any performance degradation. The bytecode size increase is typically only significant for trivial classes. It is recommended that you measure the impact on your classes. Note that the string encryption used by Zelix KlassMaster
Use legal identifiersIf you select the "legal identifers with prefix:" option, Zelix KlassMaster will obfuscate names by replacing them with numbers prefixed with the string that you entered in the input field to the right of the option.Otherwise the names will be replaced with numbers. Numbers are not legal identifiers in the Java programming language. So any source code produced by a decompiler that contains such identifiers will not compile. However, there are utilities that can replace illegal identifiers with legal ones. Zelix KlassMaster's unobfuscate tool will do this. So the advantage of using illegal identifiers is not great. More seriously, your bytecode may be verified before being run by your clients' Virtual Machines. Bytecode Verifiers reject bytecode containing illegal identifiers. So, it is recommended that you always select the "use legal identifers with prefix:" option if there is any chance that your bytecode will be verified. It is also recommended that the prefix be only one character to reduce the size of your bytecode. Keep inner class informationThe JDK 1.1 introduced inner classes. At the level of the bytecode, inner classes are distinguished by the structure of their names and by the presence of a few attributes. This inner class information is not critical to the running of your bytecode. It is provided for the use of debuggers and similar utilities.If you select the "keep inner class information" option then Zelix KlassMaster will retain this inner class information. Generally, because this information is not critical, it is recommended that you do not select this option. Remove line number tablesJava compilers can include line number tables in your bytecode that maps bytecode instructions to source code line numbers. If your code contains line number information and it experiences an uncaught exception at runtime then the corresponing source code line number is displayed by the Virtual Machine. However, line number tables could also provide clues to decompliers.If the "remove line number tables" option is selected, Zelix KlassMaster will remove all line number debugging information. If there is no line number information in the bytecode this option will have no effect. Add corrupt symbolic entriesIf the "add corrupt symbolic entries" option is selected with the "light corruption" option, Zelix KlassMaster will add corrupt debugging information to every class which implements methods. Selection of the "heavy corruption" options results in additional corrupt information being added to every class. This corrupt information can confuse or crash some decompilers.The "light corruption" option has the following properties:
|
![]() |