conor 2002/12/19 06:05:04
Modified: src/main/org/apache/tools/ant/util/depend/bcel
DependencyVisitor.java
Log:
Detect more class references, particularly the ones used to create
Class instances
Suggested by: Frank-Michael Moser
Revision Changes Path
1.4 +22 -1
jakarta-ant/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java
Index: DependencyVisitor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- DependencyVisitor.java 27 Mar 2002 10:21:30 -0000 1.3
+++ DependencyVisitor.java 19 Dec 2002 14:05:04 -0000 1.4
@@ -62,6 +62,7 @@
import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
+import org.apache.bcel.classfile.ConstantNameAndType;
/**
* A BCEL visitor implementation to collect class dependency information
@@ -114,6 +115,26 @@
}
/**
+ * Visit a name and type ref
+ *
+ * Look for class references in this
+ */
+ public void visitConstantNameAndType(ConstantNameAndType obj) {
+ String name = obj.getName(constantPool);
+ if (obj.getSignature(constantPool).equals("Ljava/lang/Class;")
+ && name.startsWith("class$")) {
+ String classname = name.substring(6).replace('$', '.');
+ addClass(classname);
+ int index = classname.lastIndexOf(".");
+ if (index != -1) {
+ classname = classname.substring(0, index) + "$" +
+ classname.substring(index + 1);
+ addClass(classname);
+ }
+ }
+ }
+
+ /**
* Visit a field of the class.
*
* @param field the field being visited
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>