Fixed
Status Update
Comments
il...@google.com <il...@google.com>
sa...@google.com <sa...@google.com>
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Information redacted by Android Beta Feedback.
Description
Version used: androidx.appcompat:appcompat:1.0.0
The code is checking if the argument class is a superclass of LifecycleOwner instead of if LifecycleOwner being a superclass of the argument class.
class ClassesInfoCache {
...
private CallbackInfo createInfo(Class klass, @Nullable Method[] declaredMethods) {
...
for (Method method : methods) {
OnLifecycleEvent annotation = method.getAnnotation(OnLifecycleEvent.class);
if (annotation == null) {
continue;
}
hasLifecycleMethods = true;
Class<?>[] params = method.getParameterTypes();
int callType = CALL_TYPE_NO_ARG;
if (params.length > 0) {
callType = CALL_TYPE_PROVIDER;
/***
* This is where the issue is found. We want to verify the argument class inherits from LifecycleOwner instead
***/
if (!params[0].isAssignableFrom(LifecycleOwner.class)) {
throw new IllegalArgumentException(
"invalid parameter type. Must be one and instanceof LifecycleOwner");
}
}
...
}