Zelix KlassMaster - Documentation
 

The trim Statement

The ZKM Script trim statement trims all opened classes. It removes classes, fields and methods that have not been explicitly or implicitly excluded by a preceding trimExclude statement.

The trim statement can also remove specified bytecode attributes. The remainder of this page is organized into the following sections.

Explanation

deleteSourceFileAttributes parameter

Set this parameter to true to remove any Source File attributes from your classes. Source File Attributes store the name of the source file that was compiled to produce a particular class. This information is typically only used to report the source file name when producing a stack trace. However, some JVMs may not display line numbers in a stack trace for a particular class unless a Source File attribute is present in that class. So, if your processed bytecode will have Line Number information (scrambled or otherwise), then you should omit this parameter or set it to false.

deleteDeprecatedAttributes parameter

Set this parameter to true to remove any Deprecated attributes from your classes. Deprecated Attributes are added to class files by compilers in response to "@deprecated" javadoc parameters. Typically, these attributes are only used by compilers to determine when "deprecated" warnings should be reported. So, if you do not expect users to compile new classes against your obfuscated classes, then you can safely set this parameter to true.

deleteAnnotationAttributes parameter

Annotation attributes where introduced with Java 5. Set this parameter to true to remove any annotation attributes from your classes. Some applications require their annotation attributes to run correctly but many don't.

deleteExceptionAttributes parameter

Exception attributes are used at compile time but they are not used at runtime. Set this parameter to true to remove any exception attributes from your classes.

deleteDebugExtensionAttributes parameter

Set this parameter to true to remove any SourceDebugExtension attributes from your classes. Such attributes may be added to your bytecode by various utilities but are typically not required for the running of your classes.

deleteUnknownAttributes parameter

Set this parameter to true to remove any attributes from your classes that are not recognized by Zelix KlassMaster. If Zelix KlassMaster™ doesn't recognize an attribute then it most probably is not a standard attribute. Such attributes may be added to your bytecode by various utilities but are typically not required for the running of your classes. If you select this option then Zelix KlassMaster™ will report the names of the unknown attributes that it deletes.

The trim statement has useful defaults which are as follows:

Omitted parameter Effect
deleteSourceFileAttributes deleteSourceFileAttributes=false
deleteDeprecatedAttributes deleteDeprecatedAttributes=true
deleteAnnotationAttributes deleteAnnotationAttributes=false
deleteExceptionAttributes deleteExceptionAttributes=false
deleteDebugExtensionAttributes deleteDebugExtensionAttributes=true
deleteUnknownAttributes deleteUnknownAttributes=false

Examples

trim; //Trim using the defaults

trim deleteSourceFileAttributes=false //Don't remove Source File Attributes
     deleteDeprecatedAttributes=true  //Remove Deprecated Attributes
     deleteAnnotationAttributes=false //Don't remove annotation attributes
     deleteExceptionAttributes=false //Don't remove exception attributes
     deleteDebugExtensionAttributes=true //Remove SourceDebugExtension attributes
     deleteUnknownAttributes=false;   //Don't remove unrecognized attributes

Syntax

"trim" ["deleteSourceFileAttributes" "=" ("true" | "false")]
["deleteDeprecatedAttributes" "=" ("true" | "false")]
["deleteAnnotationAttributes" "=" ("true" | "false")]
["deleteExceptionAttributes" "=" ("true" | "false")]
["deleteDebugExtensionAttributes" "=" ("true" | "false")]
["deleteUnknownAttributes" "=" ("true" | "false")] ";"
 
ZKM Script resetTrimExclusions statement The ZKM Script Language ZKM Script exclude statement