diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties
index 3cc6775c5..ae4b1c13f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties
+++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties
@@ -65,6 +65,7 @@ jlink=org.apache.tools.ant.taskdefs.optional.jlink.JlinkTask
native2ascii=org.apache.tools.ant.taskdefs.optional.Native2Ascii
perforce=org.apache.tools.ant.taskdefs.optional.perforce.P4sync
propertyfile=org.apache.tools.ant.taskdefs.optional.PropertyFile
+depend=org.apache.tools.ant.taskdefs.optional.depend.Depend
# deprecated ant tasks (kept for back compatibility)
javadoc2=org.apache.tools.ant.taskdefs.Javadoc
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java
new file mode 100644
index 000000000..7d1133509
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java
@@ -0,0 +1,158 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend;
+
+import java.io.*;
+import java.lang.reflect.Modifier;
+import java.util.*;
+import org.apache.tools.ant.taskdefs.optional.depend.constantpool.*;
+
+/**
+ * A ClassFile object stores information about a Java class.
+ *
+ * The class may be read from a DataInputStream.and written
+ * to a DataOutputStream. These are usually streams from a Java
+ * class file or a class file component of a Jar file.
+ *
+ * @author Conor MacNeill
+ */
+public class ClassFile {
+
+ /**
+ * The Magic Value that marks the start of a Java class file
+ */
+ static private final int CLASS_MAGIC = 0xCAFEBABE;
+
+
+ /**
+ * This class' constant pool.
+ */
+ private ConstantPool constantPool;
+
+
+ /**
+ * The class name for this class.
+ */
+ private String className;
+
+ /**
+ * Read the class from a data stream.
+ *
+ * This method takes an InputStream as input and
+ * parses the class from the stream.
+ *
+ *
+ * @param stream an InputStream from which the class will be read
+ *
+ * @throws IOException if there is a problem reading from the given stream.
+ * @throws ClassFormatError if the class cannot be parsed correctly
+ *
+ */
+ public void read(InputStream stream) throws IOException, ClassFormatError {
+ DataInputStream classStream = new DataInputStream(stream);
+
+
+ if (classStream.readInt() != CLASS_MAGIC) {
+ throw new ClassFormatError("No Magic Code Found - probably not a Java class file.");
+ }
+
+ // right we have a good looking class file.
+ int minorVersion = classStream.readUnsignedShort();
+ int majorVersion = classStream.readUnsignedShort();
+
+ // read the constant pool in and resolve it
+ constantPool = new ConstantPool();
+
+ constantPool.read(classStream);
+ constantPool.resolve();
+
+ int accessFlags = classStream.readUnsignedShort();
+ int thisClassIndex = classStream.readUnsignedShort();
+ int superClassIndex = classStream.readUnsignedShort();
+ className = ((ClassCPInfo) constantPool.getEntry(thisClassIndex)).getClassName();
+ }
+
+
+ /**
+ * Get the classes which this class references.
+ */
+ public Vector getClassRefs() {
+
+ Vector classRefs = new Vector();
+
+ for (int i = 0; i < constantPool.size(); ++i) {
+ ConstantPoolEntry entry = constantPool.getEntry(i);
+
+ if (entry != null && entry.getTag() == ConstantPoolEntry.CONSTANT_Class) {
+ ClassCPInfo classEntry = (ClassCPInfo) entry;
+
+ if (!classEntry.getClassName().equals(className)) {
+ classRefs.addElement(ClassFileUtils.convertSlashName(classEntry.getClassName()));
+ }
+ }
+ }
+
+ return classRefs;
+ }
+
+ /**
+ * Get the class' fully qualified name in dot format.
+ *
+ * @return the class name in dot format (eg. java.lang.Object)
+ */
+ public String getFullClassName() {
+ return ClassFileUtils.convertSlashName(className);
+ }
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java
new file mode 100644
index 000000000..8a926b803
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java
@@ -0,0 +1,60 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend;
+
+
+public interface ClassFileIterator {
+
+ public ClassFile getNextClassFile();
+}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java
new file mode 100644
index 000000000..ae104c8c2
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java
@@ -0,0 +1,138 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend;
+
+/**
+ * Utility class file routines.
+ *
+ * This class porovides a number of static utility methods to convert between the
+ * formats used in the Java class file format and those commonly used in Java
+ * programming.
+ *
+ * @author Conor MacNeill
+ */
+public class ClassFileUtils {
+
+ /**
+ * Convert a class name from class file slash notation to java source
+ * file dot notation.
+ *
+ * @param slashName the class name in slash notation (eg. java/lang/Object)
+ *
+ * @return the class name in dot notation (eg. java.lang.Object).
+ */
+ static public String convertSlashName(String name) {
+ String dotName = null;
+ int startIndex = 0;
+ int sepIndex = 0;
+
+ String slashName = name.replace('\\', '/');
+ do {
+ String component = null;
+
+ sepIndex = slashName.indexOf('/', startIndex);
+
+ if (sepIndex == -1) {
+ component = slashName.substring(startIndex);
+ } else {
+ component = slashName.substring(startIndex, sepIndex);
+ startIndex = sepIndex + 1;
+ }
+
+ if (dotName == null) {
+ dotName = component;
+ } else {
+ dotName += "." + component;
+ }
+ } while (sepIndex != -1);
+
+ return dotName;
+ }
+
+ /**
+ * Convert a class name from java source file dot notation to class file slash notation..
+ *
+ * @param dotName the class name in dot notation (eg. java.lang.Object).
+ *
+ * @return the class name in slash notation (eg. java/lang/Object).
+ */
+ static public String convertDotName(String dotName) {
+ String slashName = null;
+ int startIndex = 0;
+ int sepIndex = 0;
+
+ do {
+ String component = null;
+
+ sepIndex = dotName.indexOf('.', startIndex);
+
+ if (sepIndex == -1) {
+ component = dotName.substring(startIndex);
+ } else {
+ component = dotName.substring(startIndex, sepIndex);
+ startIndex = sepIndex + 1;
+ }
+
+ if (slashName == null) {
+ slashName = component;
+ } else {
+ slashName += "/" + component;
+ }
+ } while (sepIndex != -1);
+
+ return slashName;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
new file mode 100644
index 000000000..f9d6dc2b0
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
@@ -0,0 +1,436 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.tools.ant.taskdefs.optional.depend;
+
+import org.apache.tools.ant.*;
+import org.apache.tools.ant.types.*;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+
+import java.util.*;
+import java.io.*;
+
+import org.apache.tools.ant.taskdefs.optional.depend.*;
+
+/**
+ * Generate a dependency file for a given set of classes
+ *
+ * @author Conor MacNeill
+ */
+public class Depend extends MatchingTask {
+ static private class ClassFileInfo {
+ public File absoluteFile;
+ public String relativeName;
+ public String className;
+ };
+
+ /**
+ * The path where source files exist
+ */
+ private Path srcPath;
+
+ /**
+ * The path where compiled class files exist.
+ */
+ private Path destPath;
+
+ /**
+ * The directory which contains the dependency cache.
+ */
+ private File cache;
+
+ /**
+ * A map which gives for every class a list of te class which it affects.
+ */
+ private Hashtable affectedClassMap;
+
+ /**
+ * A map which gives information about a class
+ */
+ private Hashtable classFileInfoMap;
+
+ /**
+ * The list of classes which are out of date.
+ */
+ private Vector outOfDateClasses;
+
+ /**
+ * indicates that the dependency relationships should be extended
+ * beyond direct dependencies to include all classes. So if A directly
+ * affects B abd B directly affects C, then A indirectly affects C.
+ */
+ private boolean closure;
+
+ private void writeDependencyList(File depFile, Vector dependencyList) throws IOException {
+ // new dependencies so need to write them out to the cache
+ PrintWriter pw = null;
+ try {
+ String parent = depFile.getParent();
+ if (parent != null) {
+ new File(parent).mkdirs();
+ }
+
+ pw = new PrintWriter(new FileWriter(depFile));
+ for (Enumeration deps = dependencyList.elements(); deps.hasMoreElements();) {
+ pw.println(deps.nextElement());
+ }
+ }
+ finally {
+ if (pw != null) {
+ pw.close();
+ }
+ }
+ }
+
+ private Vector readDependencyList(File depFile) throws IOException {
+ Vector dependencyList = null;
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new FileReader(depFile));
+ String line = null;
+ dependencyList = new Vector();
+ while ((line = in.readLine()) != null) {
+ dependencyList.addElement(line);
+ }
+ }
+ finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+
+ return dependencyList;
+ }
+
+
+ private void determineDependencies() throws IOException {
+ affectedClassMap = new Hashtable();
+ classFileInfoMap = new Hashtable();
+ for (Enumeration e = getClassFiles(destPath).elements(); e.hasMoreElements(); ) {
+ ClassFileInfo info = (ClassFileInfo)e.nextElement();
+ classFileInfoMap.put(info.className, info);
+
+ Vector dependencyList = null;
+
+ if (cache != null) {
+ // try to read the dependency info from the cache if it is not out of date
+ File depFile = new File(cache, info.relativeName + ".dep");
+ if (depFile.exists() && depFile.lastModified() > info.absoluteFile.lastModified()) {
+ // depFile exists and is newer than the class file
+ // need to read dependency list from tyhe file.
+ dependencyList = readDependencyList(depFile);
+ }
+ }
+
+ if (dependencyList == null) {
+ // not cached - so need to read directly from the class file
+ FileInputStream inFileStream = null;
+ try {
+ inFileStream = new FileInputStream(info.absoluteFile);
+ ClassFile classFile = new ClassFile();
+ classFile.read(inFileStream);
+
+ dependencyList = classFile.getClassRefs();
+
+ if (cache != null) {
+ // new dependencies so need to write them out to the cache
+ File depFile = new File(cache, info.relativeName + ".dep");
+ writeDependencyList(depFile, dependencyList);
+ }
+ }
+ finally {
+ if (inFileStream != null) {
+ inFileStream.close();
+ }
+ }
+ }
+
+ // This class depends on each class in the dependency list. For each
+ // one of those, add this class into their affected classes list
+
+ for (Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) {
+ String dependentClass = (String)depEnum.nextElement();
+
+ Hashtable affectedClasses = (Hashtable)affectedClassMap.get(dependentClass);
+ if (affectedClasses == null) {
+ affectedClasses = new Hashtable();
+ affectedClassMap.put(dependentClass, affectedClasses);
+ }
+
+ affectedClasses.put(info.className, info);
+ }
+ }
+ }
+
+
+ private void deleteAllAffectedFiles() {
+ for (Enumeration e = outOfDateClasses.elements(); e.hasMoreElements();) {
+ String className = (String)e.nextElement();
+ deleteAffectedFiles(className);
+ }
+ }
+
+ private void deleteAffectedFiles(String className) {
+ Hashtable affectedClasses = (Hashtable)affectedClassMap.get(className);
+ if (affectedClasses != null) {
+ for (Enumeration e = affectedClasses.keys(); e.hasMoreElements(); ) {
+ String affectedClassName = (String)e.nextElement();
+ ClassFileInfo affectedClassInfo = (ClassFileInfo)affectedClasses.get(affectedClassName);
+ if (affectedClassInfo.absoluteFile.exists()) {
+ log("Deleting file " + affectedClassInfo.absoluteFile.getPath() + " since " +
+ className + " out of date", Project.MSG_VERBOSE);
+ affectedClassInfo.absoluteFile.delete();
+ if (closure) {
+ deleteAffectedFiles(affectedClassName);
+ }
+ else {
+ // without closer we may delete an inner class but not the
+ // top level class which will not trigger a recompile.
+
+ if (affectedClassName.indexOf("$") != -1) {
+ // need to delete the main class
+ String topLevelClassName
+ = affectedClassName.substring(0, affectedClassName.indexOf("$"));
+ System.out.println("Top level class = " + topLevelClassName);
+ ClassFileInfo topLevelClassInfo
+ = (ClassFileInfo)classFileInfoMap.get(topLevelClassName);
+ if (topLevelClassInfo.absoluteFile.exists()) {
+ log("Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " +
+ "one of its inner classes was removed", Project.MSG_VERBOSE);
+ topLevelClassInfo.absoluteFile.delete();
+ if (closure) {
+ deleteAffectedFiles(topLevelClassName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Does the work.
+ *
+ * @exception BuildException Thrown in unrecovrable error.
+ */
+ public void execute() throws BuildException {
+ try {
+ long start = System.currentTimeMillis();
+ String [] srcPathList = srcPath.list();
+ if (srcPathList.length == 0) {
+ throw new BuildException("srcdir attribute must be set!", location);
+ }
+
+ if (destPath == null) {
+ destPath = srcPath;
+ }
+
+ if (cache != null && cache.exists() && !cache.isDirectory()) {
+ throw new BuildException("The cache, if specified, must point to a directory");
+ }
+
+ if (cache != null && !cache.exists()) {
+ cache.mkdirs();
+ }
+
+ determineDependencies();
+
+/*
+ for (Enumeration e = affectedClassMap.keys(); e.hasMoreElements(); ) {
+ String className = (String)e.nextElement();
+ System.out.println("Class " + className + " affects:");
+ Hashtable affectedClasses = (Hashtable)affectedClassMap.get(className);
+ for (Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements(); ) {
+ String affectedClass = (String)e2.nextElement();
+ ClassFileInfo info = (ClassFileInfo)affectedClasses.get(affectedClass);
+ System.out.println(" " + affectedClass + " in " + info.absoluteFile.getPath());
+ }
+ }
+*/
+
+ // we now need to scan for out of date files. When we have the list
+ // we go through and delete all class files which are affected by these files.
+ outOfDateClasses = new Vector();
+ for (int i=0; i info.absoluteFile.lastModified()) {
+ outOfDateClasses.addElement(className);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ /**
+ * Get the list of class files we are ging to analyse.
+ *
+ * @param classLocations a path structure containing all the directories
+ * where classes can be found.
+ * @return a vector containing the classes to analyse.
+ */
+ private Vector getClassFiles(Path classLocations) {
+ // break the classLocations into its components.
+ String[] classLocationsList = classLocations.list();
+
+ Vector classFileList = new Vector();
+
+ for (int i = 0; i < classLocationsList.length; ++i) {
+ File dir = new File(classLocationsList[i]);
+ if (dir.isDirectory()) {
+ addClassFiles(classFileList, dir, dir);
+ }
+ }
+
+ return classFileList;
+ }
+
+ /**
+ * Add the list of class files from the given directory to the
+ * class file vector, including any subdirectories.
+ *
+ * @param classLocations a path structure containing all the directories
+ * where classes can be found.
+ * @return a vector containing the classes to analyse.
+ */
+ private void addClassFiles(Vector classFileList, File dir, File root) {
+ String[] filesInDir = dir.list();
+
+ if (filesInDir != null) {
+ int length = filesInDir.length;
+
+ for (int i = 0; i < length; ++i) {
+ File file = new File(dir, filesInDir[i]);
+ if (file.isDirectory()) {
+ addClassFiles(classFileList, file, root);
+ }
+ else if (file.getName().endsWith(".class")) {
+ ClassFileInfo info = new ClassFileInfo();
+ info.absoluteFile = file;
+ info.relativeName = file.getPath().substring(root.getPath().length() + 1,
+ file.getPath().length() - 6);
+ info.className = ClassFileUtils.convertSlashName(info.relativeName);
+ classFileList.addElement(info);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Set the source dirs to find the source Java files.
+ */
+ public void setSrcdir(Path srcPath) {
+ this.srcPath = srcPath;
+ }
+
+ /**
+ * Set the destination directory where the compiled java files exist.
+ */
+ public void setDestDir(Path destPath) {
+ this.destPath = destPath;
+ }
+
+ public void setCache(File cache) {
+ this.cache = cache;
+ }
+
+ public void setClosure(boolean closure) {
+ this.closure = closure;
+ }
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java
new file mode 100644
index 000000000..6e2494d12
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java
@@ -0,0 +1,204 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * An iterator which iterates through the contents of a java directory.
+ *
+ * The iterator should be created with the directory at the root of the
+ * Java namespace.
+ *
+ * @author Conor MacNeill
+ */
+public class DirectoryIterator implements ClassFileIterator {
+
+ /**
+ * This is a stack of current iterators supporting the depth first
+ * traversal of the directory tree.
+ */
+ private Stack enumStack;
+
+ /**
+ * The current directory iterator. As directories encounter lower level
+ * directories, the current iterator is pushed onto the iterator
+ * stack and a new iterator over the sub directory becomes the current
+ * directory. This implements a depth first traversal of the directory namespace.
+ */
+ private Enumeration currentEnum;
+
+ /**
+ * The length of the root directory. This is used to remove the root directory
+ * from full paths.
+ */
+ int rootLength;
+
+ /**
+ * Creates a directory iterator.
+ *
+ * The directory iterator is created to scan the root directory. If the
+ * changeInto flag is given, then the entries returned will be relative to this
+ * directory and not the current directory.
+ *
+ * @param rootDirectory the root if the directory namespace which is to be iterated over
+ * @param changeInto if true then the returned entries will be relative to the rootDirectory
+ * and not the current directory.
+ *
+ * @throws IOException if there is a problem reading the directory information.
+ */
+ public DirectoryIterator(File rootDirectory, boolean changeInto) throws IOException {
+ super();
+
+ enumStack = new Stack();
+
+ if (rootDirectory.isAbsolute() || changeInto) {
+ rootLength = rootDirectory.getPath().length() + 1;
+ } else {
+ rootLength = 0;
+ }
+
+ Vector filesInRoot = getDirectoryEntries(rootDirectory);
+
+ currentEnum = filesInRoot.elements();
+ }
+
+ /**
+ * Get a vector covering all the entries (files and subdirectories in a directory).
+ *
+ * @param directory the directory to be scanned.
+ *
+ * @return a vector containing File objects for each entry in the directory.
+ */
+ private Vector getDirectoryEntries(File directory) {
+ Vector files = new Vector();
+
+ // File[] filesInDir = directory.listFiles();
+ String[] filesInDir = directory.list();
+
+ if (filesInDir != null) {
+ int length = filesInDir.length;
+
+ for (int i = 0; i < length; ++i) {
+ files.addElement(new File(directory, filesInDir[i]));
+ }
+ }
+
+ return files;
+ }
+
+ /**
+ * Template method to allow subclasses to supply elements for the iteration.
+ *
+ * The directory iterator maintains a stack of iterators covering each level
+ * in the directory hierarchy. The current iterator covers the current directory
+ * being scanned. If the next entry in that directory is a subdirectory, the current
+ * iterator is pushed onto the stack and a new iterator is created for the
+ * subdirectory. If the entry is a file, it is returned as the next element and the
+ * iterator remains valid. If there are no more entries in the current directory,
+ * the topmost iterator on the statck is popped off to become the current iterator.
+ *
+ * @return the next ClassFile in the iteration.
+ */
+ public ClassFile getNextClassFile() {
+ ClassFile nextElement = null;
+
+ try {
+ while (nextElement == null) {
+ if (currentEnum.hasMoreElements()) {
+ File element = (File) currentEnum.nextElement();
+
+ if (element.isDirectory()) {
+
+ // push the current iterator onto the stack and then
+ // iterate through this directory.
+ enumStack.push(currentEnum);
+
+ Vector files = getDirectoryEntries(element);
+
+ currentEnum = files.elements();
+ } else {
+
+ // we have a file. create a stream for it
+ FileInputStream inFileStream = new FileInputStream(element);
+
+ if (element.getName().endsWith(".class")) {
+
+ // create a data input stream from the jar input stream
+ ClassFile javaClass = new ClassFile();
+
+ javaClass.read(inFileStream);
+
+ nextElement = javaClass;
+ }
+ }
+ } else {
+ // this iterator is exhausted. Can we pop one off the stack
+ if (enumStack.empty()) {
+ break;
+ } else {
+ currentEnum = (Enumeration) enumStack.pop();
+ }
+ }
+ }
+ } catch (IOException e) {
+ nextElement = null;
+ }
+
+ return nextElement;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java
new file mode 100644
index 000000000..4615a73bb
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java
@@ -0,0 +1,124 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend;
+
+import java.util.zip.*;
+import java.io.*;
+
+/**
+ * A class file iterator which iterates through the contents of a Java jar file.
+ *
+ * @author Conor MacNeill
+ */
+public class JarFileIterator implements ClassFileIterator {
+ private ZipInputStream jarStream;
+
+ public JarFileIterator(InputStream stream) throws IOException {
+ super();
+
+ jarStream = new ZipInputStream(stream);
+ }
+
+ private byte[] getEntryBytes(InputStream stream) throws IOException {
+ byte[] buffer = new byte[8192];
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
+ int n;
+
+ while ((n = stream.read(buffer, 0, buffer.length)) != -1) {
+ baos.write(buffer, 0, n);
+ }
+
+ return baos.toByteArray();
+ }
+
+ public ClassFile getNextClassFile() {
+ ZipEntry jarEntry;
+ ClassFile nextElement = null;
+
+ try {
+ jarEntry = jarStream.getNextEntry();
+
+
+ while (nextElement == null && jarEntry != null) {
+ String entryName = jarEntry.getName();
+
+ if (!jarEntry.isDirectory() && entryName.endsWith(".class")) {
+
+ // create a data input stream from the jar input stream
+ ClassFile javaClass = new ClassFile();
+
+ javaClass.read(jarStream);
+
+ nextElement = javaClass;
+ } else {
+
+ jarEntry = jarStream.getNextEntry();
+ }
+ }
+ } catch (IOException e) {
+ String message = e.getMessage();
+ String text = e.getClass().getName();
+
+ if (message != null) {
+ text += ": " + message;
+ }
+
+ throw new RuntimeException("Problem reading JAR file: " + text);
+ }
+
+ return nextElement;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ClassCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ClassCPInfo.java
new file mode 100644
index 000000000..d937e0ef9
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ClassCPInfo.java
@@ -0,0 +1,128 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * The constant pool entry which stores class information.
+ *
+ * @author Conor MacNeill
+ */
+public class ClassCPInfo extends ConstantPoolEntry {
+
+ /**
+ * The class' name. This will be only valid if the entry has been resolved
+ * against the constant pool.
+ */
+ private String className;
+
+ /**
+ * The index into the constant pool where this class' name is stored. If the class
+ * name is changed, this entry is invalid until this entry is connected to a constant
+ * pool.
+ */
+ private int index;
+
+ /**
+ * Constructor.
+ *
+ * Sets the tag value for this entry to type Class
+ */
+ public ClassCPInfo() {
+ super(CONSTANT_Class, 1);
+ }
+
+ /**
+ * Read the entry from a stream.
+ *
+ * @param cpStream the stream containing the constant pool entry to be read.
+ *
+ * @exception IOException thrown if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ index = cpStream.readUnsignedShort();
+ className = "unresolved";
+ }
+
+ /**
+ * Generate a string readable version of this entry
+ */
+ public String toString() {
+ return "Class Constant Pool Entry for " + className + "[" + index + "]";
+ }
+
+ /**
+ * Resolve this class info against the given constant pool.
+ *
+ * @param constantPool the constant pool with which to resolve the class.
+ */
+ public void resolve(ConstantPool constantPool) {
+ className = ((Utf8CPInfo) constantPool.getEntry(index)).getValue();
+
+ super.resolve(constantPool);
+ }
+
+ /**
+ * Get the class name of this entry.
+ *
+ * @return the class' name.
+ */
+ public String getClassName() {
+ return className;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantCPInfo.java
new file mode 100644
index 000000000..c4ad54fc4
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantCPInfo.java
@@ -0,0 +1,103 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+
+/**
+ * A Constant Pool entry which represents a constant value.
+ *
+ *
+ * @author Conor MacNeill
+ */
+abstract public class ConstantCPInfo extends ConstantPoolEntry {
+
+ /**
+ * The entry's untyped value.
+ *
+ * Each subclass interprets the constant value based on the subclass's type.
+ * The value here must be compatible.
+ */
+ private Object value;
+
+ /**
+ * Initialise the constant entry.
+ *
+ * @param tagValue the constant pool entry type to be used.
+ * @param entries the number of constant pool entry slots occupied by this entry.
+ */
+ protected ConstantCPInfo(int tagValue, int entries) {
+ super(tagValue, entries);
+ }
+
+ /**
+ * Get the value of the constant.
+ *
+ * @return the value of the constant (untyped).
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * Set the constant value.
+ *
+ * @param newValue the new untyped value of this constant.
+ */
+ public void setValue(Object newValue) {
+ value = newValue;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java
new file mode 100644
index 000000000..8258e8bfb
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java
@@ -0,0 +1,383 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * The constant pool of a Java class.
+ *
+ * The constant pool is a collection of constants used in a Java class file. It stores
+ * strings, constant values, class names, method names, field names etc.
+ *
+ * @see The Java Virtual Machine Specification
+ *
+ * @author Conor MacNeill
+ */
+public class ConstantPool {
+
+ /**
+ * The entries in the constant pool.
+ */
+ private Vector entries;
+
+ /**
+ * A Hashtable of UTF8 entries - used to get constant pool indexes of the UTF8 values quickly
+ */
+ private Hashtable utf8Indexes;
+
+ /**
+ * Initialise the constant pool.
+ */
+ public ConstantPool() {
+ entries = new Vector();
+
+ // The zero index is never present in the constant pool itself so
+ // we add a null entry for it
+ entries.addElement(null);
+
+ utf8Indexes = new Hashtable();
+ }
+
+ /**
+ * Read the constant pool from a class input stream.
+ *
+ * @param classStream the DataInputStream of a class file.
+ *
+ * @throws IOException if there is a problem reading the constant pool
+ * from the stream
+ */
+ public void read(DataInputStream classStream) throws IOException {
+ int numEntries = classStream.readUnsignedShort();
+
+ for (int i = 1; i < numEntries; ) {
+ ConstantPoolEntry nextEntry = ConstantPoolEntry.readEntry(classStream);
+
+ i += nextEntry.getNumEntries();
+
+ addEntry(nextEntry);
+ }
+ }
+
+ /**
+ * Get the size of the constant pool.
+ */
+ public int size() {
+ return entries.size();
+ }
+
+ /**
+ * Add an entry to the constant pool.
+ *
+ * @param entry the new entry to be added to the constant pool.
+ *
+ * @return the index into the constant pool at which the entry is stored.
+ */
+ public int addEntry(ConstantPoolEntry entry) {
+ int index = entries.size();
+
+ entries.addElement(entry);
+
+ int numSlots = entry.getNumEntries();
+
+ // add null entries for any additional slots required.
+ for (int j = 0; j < numSlots - 1; ++j) {
+ entries.addElement(null);
+ }
+
+ if (entry instanceof Utf8CPInfo) {
+ Utf8CPInfo utf8Info = (Utf8CPInfo) entry;
+
+ utf8Indexes.put(utf8Info.getValue(), new Integer(index));
+ }
+
+ return index;
+ }
+
+ /**
+ * Resolve the entries in the constant pool.
+ *
+ * Resolution of the constant pool involves transforming indexes to
+ * other constant pool entries into the actual data for that entry.
+ */
+ public void resolve() {
+ for (Enumeration i = entries.elements(); i.hasMoreElements(); ) {
+ ConstantPoolEntry poolInfo = (ConstantPoolEntry) i.nextElement();
+
+ if (poolInfo != null &&!poolInfo.isResolved()) {
+ poolInfo.resolve(this);
+ }
+ }
+ }
+
+
+ /**
+ * Get an constant pool entry at a particular index.
+ *
+ * @param index the index into the constant pool.
+ *
+ * @return the constant pool entry at that index.
+ */
+ public ConstantPoolEntry getEntry(int index) {
+ return (ConstantPoolEntry) entries.elementAt(index);
+ }
+
+ /**
+ * Get the index of a given UTF8 constant pool entry.
+ *
+ * @param value the string value of the UTF8 entry.
+ *
+ * @return the index at which the given string occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getUTF8Entry(String value) {
+ int index = -1;
+ Integer indexInteger = (Integer) utf8Indexes.get(value);
+
+ if (indexInteger != null) {
+ index = indexInteger.intValue();
+ }
+
+ return index;
+ }
+
+ /**
+ * Get the index of a given CONSTANT_Class entry in the constant pool.
+ *
+ * @param className the name of the class for which the class entry index is required.
+ *
+ * @return the index at which the given class entry occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getClassEntry(String className) {
+ int index = -1;
+
+ for (int i = 0; i < entries.size() && index == -1; ++i) {
+ Object element = entries.elementAt(i);
+
+ if (element instanceof ClassCPInfo) {
+ ClassCPInfo classinfo = (ClassCPInfo) element;
+
+ if (classinfo.getClassName().equals(className)) {
+ index = i;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ /**
+ * Get the index of a given constant value entry in the constant pool.
+ *
+ * @param constantValue the constant value for which the index is required.
+ *
+ * @return the index at which the given value entry occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getConstantEntry(Object constantValue) {
+ int index = -1;
+
+ for (int i = 0; i < entries.size() && index == -1; ++i) {
+ Object element = entries.elementAt(i);
+
+ if (element instanceof ConstantCPInfo) {
+ ConstantCPInfo constantEntry = (ConstantCPInfo) element;
+
+ if (constantEntry.getValue().equals(constantValue)) {
+ index = i;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ /**
+ * Get the index of a given CONSTANT_MethodRef entry in the constant pool.
+ *
+ * @param methodClassName the name of the class which contains the method
+ * being referenced.
+ * @param methodName the name of the method being referenced.
+ * @param methodType the type descriptor of the metho dbeing referenced.
+ *
+ * @return the index at which the given method ref entry occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getMethodRefEntry(String methodClassName, String methodName, String methodType) {
+ int index = -1;
+
+ for (int i = 0; i < entries.size() && index == -1; ++i) {
+ Object element = entries.elementAt(i);
+
+ if (element instanceof MethodRefCPInfo) {
+ MethodRefCPInfo methodRefEntry = (MethodRefCPInfo) element;
+
+ if (methodRefEntry.getMethodClassName().equals(methodClassName)
+ && methodRefEntry.getMethodName().equals(methodName) && methodRefEntry.getMethodType().equals(methodType)) {
+ index = i;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ /**
+ * Get the index of a given CONSTANT_InterfaceMethodRef entry in the constant pool.
+ *
+ * @param interfaceMethodClassName the name of the interface which contains the method
+ * being referenced.
+ * @param interfaceMethodName the name of the method being referenced.
+ * @param interfaceMethodType the type descriptor of the metho dbeing referenced.
+ *
+ * @return the index at which the given method ref entry occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getInterfaceMethodRefEntry(String interfaceMethodClassName, String interfaceMethodName, String interfaceMethodType) {
+ int index = -1;
+
+ for (int i = 0; i < entries.size() && index == -1; ++i) {
+ Object element = entries.elementAt(i);
+
+ if (element instanceof InterfaceMethodRefCPInfo) {
+ InterfaceMethodRefCPInfo interfaceMethodRefEntry = (InterfaceMethodRefCPInfo) element;
+
+ if (interfaceMethodRefEntry.getInterfaceMethodClassName().equals(interfaceMethodClassName)
+ && interfaceMethodRefEntry.getInterfaceMethodName().equals(interfaceMethodName)
+ && interfaceMethodRefEntry.getInterfaceMethodType().equals(interfaceMethodType)) {
+ index = i;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ /**
+ * Get the index of a given CONSTANT_FieldRef entry in the constant pool.
+ *
+ * @param fieldClassName the name of the class which contains the field
+ * being referenced.
+ * @param fieldName the name of the field being referenced.
+ * @param fieldType the type descriptor of the field being referenced.
+ *
+ * @return the index at which the given field ref entry occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getFieldRefEntry(String fieldClassName, String fieldName, String fieldType) {
+ int index = -1;
+
+ for (int i = 0; i < entries.size() && index == -1; ++i) {
+ Object element = entries.elementAt(i);
+
+ if (element instanceof FieldRefCPInfo) {
+ FieldRefCPInfo fieldRefEntry = (FieldRefCPInfo) element;
+
+ if (fieldRefEntry.getFieldClassName().equals(fieldClassName) && fieldRefEntry.getFieldName().equals(fieldName)
+ && fieldRefEntry.getFieldType().equals(fieldType)) {
+ index = i;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ /**
+ * Get the index of a given CONSTANT_NameAndType entry in the constant pool.
+ *
+ * @param name the name
+ * @param type the type
+ *
+ * @return the index at which the given NameAndType entry occurs in the
+ * constant pool or -1 if the value does not occur.
+ */
+ public int getNameAndTypeEntry(String name, String type) {
+ int index = -1;
+
+ for (int i = 0; i < entries.size() && index == -1; ++i) {
+ Object element = entries.elementAt(i);
+
+ if (element instanceof NameAndTypeCPInfo) {
+ NameAndTypeCPInfo nameAndTypeEntry = (NameAndTypeCPInfo) element;
+
+ if (nameAndTypeEntry.getName().equals(name) && nameAndTypeEntry.getType().equals(type)) {
+ index = i;
+ }
+ }
+ }
+
+ return index;
+ }
+
+ /**
+ * Dump the constant pool to a string.
+ *
+ * @return the constant pool entries as strings
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer("\n");
+ int size = entries.size();
+
+ for (int i = 0; i < size; ++i) {
+ sb.append("[" + i + "] = " + getEntry(i) + "\n");
+ }
+
+ return sb.toString();
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java
new file mode 100644
index 000000000..67c26e509
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java
@@ -0,0 +1,289 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * An entry in the constant pool.
+ *
+ * This class contains a represenation of the constant pool entries. It is
+ * an abstract base class for all the different forms of constant pool entry.
+ *
+ * @author Conor MacNeill
+ * @see ConstantPool
+ */
+public abstract class ConstantPoolEntry {
+
+ /**
+ * Tag value for UTF8 entries.
+ */
+ static public final int CONSTANT_Utf8 = 1;
+
+ /**
+ * Tag value for Integer entries.
+ */
+ static public final int CONSTANT_Integer = 3;
+
+ /**
+ * Tag value for Float entries.
+ */
+ static public final int CONSTANT_Float = 4;
+
+ /**
+ * Tag value for Long entries.
+ */
+ static public final int CONSTANT_Long = 5;
+
+ /**
+ * Tag value for Double entries.
+ */
+ static public final int CONSTANT_Double = 6;
+
+ /**
+ * Tag value for Class entries.
+ */
+ static public final int CONSTANT_Class = 7;
+
+ /**
+ * Tag value for String entries.
+ */
+ static public final int CONSTANT_String = 8;
+
+ /**
+ * Tag value for Field Reference entries.
+ */
+ static public final int CONSTANT_FieldRef = 9;
+
+ /**
+ * Tag value for Method Reference entries.
+ */
+ static public final int CONSTANT_MethodRef = 10;
+
+ /**
+ * Tag value for Interface Method Reference entries.
+ */
+ static public final int CONSTANT_InterfaceMethodRef = 11;
+
+ /**
+ * Tag value for Name and Type entries.
+ */
+ static public final int CONSTANT_NameAndType = 12;
+
+ /**
+ * This entry's tag which identifies the type of this constant pool entry.
+ */
+ private int tag;
+
+ /**
+ * The number of slots in the constant pool, occupied by this entry.
+ */
+ private int numEntries;
+
+ /**
+ * A flag which indiciates if this entry has been resolved or not.
+ */
+ private boolean resolved;
+
+ /**
+ * Initialse the constant pool entry.
+ *
+ * @param tagValue the tag value which identifies which type of constant pool entry this is.
+ * @param entries the number of constant pool entry slots this entry occupies.
+ */
+ public ConstantPoolEntry(int tagValue, int entries) {
+ tag = tagValue;
+ numEntries = entries;
+ resolved = false;
+ }
+
+ /**
+ * Read a constant pool entry from a stream.
+ *
+ * This is a factory method which reads a constant pool entry
+ * form a stream and returns the appropriate subclass for the
+ * entry.
+ *
+ * @param cpStream the stream from which the constant pool entry is to be read.
+ *
+ * @returns the appropriate ConstantPoolEntry subclass representing the
+ * constant pool entry from the stream.
+ *
+ * @throws IOExcception if there is a problem reading the entry from the stream.
+ */
+ static public ConstantPoolEntry readEntry(DataInputStream cpStream) throws IOException {
+ ConstantPoolEntry cpInfo = null;
+ int cpTag = cpStream.readUnsignedByte();
+
+ switch (cpTag) {
+
+ case CONSTANT_Utf8:
+ cpInfo = new Utf8CPInfo();
+
+ break;
+
+ case CONSTANT_Integer:
+ cpInfo = new IntegerCPInfo();
+
+ break;
+
+ case CONSTANT_Float:
+ cpInfo = new FloatCPInfo();
+
+ break;
+
+ case CONSTANT_Long:
+ cpInfo = new LongCPInfo();
+
+ break;
+
+ case CONSTANT_Double:
+ cpInfo = new DoubleCPInfo();
+
+ break;
+
+ case CONSTANT_Class:
+ cpInfo = new ClassCPInfo();
+
+ break;
+
+ case CONSTANT_String:
+ cpInfo = new StringCPInfo();
+
+ break;
+
+ case CONSTANT_FieldRef:
+ cpInfo = new FieldRefCPInfo();
+
+ break;
+
+ case CONSTANT_MethodRef:
+ cpInfo = new MethodRefCPInfo();
+
+ break;
+
+ case CONSTANT_InterfaceMethodRef:
+ cpInfo = new InterfaceMethodRefCPInfo();
+
+ break;
+
+ case CONSTANT_NameAndType:
+ cpInfo = new NameAndTypeCPInfo();
+
+ break;
+
+ default:
+ throw new ClassFormatError("Invalid Constant Pool entry Type " + cpTag);
+ }
+
+ cpInfo.read(cpStream);
+
+ return cpInfo;
+ }
+
+ /**
+ * Indicates whether this entry has been resolved.
+ *
+ * In general a constant pool entry can reference another constant
+ * pool entry by its index value. Resolution involves replacing this
+ * index value with the constant pool entry at that index.
+ *
+ * @return true if this entry has been resolved.
+ */
+ public boolean isResolved() {
+ return resolved;
+ }
+
+ /**
+ * Resolve this constant pool entry with respect to its dependents in
+ * the constant pool.
+ *
+ * @param constantPool the constant pool of which this entry is a member
+ * and against which this entry is to be resolved.
+ */
+ public void resolve(ConstantPool constantPool) {
+ resolved = true;
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public abstract void read(DataInputStream cpStream) throws IOException;
+
+ /**
+ * Get the Entry's type tag.
+ *
+ * @return The Tag value of this entry
+ */
+ public int getTag() {
+ return tag;
+ }
+
+ /**
+ * Get the number of Constant Pool Entry slots within the constant pool occupied by this entry.
+ *
+ * @return the number of slots used.
+ *
+ */
+ public final int getNumEntries() {
+ return numEntries;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java
new file mode 100644
index 000000000..9e48676f5
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java
@@ -0,0 +1,91 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.IOException;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+/**
+ * The constant pool entry subclass used to represent double constant values.
+ *
+ * @author Conor MacNeill
+ */
+public class DoubleCPInfo extends ConstantCPInfo {
+ public DoubleCPInfo() {
+ super(CONSTANT_Double, 2);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ setValue(new Double(cpStream.readDouble()));
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ return "Double Constant Pool Entry: " + getValue();
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FieldRefCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FieldRefCPInfo.java
new file mode 100644
index 000000000..574000f0c
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FieldRefCPInfo.java
@@ -0,0 +1,145 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * A FieldRef CP Info
+ *
+ * @author Conor MacNeill
+ */
+public class FieldRefCPInfo extends ConstantPoolEntry {
+ private String fieldClassName;
+ private String fieldName;
+ private String fieldType;
+ private int classIndex;
+ private int nameAndTypeIndex;
+
+ /**
+ * Constructor.
+ *
+ */
+ public FieldRefCPInfo() {
+ super(CONSTANT_FieldRef, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ classIndex = cpStream.readUnsignedShort();
+ nameAndTypeIndex = cpStream.readUnsignedShort();
+ }
+
+ /**
+ * Resolve this constant pool entry with respect to its dependents in
+ * the constant pool.
+ *
+ * @param constantPool the constant pool of which this entry is a member
+ * and against which this entry is to be resolved.
+ */
+ public void resolve(ConstantPool constantPool) {
+ ClassCPInfo fieldClass = (ClassCPInfo) constantPool.getEntry(classIndex);
+
+ fieldClass.resolve(constantPool);
+
+ fieldClassName = fieldClass.getClassName();
+
+ NameAndTypeCPInfo nt = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);
+
+ nt.resolve(constantPool);
+
+ fieldName = nt.getName();
+ fieldType = nt.getType();
+
+ super.resolve(constantPool);
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ String value;
+
+ if (isResolved()) {
+ value = "Field : Class = " + fieldClassName + ", name = " + fieldName + ", type = " + fieldType;
+ } else {
+ value = "Field : Class index = " + classIndex + ", name and type index = " + nameAndTypeIndex;
+ }
+
+ return value;
+ }
+
+ public String getFieldClassName() {
+ return fieldClassName;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public String getFieldType() {
+ return fieldType;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FloatCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FloatCPInfo.java
new file mode 100644
index 000000000..3342fdf85
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FloatCPInfo.java
@@ -0,0 +1,94 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+
+/**
+ * A Float CP Info
+ *
+ * @author Conor MacNeill
+ */
+public class FloatCPInfo extends ConstantCPInfo {
+
+ /**
+ * Constructor.
+ *
+ */
+ public FloatCPInfo() {
+ super(CONSTANT_Float, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ setValue(new Float(cpStream.readFloat()));
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ return "Float Constant Pool Entry: " + getValue();
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java
new file mode 100644
index 000000000..124aaad11
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java
@@ -0,0 +1,94 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+
+/**
+ * An Integer CP Info
+ *
+ * @author Conor MacNeill
+ */
+public class IntegerCPInfo extends ConstantCPInfo {
+
+ /**
+ * Constructor.
+ *
+ */
+ public IntegerCPInfo() {
+ super(CONSTANT_Integer, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ setValue(new Integer(cpStream.readInt()));
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ return "Integer Constant Pool Entry: " + getValue();
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InterfaceMethodRefCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InterfaceMethodRefCPInfo.java
new file mode 100644
index 000000000..f41f22b2b
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InterfaceMethodRefCPInfo.java
@@ -0,0 +1,147 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * A InterfaceMethodRef CP Info
+ *
+ *
+ * @author Conor MacNeill
+ */
+public class InterfaceMethodRefCPInfo extends ConstantPoolEntry {
+ private String interfaceMethodClassName;
+ private String interfaceMethodName;
+ private String interfaceMethodType;
+ private int classIndex;
+ private int nameAndTypeIndex;
+
+ /**
+ * Constructor.
+ *
+ */
+ public InterfaceMethodRefCPInfo() {
+ super(CONSTANT_InterfaceMethodRef, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ classIndex = cpStream.readUnsignedShort();
+ nameAndTypeIndex = cpStream.readUnsignedShort();
+ }
+
+ /**
+ * Resolve this constant pool entry with respect to its dependents in
+ * the constant pool.
+ *
+ * @param constantPool the constant pool of which this entry is a member
+ * and against which this entry is to be resolved.
+ */
+ public void resolve(ConstantPool constantPool) {
+ ClassCPInfo interfaceMethodClass = (ClassCPInfo) constantPool.getEntry(classIndex);
+
+ interfaceMethodClass.resolve(constantPool);
+
+ interfaceMethodClassName = interfaceMethodClass.getClassName();
+
+ NameAndTypeCPInfo nt = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);
+
+ nt.resolve(constantPool);
+
+ interfaceMethodName = nt.getName();
+ interfaceMethodType = nt.getType();
+
+ super.resolve(constantPool);
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ String value;
+
+ if (isResolved()) {
+ value = "InterfaceMethod : Class = " + interfaceMethodClassName + ", name = " + interfaceMethodName + ", type = "
+ + interfaceMethodType;
+ } else {
+ value = "InterfaceMethod : Class index = " + classIndex + ", name and type index = " + nameAndTypeIndex;
+ }
+
+ return value;
+ }
+
+ public String getInterfaceMethodClassName() {
+ return interfaceMethodClassName;
+ }
+
+ public String getInterfaceMethodName() {
+ return interfaceMethodName;
+ }
+
+ public String getInterfaceMethodType() {
+ return interfaceMethodType;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/LongCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/LongCPInfo.java
new file mode 100644
index 000000000..aa7007f36
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/LongCPInfo.java
@@ -0,0 +1,94 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+
+/**
+ * A Long CP Info
+ *
+ * @author Conor MacNeill
+ */
+public class LongCPInfo extends ConstantCPInfo {
+
+ /**
+ * Constructor.
+ *
+ */
+ public LongCPInfo() {
+ super(CONSTANT_Long, 2);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ setValue(new Long(cpStream.readLong()));
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ return "Long Constant Pool Entry: " + getValue();
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java
new file mode 100644
index 000000000..95a2751d2
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java
@@ -0,0 +1,145 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * A MethodRef CP Info
+ *
+ * @author Conor MacNeill
+ */
+public class MethodRefCPInfo extends ConstantPoolEntry {
+ private String methodClassName;
+ private String methodName;
+ private String methodType;
+ private int classIndex;
+ private int nameAndTypeIndex;
+
+ /**
+ * Constructor.
+ *
+ */
+ public MethodRefCPInfo() {
+ super(CONSTANT_MethodRef, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ classIndex = cpStream.readUnsignedShort();
+ nameAndTypeIndex = cpStream.readUnsignedShort();
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ String value;
+
+ if (isResolved()) {
+ value = "Method : Class = " + methodClassName + ", name = " + methodName + ", type = " + methodType;
+ } else {
+ value = "Method : Class index = " + classIndex + ", name and type index = " + nameAndTypeIndex;
+ }
+
+ return value;
+ }
+
+ /**
+ * Resolve this constant pool entry with respect to its dependents in
+ * the constant pool.
+ *
+ * @param constantPool the constant pool of which this entry is a member
+ * and against which this entry is to be resolved.
+ */
+ public void resolve(ConstantPool constantPool) {
+ ClassCPInfo methodClass = (ClassCPInfo) constantPool.getEntry(classIndex);
+
+ methodClass.resolve(constantPool);
+
+ methodClassName = methodClass.getClassName();
+
+ NameAndTypeCPInfo nt = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);
+
+ nt.resolve(constantPool);
+
+ methodName = nt.getName();
+ methodType = nt.getType();
+
+ super.resolve(constantPool);
+ }
+
+ public String getMethodClassName() {
+ return methodClassName;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public String getMethodType() {
+ return methodType;
+ }
+
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/NameAndTypeCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/NameAndTypeCPInfo.java
new file mode 100644
index 000000000..85181b0aa
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/NameAndTypeCPInfo.java
@@ -0,0 +1,130 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * A NameAndType CP Info
+ *
+ * @author Conor MacNeill
+ */
+public class NameAndTypeCPInfo extends ConstantPoolEntry {
+
+ /**
+ * Constructor.
+ *
+ */
+ public NameAndTypeCPInfo() {
+ super(CONSTANT_NameAndType, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ nameIndex = cpStream.readUnsignedShort();
+ descriptorIndex = cpStream.readUnsignedShort();
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ String value;
+
+ if (isResolved()) {
+ value = "Name = " + name + ", type = " + type;
+ } else {
+ value = "Name index = " + nameIndex + ", descriptor index = " + descriptorIndex;
+ }
+
+ return value;
+ }
+
+ /**
+ * Resolve this constant pool entry with respect to its dependents in
+ * the constant pool.
+ *
+ * @param constantPool the constant pool of which this entry is a member
+ * and against which this entry is to be resolved.
+ */
+ public void resolve(ConstantPool constantPool) {
+ name = ((Utf8CPInfo) constantPool.getEntry(nameIndex)).getValue();
+ type = ((Utf8CPInfo) constantPool.getEntry(descriptorIndex)).getValue();
+
+ super.resolve(constantPool);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ private String name;
+ private String type;
+ private int nameIndex;
+ private int descriptorIndex;
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java
new file mode 100644
index 000000000..19a6cf081
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java
@@ -0,0 +1,113 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * A String Constant Pool Entry.
+ *
+ * The String info contains an index into the constant pool where
+ * a UTF8 string is stored.
+ *
+ * @author Conor MacNeill
+ */
+public class StringCPInfo extends ConstantCPInfo {
+
+ /**
+ * Constructor.
+ *
+ */
+ public StringCPInfo() {
+ super(CONSTANT_String, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ index = cpStream.readUnsignedShort();
+
+ setValue("unresolved");
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ return "String Constant Pool Entry for " + getValue() + "[" + index + "]";
+ }
+
+ /**
+ * Resolve this constant pool entry with respect to its dependents in
+ * the constant pool.
+ *
+ * @param constantPool the constant pool of which this entry is a member
+ * and against which this entry is to be resolved.
+ */
+ public void resolve(ConstantPool constantPool) {
+ setValue(((Utf8CPInfo) constantPool.getEntry(index)).getValue());
+ super.resolve(constantPool);
+ }
+
+ private int index;
+}
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/Utf8CPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/Utf8CPInfo.java
new file mode 100644
index 000000000..0cb94fffb
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/Utf8CPInfo.java
@@ -0,0 +1,100 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * A UTF8 Constant Pool Entry.
+ *
+ * @author Conor MacNeill
+ */
+public class Utf8CPInfo extends ConstantPoolEntry {
+ private String value;
+
+ /**
+ * Constructor.
+ *
+ */
+ public Utf8CPInfo() {
+ super(CONSTANT_Utf8, 1);
+ }
+
+ /**
+ * read a constant pool entry from a class stream.
+ *
+ * @param cpStream the DataInputStream which contains the constant pool entry to be read.
+ *
+ * @throws IOException if there is a problem reading the entry from the stream.
+ */
+ public void read(DataInputStream cpStream) throws IOException {
+ value = cpStream.readUTF();
+ }
+
+ /**
+ * Print a readable version of the constant pool entry.
+ *
+ * @return the string representation of this constant pool entry.
+ */
+ public String toString() {
+ return "UTF8 Value = " + value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+}
+