ADDITIONAL SYSTEM INFORMATION : Windows 10/ JDK 8, issue still exists in OpenJDK 10/11 A DESCRIPTION OF THE PROBLEM : Javadoc states "The default implementation provided in the Observable class will notify Observers in the order in which they registered interest". However the actual implementation iterates the array in reverse order. While this is qualified by a prior statement that contractually order is unspecified, it is still confusing & erroneous. Recommended fix: - While forward order of notification would seem logically preferable, changing the ordering in the implementation would likely be impactful and break compatibility. - Therefore it would likely be preferable to correct the documentation, to state that the default implementation delivered notifications "in the reverse order to which they registered interest". STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1) Check the Observable Javadoc to see it states "The default implementation provided in the Observable class will notify Observers in the order in which they registered interest". 2) Check Observable.notifyObservers (Object) implementation for code which notifies observes in reverse of the documented order: for (int i = arrLocal.length-1; i>=0; i--) ((Observer)arrLocal[i]).update(this, arg); EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Javadoc should state that default implementation delivers notification in reverse order. ACTUAL - Javadoc incorrectly states that default implementation delivers notification in order that they registered interest. FREQUENCY : always
|