Browse Source

Code layout only.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270640 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
624fb42975
20 changed files with 591 additions and 601 deletions
  1. +22
    -22
      src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java
  2. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java
  3. +15
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java
  4. +155
    -164
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  5. +29
    -29
      src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java
  6. +24
    -24
      src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java
  7. +17
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ClassCPInfo.java
  8. +13
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantCPInfo.java
  9. +80
    -80
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java
  10. +65
    -65
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java
  11. +12
    -12
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java
  12. +21
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FieldRefCPInfo.java
  13. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FloatCPInfo.java
  14. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java
  15. +23
    -23
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InterfaceMethodRefCPInfo.java
  16. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/LongCPInfo.java
  17. +21
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java
  18. +20
    -20
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/NameAndTypeCPInfo.java
  19. +16
    -16
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java
  20. +14
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/Utf8CPInfo.java

+ 22
- 22
src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,22 +53,22 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.DataInputStream;

import java.util.Vector;
import org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPool;

import org.apache.tools.ant.taskdefs.optional.depend.constantpool.ClassCPInfo;
import org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPool;
import org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPoolEntry;

/**
* 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 {
@@ -92,16 +92,16 @@ public class ClassFile {

/**
* Read the class from a data stream.
*
*
* This method takes an InputStream as input and
* parses the class from the stream.
* <p>
*
*
* @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);
@@ -109,7 +109,7 @@ public class ClassFile {

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();
@@ -125,7 +125,7 @@ public class ClassFile {
int thisClassIndex = classStream.readUnsignedShort();
int superClassIndex = classStream.readUnsignedShort();
className = ((ClassCPInfo) constantPool.getEntry(thisClassIndex)).getClassName();
}
}


/**
@@ -143,20 +143,20 @@ public class ClassFile {

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);
}
}
}


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"


+ 15
- 15
src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -55,11 +55,11 @@ 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 {
@@ -67,24 +67,24 @@ 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).
*/
public static String convertSlashName(String name) {
return name.replace('\\', '.').replace( '/', '.' );
}
return name.replace('\\', '.').replace('/', '.');
}

/**
* 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).
*/
public static String convertDotName(String dotName) {
return dotName.replace( '.', '/');
}
return dotName.replace('.', '/');
}
}


+ 155
- 164
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -54,30 +54,29 @@

package org.apache.tools.ant.taskdefs.optional.depend;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.taskdefs.MatchingTask;

import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import java.io.File;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;


