Skip to content

[java] False positive for UseInstanceofToCompareClasses on local generic class #30

Description

@oowekyala

UseInstanceofToCompareClasses reports on non-reifiable types, even though they're not acceptable as operand to instanceof. E.g.:

class Foo<T> {

public Foo<T> wrap() {
   // since the local class is not static, the T here refers to the T of the outer instance
   class MyWrapper extends Foo<T> {
      
   }
   this instanceof MyWrapper // -> error, MyWrapper is not reifiable, because its supertype Foo<T> isn't 

   this.getClass().equals(MyWrapper.class) // this is the only way to compare it
} 

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions