The remove operation fires a DocumentEvent whose getChange() method returns an ElementChange that has incorrect offset information for the children in getChildrenRemoved(). Run the attached testcase. **Expected output: added child from: 0 to: 57 removed child from: 0 to: 5 removed child from: 5 to: 57 **Actual output: added child from: 0 to: 57 removed child from: 0 to: 6 removed child from: 6 to: 57
Created attachment 9894 [details] testcase to demonstrate the bug
Created attachment 9895 [details] A patch that prints some debugging info to show where the bug may exist.
Robert, can you take care of this? In current CVS I get a NPE: roman@moonlight:~/src/test$ cacao TestCase Exception in thread "main" java.lang.NullPointerException at TestCase$1.removeUpdate(TestCase.java:21) at javax.swing.text.AbstractDocument.fireRemoveUpdate(AbstractDocument.java:318) at javax.swing.text.AbstractDocument.removeImpl(AbstractDocument.java:741) at javax.swing.text.AbstractDocument.replaceImpl(AbstractDocument.java:781) at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:774) at javax.swing.text.JTextComponent.setText(JTextComponent.java:1184) at TestCase.main(TestCase.java:37)
First of all: I cannot confirm the original problem. However I changed code in various related classes in the last months and have not seen this PR before. The problem roman describes was introduced by the integration of the DocumenFilter. It turns out that the RI has some funny (aka unspecified) behavior when it comes to whether remove, replace and insertString turn into no-ops because of the values of their parameters. Eg. replace() has no effect when (length == 0 && (text == null || text.length() == 0) but remove will never turn into a no-op. For insertString() it is similar: It does nothing when (text == null || text.length() == 0). Doing nothing means they do not call the DocumentFilter's method and probably not the internal method (which would in a normal situation unconditionally change the document's data). I have a patch ready but would like to work on a comprehensive mauve text first.
Mauve patch is written, classpath patch is committed. Bug is FIXED.
Subject: Bug 24216 CVSROOT: /cvsroot/classpath Module name: classpath Branch: generics-branch Changes by: Mark Wielaard <mark@savannah.gnu.org> 06/05/15 09:45:37 Modified files: . : ChangeLog NEWS README configure.ac gnu/java/awt/java2d: AbstractGraphics2D.java AlphaCompositeContext.java gnu/java/awt/peer: GLightweightPeer.java gnu/java/awt/peer/gtk: GtkImage.java gnu/java/text : StringFormatBuffer.java gnu/xml/dom : DomNode.java java/awt : Component.java java/awt/geom : GeneralPath.java java/awt/image : ColorModel.java java/net : URLClassLoader.java java/nio : ByteBufferImpl.java java/text : DecimalFormat.java java/util : Calendar.java SimpleTimeZone.java java/util/logging: Logger.java java/util/zip : DeflaterEngine.java javax/swing : AbstractButton.java ButtonGroup.java DefaultDesktopManager.java ImageIcon.java JComponent.java JLabel.java JOptionPane.java JTable.java javax/swing/plaf/basic: BasicButtonListener.java BasicInternalFrameUI.java BasicRadioButtonUI.java BasicTableHeaderUI.java BasicTableUI.java BasicTreeUI.java javax/swing/plaf/metal: MetalInternalFrameTitlePane.java MetalLookAndFeel.java OceanTheme.java javax/swing/table: DefaultTableCellRenderer.java DefaultTableModel.java javax/swing/text: AbstractDocument.java javax/swing/tree: DefaultTreeSelectionModel.java native/jni/java-net: javanet.c tools/gnu/classpath/tools/keytool: ExportCmd.java Log message: 2006-05-15 Mark Wielaard <mark@klomp.org> * configure.ac (VERSION): Set to 0.91-generics. 2006-05-15 Mark Wielaard <mark@klomp.org> * NEWS: Add release date and VMClassLoader.getBootPackages() changes. 2006-05-15 Christian Thalinger <twisti@complang.tuwien.ac.at> * README: Added CACAO to list of VMs. 2006-05-14 Mark Wielaard <mark@klomp.org> * native/jni/java-net/javanet.c (_javanet_accept): Don't use C++ comments. 2006-05-14 Chris Burdess <dog@gnu.org> * gnu/xml/dom/DomNode.java: Permit comments and PIs in doctype nodes to be preserved during cloneNode. 2006-05-14 Mark Wielaard <mark@klomp.org> PR 27459 * native/jni/java-net/javanet.c (_javanet_accept): Reset the inherited timeout on socket. 2006-05-14 Lillian Angel <langel@redhat.com> * java/util/SimpleTimeZone.java: Reverted patch. (SimpleTimeZone): Throw exception if startMonth == endMonth. (SimpleTimeZone): Likewise. (checkRule): Rewritten to properly check all values (more efficently). This code is now more stable, at least less buggy than before. Fixed API documentation. (setStartRule): Moved checkRule call to end. (setStartRule): Likewise. (setEndRule): Likewise. (setEndRule): Likewise. 2006-05-14 Audrius Meskauskas <AudriusA@Bioinformatics.org> * javax/swing/tree/DefaultTreeSelectionModel.java (leadRow): Initialise to -1. 2006-05-14 Robert Schuster <robertschuster@fsfe.org> PR classpath/27595 * javax/swing/text/AbstractDocument.java: (insertString): Flipped if-expression and its blocks. (remove): Dito. (replace): Flipped if-expression and its blocks, added note, invoke insertString and remove instead of insertStringImpl and removeImpl. 2006-05-13 Tom Tromey <tromey@redhat.com> * java/nio/ByteBufferImpl.java (compact): Always set position. 2006-05-11 Mark Wielaard <mark@klomp.org> * java/util/logging/Logger.java (global): Initialize inside static PrivilegedAction. 2006-05-11 Mark Wielaard <mark@klomp.org> * java/awt/geom/GeneralPath.java (WIND_EVEN_ODD, WIND_NON_ZERO): Fully qualify PathIterator constants 2006-05-10 Roman Kennke <kennke@aicas.com> PR classpath/27481 * javax/swing/plaf/basic/BasicInternalFrameUI.java (installDefaults): Set background of content pane to null, if no custom color has been installed by the application yet. 2006-05-10 Roman Kennke <kennke@aicas.com> PR classpath/27481 * javax/swing/JRootPane.java (createContentPane): Don't set background to null. 2006-05-09 Robert Schuster <robertschuster@fsfe.org> PR classpath/24216 * javax/swing/text/AbstractDocument.java: (insertString): Added more documentation, added argument check. (remove): Added more documentation. (removeImpl): Added argument check. (replace): Added more documentation, added argument check. 2006-05-08 Lillian Angel <langel@redhat.com> * java/net/URLClassLoader.java (JarURLLoader): Added check to make sure the INDEX.LIST file exists. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27481 * javax/swing/JRootPane.java (createContentPane): Set background of the content pane to null, so that the content pane inherits its background from the root pane. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27480 * javax/swing/ButtonGroup.java (add): Check if new button is selected and if so, deselect other buttons in the group. 2006-05-08 Lillian Angel <langel@redhat.com> PR 27444 * java/net/URLClassLoader.java (JarURLLoader): Added code to go through META-INF/INDEX.LIST file to load all jars listed. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27461 * javax/swing/ImageIcon.java (ImageIcon(URL)): Set description to URL.toString(). 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27482 * javax/swing/JTable.java (IconCellRenderer.getTableCellRendererComponent): Set icon to null when cell value is null. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27484 * javax/swing/DefaultDesktopManager.java (closeFrame): Don't perform default close action on the frame to prevent endless loop. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27485 * javax/swing/table/DefaultTableModel.java (addExtraRows): New helper method. (checkSize): New helper method. (setRowCount): Use addExtraRows helper method. (addColumn): Use addExtraRows helper method. (getColumnName): Check and adjust size if necessary using checkSize(). 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27486 * javax/swing/JTable.java (setValueAt): Allow setting values even when table is editable. 2006-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org> PR classpath/27435: * java/util/zip/DeflaterEngine.java: (deflateFast(boolean,boolean)): Empty buffer when full. 2006-05-07 Sven de Marothy <sven@physto.se> Fixed PR27343 * java/util/Calendar.java (setTimeZone): Force recalculation. 2006-05-07 Sven de Marothy <sven@physto.se> Fixed PR27463 * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java (propertyChange): Handle FRAME_ICON_PROPERTY property. 2006-05-06 Sven de Marothy <sven@physto.se> Fixed PR27454 * gnu/java/awt/peer/gtk/GtkImage: (drawPixels,drawPixelsScaled): Check for zero image sizes. 2006-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org> PR classpath/27311: * gnu/java/text/StringFormatBuffer.java: (toString()): Implemented so we can see the contents. * java/text/DecimalFormat.java: (formatInternal(double,StringFormatBuffer,FieldPosition)): Don't calculate the exponent when the number is 0 or less. Also, use log10 instead of log now it's available. 2006-05-07 Sven de Marothy <sven@physto.se> Fixed PR27455 * gnu/java/awt/peer/GLightweightPeer.java (mouseEntered): Remove. * java/awt/Component.java (processMouseEvent): Do lightweight cursor handling. * javax/swing/plaf/basic/BasicTableHeaderUI.java (endResizing,mouseMoved): Save and reset original cursor, not the default one. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/RasterGraphics.java: New file. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/AbstractGraphics2D.java (fillShape): Determine user space bounds of shape and feed them into the actual rendering pipeline. (rawSetPixel): Made non-abstract for now. Maybe remove later. (rawSetForeground): Likewise. (getDestinationColorModel): Removed. (getDeviceBounds): Made non-abstract. Provide useful default impl. (rawFillShape): Handle paint context. (fillScanline): Implement painting and compositing. (fillShapeAntialias): Handle paint context. (fillScanlineAA): Implemented preliminary antialiasing based on composite context. Not working yet. (fillScanlineAlpha): Removed. (init): Fetch destination raster. (getDestinationRaster): New abstract method. (updateRaster): New backend method. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/AlphaCompositeContext.java (compose): Fixed loops, conditions and logic to make compositing work correctly. 2006-05-05 Roman Kennke <kennke@aicas.com> * java/awt/image/ColorModel.java (getNormalizedComponents): Implemented. 2006-05-05 Roman Kennke <kennke@aicas.com> * javax/swing/plaf/basic/BasicRadioButtonUI.java (paint): Query the button model for it's state, not the button itself. 2006-05-05 Roman Kennke <kennke@aicas.com> * javax/swing/JTable.java (tableChanged): Sync selection model with table model changes. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/plaf/basic/BasicButtonListener.java (mouseEntered): Fixed conditions for changing states. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JOptionPane.java (AccessibleJOptionPane.getAccessibleRole): Implemented method. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JLabel.java (AccessibleJLabel.getSelectedText): Return null instead of "". (AccessibleJLabel.getSelectionStart): Added comment why return -1 is correct here. (AccessibleJLabel.getSelectionEnd): Added comment why return -1 is correct here. (AccessibleJLabel.getCharacterAttribute): Added comment about what to do here. (AccessibleJLabel.getCharCount): Added comment about what to do here. (AccessibleJLabel.getCharacterBounds): Tagged as not implemented. (AccessibleJLabel.getIndexAtPoint): Tagged as not implemented. (paramString): Return super.paramString() here, this provides a more meaningful output. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JComponent.java (paint): Added null check to avoid NPE when clip == null. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/AbstractButton.java (addImpl): New method. Installs an OverlayLayout if no other layout has been installed before. (setLayout): New method. Detect if a client app installs a custom layout. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/table/DefaultTableCellModel.java (noFocusBorder): Fixed width of empty border to 1. (getTableCellRendererComponent): Don't change the colors for focuses cells. Fixed border for focused cells. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JTable.java (moveToCellBeingEdited): Adjust bounding box of editing component to exactly cover the grid. * javax/swing/plaf/basic/BasicTableUI.java (paint): Paint grid to the bottom and right of the cells instead of left and top. Adjust bounding box of cells accordingly. * javax/swing/plaf/metal/MetalLookAndFeel.java (initComponentDefaults): Fixed color of JTable selection border. * javax/swing/plaf/metal/OceanTheme.java (addCustomEntriesToTable): Fixed color of JTable selection border. 2006-05-04 Raif S. Naffah <raif@swiftdsl.com.au> * tools/gnu/classpath/tools/keytool/ExportCmd.java (setup): Use _alias instead of alias. 2006-05-04 Lillian Angel <langel@redhat.com> * javax/swing/JLabel.java (JLabel): Pass in an empty string for the text parameter. (JLabel): Likewise. (JLabel): Likewise. 2006-05-05 Audrius Meskauskas <AudriusA@Bioinformatics.org> * javax/swing/plaf/basic/BasicTreeUI.java (paint): Return early if there are no visible nodes to paint. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branch&tr1=1.2386.2.254&tr2=1.2386.2.255&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/NEWS.diff?only_with_tag=generics-branch&tr1=1.47.2.24&tr2=1.47.2.25&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/README.diff?only_with_tag=generics-branch&tr1=1.16.2.1&tr2=1.16.2.2&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/configure.ac.diff?only_with_tag=generics-branch&tr1=1.43.2.32&tr2=1.43.2.33&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java.diff?only_with_tag=generics-branch&tr1=1.3.2.2&tr2=1.3.2.3&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/java/awt/java2d/AlphaCompositeContext.java.diff?only_with_tag=generics-branch&tr1=1.1.4.1&tr2=1.1.4.2&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/java/awt/peer/GLightweightPeer.java.diff?only_with_tag=generics-branch&tr1=1.3.2.5&tr2=1.3.2.6&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/java/awt/peer/gtk/GtkImage.java.diff?only_with_tag=generics-branch&tr1=1.12.2.8&tr2=1.12.2.9&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/java/text/StringFormatBuffer.java.diff?only_with_tag=generics-branch&tr1=1.1.2.1&tr2=1.1.2.2&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/xml/dom/DomNode.java.diff?only_with_tag=generics-branch&tr1=1.1.2.8&tr2=1.1.2.9&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/awt/Component.java.diff?only_with_tag=generics-branch&tr1=1.38.2.25&tr2=1.38.2.26&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/awt/geom/GeneralPath.java.diff?only_with_tag=generics-branch&tr1=1.7.2.6&tr2=1.7.2.7&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/awt/image/ColorModel.java.diff?only_with_tag=generics-branch&tr1=1.19.2.6&tr2=1.19.2.7&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/net/URLClassLoader.java.diff?only_with_tag=generics-branch&tr1=1.21.2.13&tr2=1.21.2.14&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/nio/ByteBufferImpl.java.diff?only_with_tag=generics-branch&tr1=1.7.2.5&tr2=1.7.2.6&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/text/DecimalFormat.java.diff?only_with_tag=generics-branch&tr1=1.16.2.7&tr2=1.16.2.8&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/util/Calendar.java.diff?only_with_tag=generics-branch&tr1=1.25.2.17&tr2=1.25.2.18&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/util/SimpleTimeZone.java.diff?only_with_tag=generics-branch&tr1=1.18.2.9&tr2=1.18.2.10&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/util/logging/Logger.java.diff?only_with_tag=generics-branch&tr1=1.6.2.4&tr2=1.6.2.5&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/util/zip/DeflaterEngine.java.diff?only_with_tag=generics-branch&tr1=1.6.2.3&tr2=1.6.2.4&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/AbstractButton.java.diff?only_with_tag=generics-branch&tr1=1.17.2.15&tr2=1.17.2.16&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/ButtonGroup.java.diff?only_with_tag=generics-branch&tr1=1.6.2.4&tr2=1.6.2.5&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/DefaultDesktopManager.java.diff?only_with_tag=generics-branch&tr1=1.6.2.6&tr2=1.6.2.7&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/ImageIcon.java.diff?only_with_tag=generics-branch&tr1=1.9.2.11&tr2=1.9.2.12&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/JComponent.java.diff?only_with_tag=generics-branch&tr1=1.20.2.25&tr2=1.20.2.26&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/JLabel.java.diff?only_with_tag=generics-branch&tr1=1.12.2.8&tr2=1.12.2.9&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/JOptionPane.java.diff?only_with_tag=generics-branch&tr1=1.11.2.7&tr2=1.11.2.8&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/JTable.java.diff?only_with_tag=generics-branch&tr1=1.9.2.23&tr2=1.9.2.24&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicButtonListener.java.diff?only_with_tag=generics-branch&tr1=1.4.2.5&tr2=1.4.2.6&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java.diff?only_with_tag=generics-branch&tr1=1.4.2.11&tr2=1.4.2.12&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java.diff?only_with_tag=generics-branch&tr1=1.6.2.4&tr2=1.6.2.5&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java.diff?only_with_tag=generics-branch&tr1=1.6.2.10&tr2=1.6.2.11&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java.diff?only_with_tag=generics-branch&tr1=1.5.2.15&tr2=1.5.2.16&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java.diff?only_with_tag=generics-branch&tr1=1.6.2.15&tr2=1.6.2.16&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java.diff?only_with_tag=generics-branch&tr1=1.1.2.5&tr2=1.1.2.6&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java.diff?only_with_tag=generics-branch&tr1=1.6.2.15&tr2=1.6.2.16&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/plaf/metal/OceanTheme.java.diff?only_with_tag=generics-branch&tr1=1.2.2.4&tr2=1.2.2.5&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/table/DefaultTableCellRenderer.java.diff?only_with_tag=generics-branch&tr1=1.7.2.10&tr2=1.7.2.11&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/table/DefaultTableModel.java.diff?only_with_tag=generics-branch&tr1=1.5.2.5&tr2=1.5.2.6&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/AbstractDocument.java.diff?only_with_tag=generics-branch&tr1=1.9.2.19&tr2=1.9.2.20&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/tree/DefaultTreeSelectionModel.java.diff?only_with_tag=generics-branch&tr1=1.3.2.10&tr2=1.3.2.11&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/native/jni/java-net/javanet.c.diff?only_with_tag=generics-branch&tr1=1.18.2.8&tr2=1.18.2.9&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java.diff?only_with_tag=generics-branch&tr1=1.1.4.1&tr2=1.1.4.2&r1=text&r2=text