/**
* Generate a dependency file for a given set of classes
* Generate a dependency file for a given set of classes
*
* @author Conor MacNeill
*/
@@ -88,25 +87,25 @@ public class Depend extends MatchingTask {
private static class ClassFileInfo {
/** The file where the class file is stored in the file system */
public File absoluteFile;
/** The location of the file relative to its base directory - the root
of the package namespace */
of the package namespace */
public String relativeName;
/** The Java class name of this class */
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.
*/
@@ -121,10 +120,10 @@ public class Depend extends MatchingTask {
* A map which gives information about a class
*/
private Hashtable classFileInfoMap;
/**
* A map which gives the list of jars and classes from the classpath that
* a class depends upon
* a class depends upon
*/
private Hashtable classpathDependencies;

@@ -132,14 +131,14 @@ public class Depend extends MatchingTask {
* The list of classes which are out of date.
*/
private Hashtable 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 = false;
/**
* Flag which controls whether the reversed dependencies should be dumped
* to the log
@@ -187,13 +186,13 @@ public class Depend extends MatchingTask {
public void setClasspathRef(Reference r) {
createClasspath().setRefid(r);
}
/**
* Read the dependencies from cache file
*/
private Hashtable readCachedDependencies() throws IOException{
private Hashtable readCachedDependencies() throws IOException {
Hashtable dependencyMap = new Hashtable();
if (cache != null) {
File depFile = new File(cache, CACHE_FILE_NAME);
BufferedReader in = null;
@@ -209,48 +208,45 @@ public class Depend extends MatchingTask {
dependencyList = new Vector();
className = line.substring(prependLength);
dependencyMap.put(className, dependencyList);
}
else {
} else {
dependencyList.addElement(line);
}
}
}
finally {
if (in != null) {
} finally {
if (in != null) {
in.close();
}
}
}
}
return dependencyMap;
}
/**
* Write the dependencies to cache file
*/
private void writeCachedDependencies(Hashtable dependencyMap) throws IOException{
private void writeCachedDependencies(Hashtable dependencyMap) throws IOException {
if (cache != null) {
PrintWriter pw = null;
try {
cache.mkdirs();
cache.mkdirs();
File depFile = new File(cache, CACHE_FILE_NAME);
pw = new PrintWriter(new FileWriter(depFile));
for (Enumeration deps = dependencyMap.keys(); deps.hasMoreElements();) {
String className = (String)deps.nextElement();
String className = (String) deps.nextElement();
pw.println(CLASSNAME_PREPEND + className);
Vector dependencyList = (Vector)dependencyMap.get(className);
Vector dependencyList = (Vector) dependencyMap.get(className);
int size = dependencyList.size();
for (int x = 0; x < size; x++) {
pw.println(dependencyList.elementAt(x));
}
}
}
finally {
if (pw != null) {
} finally {
if (pw != null) {
pw.close();
}
}
@@ -259,21 +255,21 @@ public class Depend extends MatchingTask {


/**
* Determine the dependencies between classes.
* Determine the dependencies between classes.
*
* Class dependencies are determined by examining the class references in a class file
* to other classes
* to other classes
*/
private void determineDependencies() throws IOException {
affectedClassMap = new Hashtable();
classFileInfoMap = new Hashtable();
boolean cacheDirty = false;
Hashtable dependencyMap = new Hashtable();
File depCacheFile = null;
boolean depCacheFileExists = true;
long depCacheFileLastModified = Long.MAX_VALUE;
// read the dependency cache from the disk
if (cache != null) {
dependencyMap = readCachedDependencies();
@@ -281,22 +277,22 @@ public class Depend extends MatchingTask {
depCacheFileExists = depCacheFile.exists();
depCacheFileLastModified = depCacheFile.lastModified();
}
for (Enumeration e = getClassFiles(destPath).elements(); e.hasMoreElements(); ) {
ClassFileInfo info = (ClassFileInfo)e.nextElement();
for (Enumeration e = getClassFiles(destPath).elements(); e.hasMoreElements();) {
ClassFileInfo info = (ClassFileInfo) e.nextElement();
log("Adding class info for " + info.className, Project.MSG_DEBUG);
classFileInfoMap.put(info.className, info);
Vector dependencyList = null;
if (cache != null) {
// try to read the dependency info from the map if it is not out of date
if (depCacheFileExists && depCacheFileLastModified > info.absoluteFile.lastModified()) {
// depFile exists and is newer than the class file
// need to get dependency list from the map.
dependencyList = (Vector)dependencyMap.get(info.className);
dependencyList = (Vector) dependencyMap.get(info.className);
}
}
if (dependencyList == null) {
// not cached - so need to read directly from the class file
FileInputStream inFileStream = null;
@@ -304,55 +300,54 @@ public class Depend extends MatchingTask {
inFileStream = new FileInputStream(info.absoluteFile);
ClassFile classFile = new ClassFile();
classFile.read(inFileStream);
dependencyList = classFile.getClassRefs();
if (dependencyList != null) {
cacheDirty = true;
dependencyMap.put(info.className, dependencyList);
}
}
finally {

} 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);
// 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);
}
}
classpathDependencies = null;
if (dependClasspath != null) {
// now determine which jars each class depends upon
classpathDependencies = new Hashtable();
AntClassLoader loader = new AntClassLoader(getProject(), dependClasspath);
Hashtable classpathFileCache = new Hashtable();
Object nullFileMarker = new Object();
for (Enumeration e = dependencyMap.keys(); e.hasMoreElements();) {
String className = (String)e.nextElement();
Vector dependencyList = (Vector)dependencyMap.get(className);
String className = (String) e.nextElement();
Vector dependencyList = (Vector) dependencyMap.get(className);
Hashtable dependencies = new Hashtable();
classpathDependencies.put(className, dependencies);
for (Enumeration e2 = dependencyList.elements(); e2.hasMoreElements();) {
String dependency =(String)e2.nextElement();
String dependency = (String) e2.nextElement();
Object classpathFileObject = classpathFileCache.get(dependency);
if (classpathFileObject == null) {
classpathFileObject = nullFileMarker;
if (!dependency.startsWith("java.") && !dependency.startsWith("javax.")) {
URL classURL = loader.getResource(dependency.replace('.', '/') + ".class");
if (classURL != null) {
@@ -363,78 +358,76 @@ public class Depend extends MatchingTask {
jarFilePath = jarFilePath.substring(5, classMarker);
}
classpathFileObject = new File(jarFilePath);
}
else if (classURL.getProtocol().equals("file")) {
} else if (classURL.getProtocol().equals("file")) {
String classFilePath = classURL.getFile();
classpathFileObject = new File(classFilePath);
}
log("Class " + className +
" depends on " + classpathFileObject +
" due to " + dependency, Project.MSG_DEBUG);
log("Class " + className +
" depends on " + classpathFileObject +
" due to " + dependency, Project.MSG_DEBUG);
}
}
classpathFileCache.put(dependency, classpathFileObject);
}
if (classpathFileObject != null && classpathFileObject != nullFileMarker) {
// we need to add this jar to the list for this class.
File jarFile = (File)classpathFileObject;
File jarFile = (File) classpathFileObject;
dependencies.put(jarFile, jarFile);
}
}
}
}
// write the dependency cache to the disk
if (cache != null && cacheDirty) {
writeCachedDependencies(dependencyMap);
}
}
private int deleteAllAffectedFiles() {
int count = 0;
for (Enumeration e = outOfDateClasses.elements(); e.hasMoreElements();) {
String className = (String)e.nextElement();
String className = (String) e.nextElement();
count += deleteAffectedFiles(className);
ClassFileInfo classInfo = (ClassFileInfo)classFileInfoMap.get(className);
ClassFileInfo classInfo = (ClassFileInfo) classFileInfoMap.get(className);
if (classInfo != null && classInfo.absoluteFile.exists()) {
classInfo.absoluteFile.delete();
count++;
}
}
return count;
return count;
}
private int deleteAffectedFiles(String className) {
int count = 0;

Hashtable affectedClasses = (Hashtable)affectedClassMap.get(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);
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);
log("Deleting file " + affectedClassInfo.absoluteFile.getPath() + " since " +
className + " out of date", Project.MSG_VERBOSE);
affectedClassInfo.absoluteFile.delete();
count++;
if (closure) {
count += deleteAffectedFiles(affectedClassName);
}
else {
} else {
// without closure we may delete an inner class but not the
// top level class which would not trigger a recompile.
if (affectedClassName.indexOf("$") != -1) {
// need to delete the main class
String topLevelClassName
= affectedClassName.substring(0, affectedClassName.indexOf("$"));
String topLevelClassName
= affectedClassName.substring(0, affectedClassName.indexOf("$"));
log("Top level class = " + topLevelClassName, Project.MSG_VERBOSE);
ClassFileInfo topLevelClassInfo
= (ClassFileInfo)classFileInfoMap.get(topLevelClassName);
ClassFileInfo topLevelClassInfo
= (ClassFileInfo) classFileInfoMap.get(topLevelClassName);
if (topLevelClassInfo != null &&
topLevelClassInfo.absoluteFile.exists()) {
log("Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " +
"one of its inner classes was removed", Project.MSG_VERBOSE);
topLevelClassInfo.absoluteFile.exists()) {
log("Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " +
"one of its inner classes was removed", Project.MSG_VERBOSE);
topLevelClassInfo.absoluteFile.delete();
count++;
if (closure) {
@@ -457,59 +450,59 @@ public class Depend extends MatchingTask {
public void execute() throws BuildException {
try {
long start = System.currentTimeMillis();
String [] srcPathList = srcPath.list();
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();
if (dump) {
log("Reverse Dependency Dump for " + affectedClassMap.size() +
" classes:", Project.MSG_DEBUG);
for (Enumeration e = affectedClassMap.keys(); e.hasMoreElements(); ) {
String className = (String)e.nextElement();
if (dump) {
log("Reverse Dependency Dump for " + affectedClassMap.size() +
" classes:", Project.MSG_DEBUG);
for (Enumeration e = affectedClassMap.keys(); e.hasMoreElements();) {
String className = (String) e.nextElement();
log(" Class " + className + " affects:", Project.MSG_DEBUG);
Hashtable affectedClasses = (Hashtable)affectedClassMap.get(className);
for (Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements(); ) {
String affectedClass = (String)e2.nextElement();
ClassFileInfo info = (ClassFileInfo)affectedClasses.get(affectedClass);
Hashtable affectedClasses = (Hashtable) affectedClassMap.get(className);
for (Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements();) {
String affectedClass = (String) e2.nextElement();
ClassFileInfo info = (ClassFileInfo) affectedClasses.get(affectedClass);
log(" " + affectedClass + " in " + info.absoluteFile.getPath(), Project.MSG_DEBUG);
}
}
if (classpathDependencies != null) {
log("Classpath file dependencies (Forward):", Project.MSG_DEBUG);
for (Enumeration e = classpathDependencies.keys(); e.hasMoreElements();) {
String className = (String)e.nextElement();
for (Enumeration e = classpathDependencies.keys(); e.hasMoreElements();) {
String className = (String) e.nextElement();
log(" Class " + className + " depends on:", Project.MSG_DEBUG);
Hashtable dependencies = (Hashtable)classpathDependencies.get(className);
Hashtable dependencies = (Hashtable) classpathDependencies.get(className);
for (Enumeration e2 = dependencies.elements(); e2.hasMoreElements();) {
File classpathFile = (File)e2.nextElement();
File classpathFile = (File) e2.nextElement();
log(" " + classpathFile.getPath(), Project.MSG_DEBUG);
}
}
}
}
// 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 Hashtable();
for (int i=0; i < srcPathList.length; i++) {
File srcDir = (File)project.resolveFile(srcPathList[i]);
for (int i = 0; i < srcPathList.length; i++) {
File srcDir = (File) project.resolveFile(srcPathList[i]);
if (srcDir.exists()) {
DirectoryScanner ds = this.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles();
@@ -519,20 +512,20 @@ public class Depend extends MatchingTask {

// now check classpath file dependencies
if (classpathDependencies != null) {
for (Enumeration e = classpathDependencies.keys(); e.hasMoreElements();) {
String className = (String)e.nextElement();
for (Enumeration e = classpathDependencies.keys(); e.hasMoreElements();) {
String className = (String) e.nextElement();
if (!outOfDateClasses.containsKey(className)) {
ClassFileInfo info = (ClassFileInfo)classFileInfoMap.get(className);
// if we have no info about the class - it may have been deleted already and we
ClassFileInfo info = (ClassFileInfo) classFileInfoMap.get(className);
// if we have no info about the class - it may have been deleted already and we
// are using cached info.
if (info != null) {
Hashtable dependencies = (Hashtable)classpathDependencies.get(className);
Hashtable dependencies = (Hashtable) classpathDependencies.get(className);
for (Enumeration e2 = dependencies.elements(); e2.hasMoreElements();) {
File classpathFile = (File)e2.nextElement();
File classpathFile = (File) e2.nextElement();
if (classpathFile.lastModified() > info.absoluteFile.lastModified()) {
log("Class " + className +
" is out of date with respect to " + classpathFile, Project.MSG_DEBUG);
log("Class " + className +
" is out of date with respect to " + classpathFile, Project.MSG_DEBUG);
outOfDateClasses.put(className, className);
break;
}
@@ -541,11 +534,11 @@ public class Depend extends MatchingTask {
}
}
}
// we now have a complete list of classes which are out of date
// We scan through the affected classes, deleting any affected classes.
int count = deleteAllAffectedFiles();
long duration = (System.currentTimeMillis() - start) / 1000;
log("Deleted " + count + " out of date files in " + duration + " seconds");
} catch (Exception e) {
@@ -566,14 +559,13 @@ public class Depend extends MatchingTask {
if (files[i].endsWith(".java")) {
String filePath = srcFile.getPath();
String className = filePath.substring(srcDir.getPath().length() + 1,
filePath.length() - ".java".length());
className = ClassFileUtils.convertSlashName(className);
ClassFileInfo info = (ClassFileInfo)classFileInfoMap.get(className);
filePath.length() - ".java".length());
className = ClassFileUtils.convertSlashName(className);
ClassFileInfo info = (ClassFileInfo) classFileInfoMap.get(className);
if (info == null) {
// there was no class file. add this class to the list
outOfDateClasses.put(className, className);
}
else {
} else {
if (srcFile.lastModified() > info.absoluteFile.lastModified()) {
outOfDateClasses.put(className, className);
}
@@ -583,7 +575,7 @@ public class Depend extends MatchingTask {
}


/**
/**
* Get the list of class files we are going to analyse.
*
* @param classLocations a path structure containing all the directories
@@ -591,23 +583,23 @@ public class Depend extends MatchingTask {
* @return a vector containing the classes to analyse.
*/
private Vector getClassFiles(Path classLocations) {
// break the classLocations into its components.
String[] classLocationsList = classLocations.list();
// 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
/**
* 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
@@ -616,7 +608,7 @@ public class Depend extends MatchingTask {
*/
private void addClassFiles(Vector classFileList, File dir, File root) {
String[] filesInDir = dir.list();
if (filesInDir != null) {
int length = filesInDir.length;

@@ -624,20 +616,19 @@ public class Depend extends MatchingTask {
File file = new File(dir, filesInDir[i]);
if (file.isDirectory()) {
addClassFiles(classFileList, file, root);
}
else if (file.getName().endsWith(".class")) {
} 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);
file.getPath().length() - 6);
info.className = ClassFileUtils.convertSlashName(info.relativeName);
classFileList.addElement(info);
}
}
}
}
}
}
/**
* Set the source dirs to find the source Java files.
*/
@@ -651,11 +642,11 @@ public class Depend extends MatchingTask {
public void setDestDir(Path destPath) {
this.destPath = destPath;
}
public void setCache(File cache) {
this.cache = cache;
}
public void setClosure(boolean closure) {
this.closure = closure;
}


+ 29
- 29
src/main/org/apache/tools/ant/taskdefs/optional/depend/DirectoryIterator.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,19 +53,19 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend;

import java.util.Stack;
import java.util.Enumeration;
import java.util.Vector;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Stack;
import java.util.Vector;

/**
* 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 {
@@ -92,15 +92,15 @@ public class DirectoryIterator implements ClassFileIterator {

/**
* 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 {
@@ -112,7 +112,7 @@ public class DirectoryIterator implements ClassFileIterator {
rootLength = rootDirectory.getPath().length() + 1;
} else {
rootLength = 0;
}
}

Vector filesInRoot = getDirectoryEntries(rootDirectory);

@@ -121,9 +121,9 @@ public class DirectoryIterator implements ClassFileIterator {

/**
* 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) {
@@ -137,15 +137,15 @@ public class DirectoryIterator implements ClassFileIterator {

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
@@ -153,7 +153,7 @@ public class DirectoryIterator implements ClassFileIterator {
* 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() {
@@ -186,23 +186,23 @@ public class DirectoryIterator implements ClassFileIterator {
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;
}
}

}


+ 24
- 24
src/main/org/apache/tools/ant/taskdefs/optional/depend/JarFileIterator.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,15 +53,15 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend;

import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
* A class file iterator which iterates through the contents of a Java jar file.
*
*
* @author Conor MacNeill
*/
public class JarFileIterator implements ClassFileIterator {
@@ -74,19 +74,19 @@ public class JarFileIterator implements ClassFileIterator {
}

private byte[] getEntryBytes(InputStream stream) throws IOException {
byte[] buffer = new byte[8192];
byte[] buffer = new byte[8192];
ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
int n;
int n;

while ((n = stream.read(buffer, 0, buffer.length)) != -1) {
baos.write(buffer, 0, n);
}
}

return baos.toByteArray();
}
}

public ClassFile getNextClassFile() {
ZipEntry jarEntry;
ZipEntry jarEntry;
ClassFile nextElement = null;

try {
@@ -98,30 +98,30 @@ public class JarFileIterator implements ClassFileIterator {

if (!jarEntry.isDirectory() && entryName.endsWith(".class")) {

// create a data input stream from the jar input stream
ClassFile javaClass = new ClassFile();
// create a data input stream from the jar input stream
ClassFile javaClass = new ClassFile();

javaClass.read(jarStream);
javaClass.read(jarStream);

nextElement = javaClass;
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;
}
}

}


+ 17
- 17
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ClassCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,13 +53,13 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* The constant pool entry which stores class information.
*
*
* @author Conor MacNeill
*/
public class ClassCPInfo extends ConstantPoolEntry {
@@ -75,11 +75,11 @@ public class ClassCPInfo extends ConstantPoolEntry {
* name is changed, this entry is invalid until this entry is connected to a constant
* pool.
*/
private int index;
private int index;

/**
* Constructor.
*
*
* Sets the tag value for this entry to type Class
*/
public ClassCPInfo() {
@@ -88,42 +88,42 @@ public class ClassCPInfo extends ConstantPoolEntry {

/**
* 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;
}
}

}


+ 13
- 14
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -54,18 +54,17 @@
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;



/**
* 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.
*/
@@ -73,7 +72,7 @@ abstract public class ConstantCPInfo extends ConstantPoolEntry {

/**
* 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.
*/
@@ -83,21 +82,21 @@ abstract public class ConstantCPInfo extends ConstantPoolEntry {

/**
* 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;
}
}

}


+ 80
- 80
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPool.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,20 +53,20 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.util.Vector;
import java.util.Hashtable;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

/**
* 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 <a href="http://java.sun.com/docs/books/vmspec/">The Java Virtual Machine Specification</a>
*
*
* @author Conor MacNeill
*/
public class ConstantPool {
@@ -96,23 +96,23 @@ public class ConstantPool {

/**
* 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; ) {
for (int i = 1; i < numEntries;) {
ConstantPoolEntry nextEntry = ConstantPoolEntry.readEntry(classStream);

i += nextEntry.getNumEntries();

addEntry(nextEntry);
}
}
}
}

/**
* Get the size of the constant pool.
@@ -120,12 +120,12 @@ public class ConstantPool {
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) {
@@ -138,69 +138,69 @@ public class ConstantPool {
// 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(); ) {
for (Enumeration i = entries.elements(); i.hasMoreElements();) {
ConstantPoolEntry poolInfo = (ConstantPoolEntry) i.nextElement();

if (poolInfo != null &&!poolInfo.isResolved()) {
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;
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.
*/
@@ -215,18 +215,18 @@ public class ConstantPool {

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.
*/
@@ -241,21 +241,21 @@ public class ConstantPool {

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.
*/
@@ -268,24 +268,24 @@ public class ConstantPool {
if (element instanceof MethodRefCPInfo) {
MethodRefCPInfo methodRefEntry = (MethodRefCPInfo) element;

if (methodRefEntry.getMethodClassName().equals(methodClassName)
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.
*/
@@ -298,25 +298,25 @@ public class ConstantPool {
if (element instanceof InterfaceMethodRefCPInfo) {
InterfaceMethodRefCPInfo interfaceMethodRefEntry = (InterfaceMethodRefCPInfo) element;

if (interfaceMethodRefEntry.getInterfaceMethodClassName().equals(interfaceMethodClassName)
&& interfaceMethodRefEntry.getInterfaceMethodName().equals(interfaceMethodName)
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.
*/
@@ -329,22 +329,22 @@ public class ConstantPool {
if (element instanceof FieldRefCPInfo) {
FieldRefCPInfo fieldRefEntry = (FieldRefCPInfo) element;

if (fieldRefEntry.getFieldClassName().equals(fieldClassName) && fieldRefEntry.getFieldName().equals(fieldName)
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.
*/
@@ -359,28 +359,28 @@ public class ConstantPool {

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();
int size = entries.size();

for (int i = 0; i < size; ++i) {
sb.append("[" + i + "] = " + getEntry(i) + "\n");
}
}

return sb.toString();
}
}

}


+ 65
- 65
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,16 +53,16 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* 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
*/
@@ -126,21 +126,21 @@ public abstract class ConstantPoolEntry {
/**
* This entry's tag which identifies the type of this constant pool entry.
*/
private int tag;
private int tag;

/**
* The number of slots in the constant pool, occupied by this entry.
*/
private int numEntries;
private int numEntries;

/**
* A flag which indiciates if this entry has been resolved or not.
*/
private boolean resolved;
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.
*/
@@ -152,139 +152,139 @@ public abstract class ConstantPoolEntry {

/**
* 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.
*/
public static ConstantPoolEntry readEntry(DataInputStream cpStream) throws IOException {
ConstantPoolEntry cpInfo = null;
int cpTag = cpStream.readUnsignedByte();
int cpTag = cpStream.readUnsignedByte();

switch (cpTag) {

case CONSTANT_Utf8:
cpInfo = new Utf8CPInfo();
case CONSTANT_Utf8:
cpInfo = new Utf8CPInfo();

break;
break;

case CONSTANT_Integer:
cpInfo = new IntegerCPInfo();
case CONSTANT_Integer:
cpInfo = new IntegerCPInfo();

break;
break;

case CONSTANT_Float:
cpInfo = new FloatCPInfo();
case CONSTANT_Float:
cpInfo = new FloatCPInfo();

break;
break;

case CONSTANT_Long:
cpInfo = new LongCPInfo();
case CONSTANT_Long:
cpInfo = new LongCPInfo();

break;
break;

case CONSTANT_Double:
cpInfo = new DoubleCPInfo();
case CONSTANT_Double:
cpInfo = new DoubleCPInfo();

break;
break;

case CONSTANT_Class:
cpInfo = new ClassCPInfo();
case CONSTANT_Class:
cpInfo = new ClassCPInfo();

break;
break;

case CONSTANT_String:
cpInfo = new StringCPInfo();
case CONSTANT_String:
cpInfo = new StringCPInfo();

break;
break;

case CONSTANT_FieldRef:
cpInfo = new FieldRefCPInfo();
case CONSTANT_FieldRef:
cpInfo = new FieldRefCPInfo();

break;
break;

case CONSTANT_MethodRef:
cpInfo = new MethodRefCPInfo();
case CONSTANT_MethodRef:
cpInfo = new MethodRefCPInfo();

break;
break;

case CONSTANT_InterfaceMethodRef:
cpInfo = new InterfaceMethodRefCPInfo();
case CONSTANT_InterfaceMethodRef:
cpInfo = new InterfaceMethodRefCPInfo();

break;
break;

case CONSTANT_NameAndType:
cpInfo = new NameAndTypeCPInfo();
case CONSTANT_NameAndType:
cpInfo = new NameAndTypeCPInfo();

break;
break;

default:
throw new ClassFormatError("Invalid Constant Pool entry Type " + cpTag);
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;
}
}

}


+ 12
- 12
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,13 +53,13 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* The constant pool entry subclass used to represent double constant values.
*
*
* @author Conor MacNeill
*/
public class DoubleCPInfo extends ConstantCPInfo {
@@ -69,23 +69,23 @@ public class DoubleCPInfo extends ConstantCPInfo {

/**
* 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();
}
}

}


+ 21
- 21
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FieldRefCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,25 +53,25 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* 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;
private int classIndex;
private int nameAndTypeIndex;

/**
* Constructor.
*
*
*/
public FieldRefCPInfo() {
super(CONSTANT_FieldRef, 1);
@@ -79,20 +79,20 @@ public class FieldRefCPInfo extends ConstantPoolEntry {

/**
* 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.
*/
@@ -111,11 +111,11 @@ public class FieldRefCPInfo extends ConstantPoolEntry {
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() {
@@ -125,22 +125,22 @@ public class FieldRefCPInfo extends ConstantPoolEntry {
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;
}
}

}


+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/FloatCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,19 +53,19 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;

/**
* A Float CP Info
*
*
* @author Conor MacNeill
*/
public class FloatCPInfo extends ConstantCPInfo {

/**
* Constructor.
*
*
*/
public FloatCPInfo() {
super(CONSTANT_Float, 1);
@@ -73,23 +73,23 @@ public class FloatCPInfo extends ConstantCPInfo {

/**
* 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();
}
}

}


+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,19 +53,19 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;

/**
* An Integer CP Info
*
*
* @author Conor MacNeill
*/
public class IntegerCPInfo extends ConstantCPInfo {

/**
* Constructor.
*
*
*/
public IntegerCPInfo() {
super(CONSTANT_Integer, 1);
@@ -73,23 +73,23 @@ public class IntegerCPInfo extends ConstantCPInfo {

/**
* 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();
}
}

}


+ 23
- 23
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InterfaceMethodRefCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,26 +53,26 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* 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;
private int classIndex;
private int nameAndTypeIndex;

/**
* Constructor.
*
*
*/
public InterfaceMethodRefCPInfo() {
super(CONSTANT_InterfaceMethodRef, 1);
@@ -80,20 +80,20 @@ public class InterfaceMethodRefCPInfo extends ConstantPoolEntry {

/**
* 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.
*/
@@ -112,37 +112,37 @@ public class InterfaceMethodRefCPInfo extends ConstantPoolEntry {
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 = "
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;
}
}

}


+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/LongCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,19 +53,19 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;

/**
* A Long CP Info
*
*
* @author Conor MacNeill
*/
public class LongCPInfo extends ConstantCPInfo {

/**
* Constructor.
*
*
*/
public LongCPInfo() {
super(CONSTANT_Long, 2);
@@ -73,23 +73,23 @@ public class LongCPInfo extends ConstantCPInfo {

/**
* 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();
}
}

}


+ 21
- 21
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,25 +53,25 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* 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;
private int classIndex;
private int nameAndTypeIndex;

/**
* Constructor.
*
*
*/
public MethodRefCPInfo() {
super(CONSTANT_MethodRef, 1);
@@ -79,19 +79,19 @@ public class MethodRefCPInfo extends ConstantPoolEntry {

/**
* 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() {
@@ -101,15 +101,15 @@ public class MethodRefCPInfo extends ConstantPoolEntry {
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.
*/
@@ -128,19 +128,19 @@ public class MethodRefCPInfo extends ConstantPoolEntry {
methodType = nt.getType();

super.resolve(constantPool);
}
}

public String getMethodClassName() {
return methodClassName;
}
}

public String getMethodName() {
return methodName;
}
}

public String getMethodType() {
return methodType;
}
}

}


+ 20
- 20
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/NameAndTypeCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,20 +53,20 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* A NameAndType CP Info
*
*
* @author Conor MacNeill
*/
public class NameAndTypeCPInfo extends ConstantPoolEntry {

/**
* Constructor.
*
*
*/
public NameAndTypeCPInfo() {
super(CONSTANT_NameAndType, 1);
@@ -74,19 +74,19 @@ public class NameAndTypeCPInfo extends ConstantPoolEntry {

/**
* 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() {
@@ -96,15 +96,15 @@ public class NameAndTypeCPInfo extends ConstantPoolEntry {
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.
*/
@@ -113,19 +113,19 @@ public class NameAndTypeCPInfo extends ConstantPoolEntry {
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;
private int nameIndex;
private int descriptorIndex;
}


+ 16
- 16
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,23 +53,23 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* 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);
@@ -77,37 +77,37 @@ public class StringCPInfo extends ConstantCPInfo {

/**
* 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;
}


+ 14
- 14
src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/Utf8CPInfo.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* 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"
@@ -53,13 +53,13 @@
*/
package org.apache.tools.ant.taskdefs.optional.depend.constantpool;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.IOException;


/**
* A UTF8 Constant Pool Entry.
*
*
* @author Conor MacNeill
*/
public class Utf8CPInfo extends ConstantPoolEntry {
@@ -67,7 +67,7 @@ public class Utf8CPInfo extends ConstantPoolEntry {

/**
* Constructor.
*
*
*/
public Utf8CPInfo() {
super(CONSTANT_Utf8, 1);
@@ -75,27 +75,27 @@ public class Utf8CPInfo extends ConstantPoolEntry {

/**
* 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;
}
}

}


Loading…
Cancel
Save