We have two classes like this:
package com.intuit.foo;
public class Foo {
}
public class FooHolder {
private List<Foo> foos = new ArrayList<>();
}
After visiting both classes and dumping out the info, I see this:
com/intuit/foo/Foo:
class, lines 0 to ~2, deletable, public
com/intuit/foo/Foos:
class, lines 0 to ~2, not-deletable, public
type references
<none>
field declarations
com/intuit/obill/v1/quote/response/Quote:chargeDetails:Ljava/util/List;
Note that the type Foo is not seen in when visiting the Foos. Because there are
no other references to Foo anywhere, this results in a false-positive delete of
Foo.java.
I collect all of the referred-to types in the visitor like this:
@Override
public void visitConstantClass(final ConstantClass obj) {
String className =
JavaUtils.dotsToSlashes(javaClass().getConstantPool().getConstant(obj.getNameIndex()).toString().replace("\")",
"").replaceAll("^.*\"", ""));
if (ignore(className)) {
return;
}
type().addTypeReference(className);
}
What am I doing wrong?
Jim Showalter
Programmer
Intuit, 2003H-265Z
Garcia Avenue
Mountain View, CA 94043
(408) 353-4954 [home]
(408) 204-1661 [personal cell]
(669) 271-2257 [work cell]