As you know, it Class#isAssignabledoes not take into account that the value can be automatically inserted into the box / unpacked. For example. the bottom of the four following cases returns false:
System.out.println(boolean.class.isAssignableFrom(boolean.class));
System.out.println(Boolean.class.isAssignableFrom(Boolean.class));
System.out.println(boolean.class.isAssignableFrom(Boolean.class));
System.out.println(Boolean.class.isAssignableFrom(boolean.class));
Is there an already existing version of this method that will consider this case? (i.e. return truein all four of the above cases.) If not, what is the best way to implement this for all primitive / wrapped combinations?
source
share