Re: Missing type information (not seen in visitor)

2017-09-27 Thread Guang Chao
On Tue, Sep 26, 2017 at 7:05 AM, Showalter, Jim 
wrote:

> We have two classes like this:
>
> package com.intuit.foo;
>
> public class Foo {
> }
>
> public class FooHolder {
>private List 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
> 
>   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 think that is expected for Generics if I am not mistaken.  The Foo in
List is just for compile time.  On runtime, it just knows that it is a
List, and do not know it is a list of Foo.


>
> 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]
>
>


-- 
Guang 


RE: Missing type information (not seen in visitor)

2017-09-25 Thread Showalter, Jim
org.apache.bcel

-Original Message-
From: Gary Gregory [mailto:garydgreg...@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_showal...@intuit.com> wrote:

> We have two classes like this:
>
> package com.intuit.foo;
>
> public class Foo {
> }
>
> public class FooHolder {
>private List 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
> 
>   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]
>
>


Re: Missing type information (not seen in visitor)

2017-09-25 Thread Gary Gregory
Which Commons component are you using?

Gary

On Sep 25, 2017 17:05, "Showalter, Jim"  wrote:

> We have two classes like this:
>
> package com.intuit.foo;
>
> public class Foo {
> }
>
> public class FooHolder {
>private List 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
> 
>   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]
>
>


Missing type information (not seen in visitor)

2017-09-25 Thread Showalter, Jim
We have two classes like this:

package com.intuit.foo;

public class Foo {
}

public class FooHolder {
   private List 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

  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]