A DESCRIPTION OF THE PROBLEM :
As explained in [https://github.com/openjdk/jdk/pull/7061#issuecomment-1046816442], `Class::isAssignableFrom` tends to be used incorrectly (see:JDK-8034820, JDK-8254717, and JDK-8279800).
I propose to add the following method to `java.lang.Class`, which should hopefully be clearer about the order of arguments:
```java
public boolean isSublassOf(final Class<?> cls) {
return cls.isAssignableFrom(this);
}
```
this method also complements the `Class::asSubclassOf` method.
As explained in [https://github.com/openjdk/jdk/pull/7061#issuecomment-1046816442], `Class::isAssignableFrom` tends to be used incorrectly (see:
I propose to add the following method to `java.lang.Class`, which should hopefully be clearer about the order of arguments:
```java
public boolean isSublassOf(final Class<?> cls) {
return cls.isAssignableFrom(this);
}
```
this method also complements the `Class::asSubclassOf` method.
- relates to
-
JDK-8279800 isAssignableFrom checks in AlgorithmParametersSpi.engineGetParameterSpec appear to be backwards
- Resolved
-
JDK-8254717 isAssignableFrom checks in KeyFactorySpi.engineGetKeySpec appear to be backwards
- Resolved
-
JDK-8034820 Wrong isAssignableFrom test when adding Principal to Subject
- Closed