Class Javah
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.optional.Javah
- All Implemented Interfaces:
Cloneable
Generates JNI header files using javah.
This task can take the following arguments:
- classname - the fully-qualified name of a class
- outputFile - Concatenates the resulting header or source files for all the classes listed into this file
- destdir - Sets the directory where javah saves the header files or the stub files
- classpath
- bootclasspath
- force - Specifies that output files should always be written (JDK1.2 only)
- old - Specifies that old JDK1.0-style header files should be generated (otherwise output file contain JNI-style native method function prototypes) (JDK1.2 only)
- stubs - generate C declarations from the Java object file (used with old)
- verbose - causes javah to print a message to stdout concerning the status of the generated files
- extdirs - Override location of installed extensions
<class name="xxx"> elements within the task.
When this task executes, it will generate C header and source files that are needed to implement native methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA class corresponding the the nested "class" element. -
Field Summary
Fields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(JavahAdapter adapter) Set the adapter explicitly.voidaddFileSet(FileSet fs) Add a fileset.Adds an implementation specific command-line argument.Adds path to bootstrap class files.Adds class to process.Path to use for classpath.The classpath to use when loading the javah implementation if it is not a built-in one.voidexecute()Execute the taskThe bootclasspath to use.String[]Names of the classes to process.The classpath to use.String[]Returns the (implementation specific) settings given as nested arg elements.The destination directory, if any.booleangetForce()Whether output files should always be written.booleangetOld()Whether old JDK1.0-style header files should be generated.The destination file, if any.booleangetStubs()Whether C declarations from the Java object file should be generated.booleanWhether verbose output should get generated.voidLogs the compilation parameters, adds the files to compile and logs the "niceSourceList"protected voidLogs the compilation parameters, adds the files to compile and logs the "niceSourceList"voidsetBootclasspath(Path src) location of bootstrap class files.voidTo the bootstrap path, this adds a reference to a classpath defined elsewhere.voidthe fully-qualified name of the class (or classes, separated by commas).voidsetClasspath(Path src) the classpath to use.voidAdds a reference to a classpath defined elsewhere.voidsetDestdir(File destDir) Set the destination directory into which the Java source files should be compiled.voidsetForce(boolean force) If true, output files should always be written (JDK1.2 only).voidsetImplementation(String impl) Choose the implementation for this particular task.voidsetOld(boolean old) If true, specifies that old JDK1.0-style header files should be generated.voidsetOutputFile(File outputFile) Concatenates the resulting header or source files for all the classes listed into this file.voidsetStubs(boolean stubs) If true, generate C declarations from the Java object file (used with old).voidsetVerbose(boolean verbose) If true, causes Javah to print a message concerning the status of the generated files.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.voidinit()Called by the project to let the task initialize properly.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProjectModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.voidsetProject(Project project) Sets the project object of this component.
-
Constructor Details
-
Javah
public Javah()No arg constructor.
-
-
Method Details
-
setClass
the fully-qualified name of the class (or classes, separated by commas).- Parameters:
cls- the classname (or classnames).
-
createClass
Adds class to process.- Returns:
- a
ClassArgumentto be configured.
-
addFileSet
-
getClasses
Names of the classes to process.- Returns:
- the array of classes.
- Since:
- Ant 1.6.3
-
setDestdir
Set the destination directory into which the Java source files should be compiled.- Parameters:
destDir- the destination directory.
-
getDestdir
The destination directory, if any.- Returns:
- the destination directory.
- Since:
- Ant 1.6.3
-
setClasspath
-
createClasspath
-
setClasspathRef
Adds a reference to a classpath defined elsewhere.- Parameters:
r- a reference to a classpath.- To do:
- this needs to be documented in the HTML docs.
-
getClasspath
-
setBootclasspath
location of bootstrap class files.- Parameters:
src- the bootstrap classpath.
-
createBootclasspath
Adds path to bootstrap class files.- Returns:
- a path to be configured.
-
setBootClasspathRef
To the bootstrap path, this adds a reference to a classpath defined elsewhere.- Parameters:
r- a reference to a classpath- To do:
- this needs to be documented in the HTML.
-
getBootclasspath
The bootclasspath to use.- Returns:
- the bootclass path.
- Since:
- Ant 1.6.3
-
setOutputFile
Concatenates the resulting header or source files for all the classes listed into this file.- Parameters:
outputFile- the output file.
-
getOutputfile
The destination file, if any.- Returns:
- the destination file.
- Since:
- Ant 1.6.3
-
setForce
public void setForce(boolean force) If true, output files should always be written (JDK1.2 only).- Parameters:
force- the value to use.
-
getForce
public boolean getForce()Whether output files should always be written.- Returns:
- the force attribute.
- Since:
- Ant 1.6.3
-
setOld
public void setOld(boolean old) If true, specifies that old JDK1.0-style header files should be generated. (otherwise output file contain JNI-style native method function prototypes) (JDK1.2 only).- Parameters:
old- if true use old 1.0 style header files.
-
getOld
public boolean getOld()Whether old JDK1.0-style header files should be generated.- Returns:
- the old attribute.
- Since:
- Ant 1.6.3
-
setStubs
public void setStubs(boolean stubs) If true, generate C declarations from the Java object file (used with old).- Parameters:
stubs- if true, generated C declarations.
-
getStubs
public boolean getStubs()Whether C declarations from the Java object file should be generated.- Returns:
- the stubs attribute.
- Since:
- Ant 1.6.3
-
setVerbose
public void setVerbose(boolean verbose) If true, causes Javah to print a message concerning the status of the generated files.- Parameters:
verbose- if true, do verbose printing.
-
getVerbose
public boolean getVerbose()Whether verbose output should get generated.- Returns:
- the verbose attribute.
- Since:
- Ant 1.6.3
-
setImplementation
Choose the implementation for this particular task.- Parameters:
impl- the name of the implementation.- Since:
- Ant 1.6.3
-
createArg
Adds an implementation specific command-line argument.- Returns:
- a ImplementationSpecificArgument to be configured.
- Since:
- Ant 1.6.3
-
getCurrentArgs
Returns the (implementation specific) settings given as nested arg elements.- Returns:
- the arguments.
- Since:
- Ant 1.6.3
-
createImplementationClasspath
The classpath to use when loading the javah implementation if it is not a built-in one.- Returns:
- Path
- Since:
- Ant 1.8.0
-
add
Set the adapter explicitly.- Parameters:
adapter- JavahAdapter- Since:
- Ant 1.8.0
-
execute
Execute the task- Overrides:
executein classTask- Throws:
BuildException- is there is a problem in the task execution.
-
logAndAddFiles
Logs the compilation parameters, adds the files to compile and logs the "niceSourceList"- Parameters:
cmd- the command line.
-
logAndAddFilesToCompile
Logs the compilation parameters, adds the files to compile and logs the "niceSourceList"- Parameters:
cmd- the command line to add parameters to.
-