Rickard �berg wrote:
R�> Hey

R�> Aaron Mulder wrote:
>>         Download the JMX RI, and look at the source code for
>> com/sun/management/jmx/Introspector.java and in particular the for loop
>> that begins on line 386 and ends on line 397.  This is where it generates
>> the attribute list (by combining entries for getters and setters).
>>         The logic here looks very sketchy to me - here's my pseudocode:
>> 
>> for(i=0; i<vector.size(); i++) {
>>     ...
>>     if(readable and writeable) {
>>         vector.removeElementAt(i);
>>     }
>> }
>> 
>>         To me, it looks like that will skip element i+1: when you remove
>> i, then i+1 becomes i, then you loop and increment to the new i+1 which
>> used to be i+2...
>>         Now, if i+1 happened to be setURL, it may get skipped, and bad
>> things could happen.

R�> Wow... they actually do that?! What a newbie bug *sigh*... yeah, that
R�> definitely is wrong. The right thing to do is make a copy and remove.

Or:

for(i = vector.size() - 1; i >= 0; i--) {
     ...
     if(readable and writeable) {
         vector.removeElementAt(i);
     }
}

;-)

Best regards,
 Oleg 



Reply via email to