Ant Task Documentation

Description

Task to check if a set of class files contains calls to forbidden APIs from a given classpath and list of API signatures (either inline or as pointer to files). In contrast to other ANT tasks, this tool does only visit the given classpath and the system classloader, not ANT's class loader.

Parameters

Name Type Default Description
dir File Directory to scan for class files. This directory is automatically converted to a FileSet with **/*.class as include pattern.
signaturesfile File A single signatures file.
bundledsignatures String Name of a built-in signatures file.
classpath Path Classpath in ANT format. Should be identical to classpath used for compiling the class files.
classpathref Reference Reference to a path defined anywhere else. Should be identical to classpath used for compiling the class files.
failOnUnsupportedJava boolean false Fail the build, if the bundled ASM library cannot read the class file format of the runtime library or the runtime library cannot be discovered.
failOnMissingClasses boolean true Fail the build, if a referenced class is missing. This requires that you pass the whole classpath including all dependencies. If you don't have all classes in the filesets, the application classes must be reachable through this classpath, too.
failOnUnresolvableSignatures boolean true Fail the build if a signature is not resolving. If this parameter is set to to false, then such signatures are silently ignored.
internalRuntimeForbidden boolean false Forbids calls to classes from the internal java runtime (like sun.misc.Unsafe).
restrictClassFilename boolean true Automatically restrict resource names included to files with a name ending in '.class'. This makes filesets easier, as the includes="**/*.class" is not needed.
ignoreEmptyFileset boolean false Ignore empty fileset/resource collection and print a warning instead.

Parameters specified as nested elements

This task supports all resource collections Ant provides (fileset, filelist, file, tarfileset, zipfileset,...) and uses all class files from them. It automatically adds an implcit filter to file names ending in '.class', so you don't need to add this as include attribute to those collections.

You can also pass one or multiple classpath elements to form a classpath. Ideally use the same configuration like the javac task.

To pass in signatures, you have 3 possibilities: