Generates JNI header files using javah.
This task can take the following arguments:
is required,
but not both. More than one classname may be specified, using a comma-separated
list or by using
elements within the task.
When this task executes, it will generate C header and source files that
are needed to implement native methods.
| Method from org.apache.tools.ant.taskdefs.optional.Javah Detail: |
public ImplementationSpecificArgument createArg() {
ImplementationSpecificArgument arg =
new ImplementationSpecificArgument();
facade.addImplementationArgument(arg);
return arg;
}
Adds an implementation specific command-line argument. |
public Path createBootclasspath() {
if (bootclasspath == null) {
bootclasspath = new Path(getProject());
}
return bootclasspath.createPath();
}
Adds path to bootstrap class files. |
public Javah.ClassArgument createClass() {
ClassArgument ga = new ClassArgument();
classes.addElement(ga);
return ga;
}
|
public Path createClasspath() {
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
}
Path to use for classpath. |
public void execute() throws BuildException {
// first off, make sure that we've got a srcdir
if ((cls == null) && (classes.size() == 0)) {
throw new BuildException("class attribute must be set!",
getLocation());
}
if ((cls != null) && (classes.size() > 0)) {
throw new BuildException("set class attribute or class element, "
+ "not both.", getLocation());
}
if (destDir != null) {
if (!destDir.isDirectory()) {
throw new BuildException("destination directory \"" + destDir
+ "\" does not exist or is not a directory", getLocation());
}
if (outputFile != null) {
throw new BuildException("destdir and outputFile are mutually "
+ "exclusive", getLocation());
}
}
if (classpath == null) {
classpath = (new Path(getProject())).concatSystemClasspath("last");
} else {
classpath = classpath.concatSystemClasspath("ignore");
}
JavahAdapter ad =
JavahAdapterFactory.getAdapter(facade.getImplementation(),
this);
if (!ad.compile(this)) {
throw new BuildException("compilation failed");
}
}
|
public Path getBootclasspath() {
return bootclasspath;
}
The bootclasspath to use. |
public String[] getClasses() {
ArrayList al = new ArrayList();
if (cls != null) {
StringTokenizer tok = new StringTokenizer(cls, ",", false);
while (tok.hasMoreTokens()) {
al.add(tok.nextToken().trim());
}
}
Enumeration e = classes.elements();
while (e.hasMoreElements()) {
ClassArgument arg = (ClassArgument) e.nextElement();
al.add(arg.getName());
}
return (String[]) al.toArray(new String[al.size()]);
}
Names of the classes to process. |
public Path getClasspath() {
return classpath;
}
|
public String[] getCurrentArgs() {
return facade.getArgs();
}
Returns the (implementation specific) settings given as nested
arg elements. |
public File getDestdir() {
return destDir;
}
The destination directory, if any. |
public boolean getForce() {
return force;
}
Whether output files should always be written. |
public boolean getOld() {
return old;
}
Whether old JDK1.0-style header files should be generated. |
public File getOutputfile() {
return outputFile;
}
The destination file, if any. |
public boolean getStubs() {
return stubs;
}
Whether C declarations from the Java object file should be generated. |
public boolean getVerbose() {
return verbose;
}
Whether verbose output should get generated. |
public void logAndAddFiles(Commandline cmd) {
logAndAddFilesToCompile(cmd);
}
Logs the compilation parameters, adds the files to compile and logs the
"niceSourceList" |
protected void logAndAddFilesToCompile(Commandline cmd) {
log("Compilation " + cmd.describeArguments(),
Project.MSG_VERBOSE);
StringBuffer niceClassList = new StringBuffer();
String[] c = getClasses();
for (int i = 0; i < c.length; i++) {
cmd.createArgument().setValue(c[i]);
niceClassList.append(" ");
niceClassList.append(c[i]);
niceClassList.append(lSep);
}
StringBuffer prefix = new StringBuffer("Class");
if (c.length > 1) {
prefix.append("es");
}
prefix.append(" to be compiled:");
prefix.append(lSep);
log(prefix.toString() + niceClassList.toString(), Project.MSG_VERBOSE);
}
Logs the compilation parameters, adds the files to compile and logs the
"niceSourceList" |
public void setBootClasspathRef(Reference r) {
createBootclasspath().setRefid(r);
}
To the bootstrap path, this adds a reference to a classpath defined elsewhere. |
public void setBootclasspath(Path src) {
if (bootclasspath == null) {
bootclasspath = src;
} else {
bootclasspath.append(src);
}
}
location of bootstrap class files. |
public void setClass(String cls) {
this.cls = cls;
}
the fully-qualified name of the class (or classes, separated by commas). |
public void setClasspath(Path src) {
if (classpath == null) {
classpath = src;
} else {
classpath.append(src);
}
}
|
public void setClasspathRef(Reference r) {
createClasspath().setRefid(r);
}
Adds a reference to a classpath defined elsewhere. |
public void setDestdir(File destDir) {
this.destDir = destDir;
}
Set the destination directory into which the Java source
files should be compiled. |
public void setForce(boolean force) {
this.force = force;
}
If true, output files should always be written (JDK1.2 only). |
public void setImplementation(String impl) {
if ("default".equals(impl)) {
facade.setImplementation(JavahAdapterFactory.getDefault());
} else {
facade.setImplementation(impl);
}
}
Choose the implementation for this particular task. |
public void setOld(boolean old) {
this.old = 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). |
public void setOutputFile(File outputFile) {
this.outputFile = outputFile;
}
Concatenates the resulting header or source files for all
the classes listed into this file. |
public void setStubs(boolean stubs) {
this.stubs = stubs;
}
If true, generate C declarations from the Java object file (used with old). |
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
If true, causes Javah to print a message concerning
the status of the generated files. |