Basic Usage

Jmangle is run by supplying it with an optional set of parameters, a class directory containing the classes to be mangled and a destination directory for the new mangled classes:

java jmangle [optional parameters] <class dir> <mangled dir>

The optional command line parameters allow global control of the mangling, for example +private causes all private members to have their names mangled. Control at the individual class level is possible with the +config <file> (see) parameter which specifies a file with configuration directives where individual classes may be listed with specific mangling directives. Note that all parameters either begin with a + or a -. Those beginning with + enable an option, while those beginning with - disable an option.

You must have the <class dir> in your CLASSPATH.

The class files produced contain all the request names mangled. These are the classes that get packaged into the final distribution.

Caveats

There are a few issues to be aware of:

The +help option

The +help option prints out a simple usage message. The -help option does the same. This option causes the program to exit.

The +gui option

The +gui option will pop up a GUI to control the program.

The options described below can be specified either on the command line or set using the GUI.

The +prefix <prefix> option

The +prefix option will cause all mangled names to have <prefix> as the prefix. -prefix is not an option. The default prefix is jm.

The +debug option

The +debug option will strip all debugging symbols. -debug disables this option. This option is enabled by default.

The +package option

The +package option will mangle all package names. -package disables this option. This option is disabled by default.

The +class option

The +class option will mangle all class names. -class disables this option. This option is disabled by default.

The +public option

The +public option will mangle all methods and fields declared public. -public disables this option. This option is enabled by default.

The +protected option

The +protected option will mangle all methods and fields declared protected. -protected disables this option. This option is enabled by default.

The +private option

The +private option will mangle all methods and fields declared private. -private disables this option. This option is enabled by default.

The +friendly option

The +friendly option will mangle all methods and fields declared friendly. These are those that are not declared public,protected or private. -friendly disables this option. This option is enabled by default.

The +map <file> option

The +map option will output a map of original names to mangled names into <file>. If - is specified as the file, then the map will go to System.out. This map is important for confirming that the proper symbols were mangled and for tacking errors from the executing program (the JVM may report an error using a mangled method name). -map disables this option. This option is disabled by default.

If you are using the GUI, then selecting this option will produce a text window which will display the map and allow you to save it to a file.

The +verbose <file> option

The +verbose option will output detailed messages about the processing into <file>. If - is specified as the file, then the messages go to System.out. -verbose disables this option. This option is disabled by default.

If you are using the GUI, then selecting this option will produce a text window which will display the messages and allow you to save them to a file.

The +silent option

The +silent option turns off all messages, including those messages enabled by +verbose. This is useful in Makefiles and build scripts. -silent disables this option. This option is disabled by default.

The +tag <tag> option

If the +tag option is specified, then the associated tag string is added to all classes. This is useful for embedding copyright notices in all files. For example: +tag 'Copright 1998 John Smith'. -tag disables this option. This option is disabled by default.

The +config <file> option

The +config option specifies a configuration <file> that is read. All of the above global parameters are allowed except +/-help. Lines that begin with # are considered comment lines and ignored. Blank lines are ignored. In addition to the global commands, class specific control is possible by specifying a line of the form:
<classname> [options]
where options are:
  • +class mangle class name
  • -class DO NOT mangle class name
  • +public mangle public method and field names
  • -public DO NOT mangle public method and field names
  • +protected mangle protected method and field names
  • -protected DO NOT mangle protected method and field names
  • +private mangle private method and field names
  • -private DO NOT mangle private method and field names
  • +friendly mangle friendly method and field names
  • -friendly DO NOT mangle friendly method and field names
  • +debug strip debugging information
  • -debug DO NOT strip debugging information
  • +tag <tag> add <tag> to class file
  • -tag add NO TAG to class file
Initially, a class inherits the global options then the specified options override the global settings. For example:

MajorFrame -class +tag Copyright Me

When MajorFrame is mangled, the class name will not be mangled and the tag will be Copyright Me .

The following is the configuration file for example2:


# example2  config file

# NOTE: global commands should be
# first to avoid incorrect defaulting
# behavior in the the class specific
# assignments of properties

# NO messages
# +silent

# new prefix
+prefix me

# Lot's of output
+verbose example2.log

# Generate map of mangled symbols
+map example2.map

# mangle all class names and packages
+class

# public symbols
+public

# protected symbols
+protected

# private symbols
+private

# friendly symbols
+friendly

# global tag
+tag Copyright (c) 1997 John Jensen

# ------  Class specific directives

# application, don't mangle entry point classname
MiniEdit -class 


Copyright (c) 1998 Russell Leighton, all rights reserved