0

I have an abstract generic class.

public abstract class FieldHandlerWithData<DataType extends Parcelable> 
    extends FieldHandler

Now I have an object c

Class<? extends FieldHandler> c = getHandlerClass(type);

and now I want to test if c inherits FieldHandlerWithData (directly or indirectly). How to determine whether c inherits FieldHandlerWithData?

c.isAssignableFrom(FieldHandlerWithData.class) - returns false.

Abhinav Sarkar
  • 23,534
  • 11
  • 81
  • 97
Solvek
  • 5,158
  • 5
  • 41
  • 64
  • possible duplicate of [Check if a subclass is an instance of a class at runtime in Java?](http://stackoverflow.com/questions/2410304/check-if-a-subclass-is-an-instance-of-a-class-at-runtime-in-java) – nanda Sep 27 '10 at 10:23

1 Answers1

1

It's the other way around - FieldHandlerWithData.class.isAssignableFrom(c)

Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter

So this class (the one on which the method is invoked) should be the superclass/superinterface

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140