commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Showalter, Jim" <Jim_Showal...@intuit.com>
Subject RE: Missing type information (not seen in visitor)
Date Tue, 26 Sep 2017 01:19:58 GMT
org.apache.bcel

-----Original Message-----
From: Gary Gregory [mailto:garydgregory@gmail.com] 
Sent: Monday, September 25, 2017 6:15 PM
To: Commons Users List <user@commons.apache.org>
Subject: Re: Missing type information (not seen in visitor)

Which Commons component are you using?

Gary

On Sep 25, 2017 17:05, "Showalter, Jim" <Jim_Showalter@intuit.com> wrote:

> 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]
>
>
Mime
View raw message