Zelix KlassMaster - Documentation
 

The open Statement

The ZKM Script open statement opens class files and Java ME JAD files for processing by Zelix KlassMaster. Successive open statements do not have a cumulative effect.

If you open an archive that contains nested JAR, ZIP, WAR or RAR archives then the nested archives will also be opened for obfuscation. This typically happens in the case of JEE EAR archives. Occassionally this can cause a problem where your EAR contains a nested third party JAR that you don't want to obfuscate. In such cases you can use the -"x.ear!y.war!WEB-INF/lib/z.jar" syntax to tell Zelix KlassMaster™ to not open (i.e. "skip") a specified nested archive file.

You can also use the -"x.jar!com/mycompany/MyClass.class" syntax to tell Zelix KlassMaster™ to not open (i.e. "skip") a specified class or XML file within an archive. However, if you "skip" any classes then you must make sure that those classes does not access any of the classes that are to be obfuscated.

If you have specified a broad "skip" clause then you can use a narrower "unskip" to reduce the scope of that "skip" clause. The syntax is +"x.jar!com/mycompany/MyClass.class" The "unskip" must be at the same archive level as the "skip" that it narrows.

Any non-class files contained in opened archive files will be copied across to the corresponding saved archive files. Some of these files may be updated to reflect obfuscated names. See the File | SaveAll documentation for more detail.

Examples

open "C:\directory1\Class1.class" //a single class file
     "C:\directory1\MyJar.jar"    //all the class files in a single jar
     "C:\directory2"              //all the class files in a single directory
     "C:\directory3\*"   //all the class files in a single directory AND its subdirectories
     "C:\directory1\MyJar.jad" //Java ME JAD file will be associated with the JAR it specifies
     "C:\directory4\*.jar" //all the JAR files in directory4
     "C:\directory5\Config.xml" //XML file Config.xml
     "C:\directory6\*.xml" //all the XML files in directory
     ;
	 
open "C:\directory1\MyEar.ear"     //Open the EAR and all its nested WAR and JAR files
     //Don't open the archive X.jar (in the WEB-INF/lib/ directory) nested within MyWar.war nested within MyEar.ear
     -"MyEar.ear!MyWar.war!WEB-INF/lib/X.jar"
     //Don't open ANY zip file archive (in the WEB-INF/lib/ directory) nested within MyWar.war nested within MyEar.ear
     -"MyEar.ear!MyWar.war!WEB-INF/lib/*.zip"
     //Unskip (i.e. open) special.zip (in the WEB-INF/lib/ directory) nested within MyWar.war nested within MyEar.ear
     +"MyEar.ear!MyWar.war!WEB-INF/lib/special.zip"
     //Don't open any class file within the package com/mycompany within MyJar.jar nested within MyEar.ear
     -"MyEar.ear!MyJar.jar!com/mycompany/*.class"
     //Unskip (i.e. open) the class file com/mycompany/MyClass.class within MyJar.jar nested within MyEar.ear
     +"MyEar.ear!MyJar.jar!com/mycompany/MyClass.class"
     ; 

Explanation

The statement's action for each of the sourceName types is
Type Action
class file Open the specified class file
ZIP file Open all class files stored in the ZIP file
JAR file Open all class files stored in the JAR file
EAR file Open all class files stored in the nested WAR, JAR or RAR files
directory Open all class files stored in the directory
directory followed by an "*" Open all class files stored in the directory and all of its subdirectories
Java ME JAD file Open the JAD file and associate it with the opened JAR that it specifies
XML file Open the XML file from the file system. Note that any XML file within an opened archive will be automatically opened.

Syntax

"open" "\"" sourceName "\"" ("\"" sourceName "\"" | ("-" "\"" skipName "\"") | ("+" "\"" unSkipName "\""))* ";"

where
  • sourceName is the fully qualified pathname of a:
    • class file or
    • JAR file or
    • EAR file or
    • WAR file or
    • RAR file or
    • ZIP file or
    • directory or
    • directory followed by an "*" or
    • Java ME JAD file
    • XML file
    Note that a sourceName can contain "*" wildcards in the non-suffix part of an archive, class or XML file name.
  • skipName is the path to a nested archive, class file or XML file that should NOT be opened. The levels of nesting must be separated by "!" characters. Note that a skipName can contain "*" wildcards in the final file name which may be an archive name. For example:
    • x.ear!y.war!WEB-INF/lib/myJar.jar OR
    • x.ear!y.war!WEB-INF/lib/*.jar OR
    • x.jar!com/mycompany/*.class
    Also, the skipName can contain "*" wildcards in the path that qualifies the final file name.
    • x.ear!y.war!WEB-INF/*/myJar.jar OR
    • x.ear!y.war!WEB-INF/*/myXml.xml OR
    • x.jar!com/mycompany/*/myClass.class
  • unSkipName is the path to a nested archive, class file or XML file that should be removed from a corresponding broader "skip" exclusion and therefore SHOULD be opened. The levels of nesting must be separated by "!" characters. As in the case of a skipName, the unSkipName can contain "*" wildcards in the final file name which may be an archive name or in the path that qualifies the final file name. If there is no corresponding broader skipName ("skip" exclusion) then the unSkipName ("unskip" exclusion) will have no effect.
 
ZKM Script classpath statement The ZKM Script Language ZKM Script trimExclude statement