Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : A DESCRIPTION OF THE PROBLEM : at last of method initBean(Class type, Object oldInstance, Object newInstance, Encoder out): line 316: String removeListenerMethodName = d.getRemoveListenerMethod().getName(); for (int i = oldL.length; i < newL.length; i++) { invokeStatement(oldInstance, removeListenerMethodName, new Object[]{oldL[i]}, out); // the upper line should be invokeStatement(oldInstance, removeListenerMethodName, new Object[]{newL[i]}, out); } It is obvious that if the for loop is executed, you are trying to access "oldL" with an illegal index because i >= oldL.length. I think this may be a clerical error and "newL" should be used inside the for loop. The exception will be thrown when we remove some default listeners from an instance. In one word, if oldL.length < newL.length, an ArrayIndexOutOfBoundsException will be thrown. REPRODUCIBILITY : This bug can be reproduced occasionally. ------------- begin ---------------- /* * Test.java * * Created on June 15, 2007, 2:41 PM * */ import java.awt.BorderLayout; import java.beans.ExceptionListener; import java.beans.XMLEncoder; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.plaf.basic.BasicLabelUI; public class Test { /** Creates a new instance of Test */ public Test() { JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel(""); //the following line is ugly and useless //but I have to do something to detonate the bomb label.removePropertyChangeListener((BasicLabelUI)label.getUI()); panel.add(label); ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(out); encoder.setExceptionListener(new ExceptionListener() { public void exceptionThrown(Exception e) { e.printStackTrace(); System.err.println("Continuing ..."); } }); encoder.writeObject(panel); encoder.flush(); encoder.close(); String xml; try { xml = new String(out.toByteArray(), "UTF-8"); System.out.println(xml); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } } public static void main(String[] args) { Test app = new Test(); } } ------------- end ----------------
|