Details
-
Improvement
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
6.8.0
Description
Component.getBehaviors() is implemented as
"return getBehaviors(Behavior.class);"
but can be
"return getBehaviors(null);"
As mentioned in getBehaviors(Class type) documentation: "The type or null for all". The handling code in Behaviors.getBehaviors method is following:
if (obj != null && obj instanceof Behavior)
{
if (type == null || type.isAssignableFrom(obj.getClass()))
}
When called with "null" parameter, only the first condition of inner "if" is tested. If called with Behavior.class, all conditions has to be evaluated and you call "obj instanceof Behavior" twice in fact (because "Behavior.class.isAssignableFrom(obj.getClass())" is equivalent to "obj instanceof Behavior").