I get a NPE parsing certain plugin.xml files from Eclipse with libgcj from FC-6: % java PluginXMLHandler org.xml.sax.SAXParseException at gnu.xml.stream.SAXParser.parse(libgcj.so.7rh) at javax.xml.parsers.SAXParser.parse(libgcj.so.7rh) at javax.xml.parsers.SAXParser.parse(libgcj.so.7rh) at PluginXMLHandler.main(PluginXMLHandler.java:31) Caused by: java.lang.NullPointerException at gnu.xml.dom.DomNode.dispatchEvent(libgcj.so.7rh) at gnu.xml.dom.DomAttr.mutating(libgcj.so.7rh) at gnu.xml.dom.DomAttr.setNodeValue(libgcj.so.7rh) at gnu.xml.dom.DomElement.setAttribute(libgcj.so.7rh) at PluginXMLHandler.startElement(PluginXMLHandler.java:44) at gnu.xml.stream.SAXParser.parse(libgcj.so.7rh) ...3 more % I do not get this NPE with Sun's VM: % jdk1.5.0_09/bin/java PluginXMLHandler % I believe this is a problem with Classpath HEAD as well. I will attach a test xml file and small parsing app.
Created attachment 12625 [details] sample plugin.xml file from Eclipse
Created attachment 12626 [details] small test app that causes NPE
Created attachment 12634 [details] patch to fix NPE and add small optimization to mutation event propagation I think this patch should fix the problem. The change to DomNode.java fixes the actual NPE and the change to DomAttr.java are a mini optimization (don't report a mutation if the oldValue and the newValue are the same value). I'm not sure if the optimization is a good idea because it will throw a NPE if newValue is null. Chris, it would be cool if you could check this over when you have a chance - I'd like to know if these solutions are going to work. Thanks. I will be putting a workaround in Fedora's Eclipse packages so that the PDE will work with GCJ until this is fixed.
Ben, this patch looks good but for the potential NPE you describe. Instead of "newValue.equals(oldValue)" please use "equal(newValue, oldValue)" (defined in DomNode) and commit.
Created attachment 12756 [details] updated patch I don't have commit access to Classpath so feel free to commit this. I updated the patch with your suggestion and included a ChangeLog entry. Thanks.
Subject: Bug 29853 CVSROOT: /cvsroot/classpath Module name: classpath Changes by: Chris Burdess <dog> 06/12/06 18:38:06 Modified files: . : ChangeLog gnu/xml/dom : DomAttr.java DomNode.java Log message: 2006-12-06 Ben Konrath <bkonrath@redhat.com> Fixes PR 29853. * gnu/xml/dom/DomAttr.java: Don't report mutation if oldValue and newValue are the same. * gnu/xml/dom/DomNode.java: Set parent if null during mutation. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.8931&r2=1.8932 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomAttr.java?cvsroot=classpath&r1=1.3&r2=1.4 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomNode.java?cvsroot=classpath&r1=1.16&r2=1.17
Patch committed.
Thanks Chris.
Subject: Bug 29853 CVSROOT: /cvsroot/classpath Module name: classpath Branch: generics-branch Changes by: Mark Wielaard <mark> 06/12/08 10:30:10 Modified files: . : ChangeLog gnu/xml/dom : DomAttr.java DomNode.java gnu/xml/stream : SAXParser.java XMLStreamWriterImpl.java javax/xml/parsers: DocumentBuilderFactory.java javax/xml/validation: SchemaFactory.java Log message: 2006-12-06 Ben Konrath <bkonrath@redhat.com> Fixes PR 29853. * gnu/xml/dom/DomAttr.java: Don't report mutation if oldValue and newValue are the same. * gnu/xml/dom/DomNode.java: Set parent if null during mutation. 2006-12-06 Chris Burdess <dog@gnu.org> Fixes PR 29272. * javax/xml/parsers/DocumentBuilderFactory.java: Fix broken Javadoc. * gnu/xml/stream/SAXParser.java: Fix file descriptor leak. 2006-12-06 Chris Burdess <dog@gnu.org> Fixes PR 29264. * gnu/xml/stream/XMLStreamWriterImpl.java: Allow arbitrary text in writeDTD method. 2006-12-056 Chris Burdess <dog@gnu.org> Fixes PR 28816. * javax/xml/validation/SchemaFactory.java: Use correct algorithm to discover schema factory implementation class. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&only_with_tag=generics-branch&r1=1.2386.2.358&r2=1.2386.2.359 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomAttr.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.3&r2=1.1.2.4 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomNode.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.10&r2=1.1.2.11 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/SAXParser.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.14.2.4&r2=1.14.2.5 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/XMLStreamWriterImpl.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.4&r2=1.1.2.5 http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/parsers/DocumentBuilderFactory.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.5&r2=1.1.2.6 http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/validation/SchemaFactory.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.5&r2=1.1.2.6
Subject: Bug 29853 CVSROOT: /cvsroot/classpath Module name: classpath Branch: classpath-0_93-branch Changes by: Mark Wielaard <mark> 06/12/08 10:31:50 Modified files: . : ChangeLog gnu/xml/dom : DomAttr.java DomNode.java gnu/xml/stream : SAXParser.java XMLStreamWriterImpl.java javax/xml/parsers: DocumentBuilderFactory.java javax/xml/validation: SchemaFactory.java Log message: 2006-12-06 Ben Konrath <bkonrath@redhat.com> Fixes PR 29853. * gnu/xml/dom/DomAttr.java: Don't report mutation if oldValue and newValue are the same. * gnu/xml/dom/DomNode.java: Set parent if null during mutation. 2006-12-06 Chris Burdess <dog@gnu.org> Fixes PR 29272. * javax/xml/parsers/DocumentBuilderFactory.java: Fix broken Javadoc. * gnu/xml/stream/SAXParser.java: Fix file descriptor leak. 2006-12-06 Chris Burdess <dog@gnu.org> Fixes PR 29264. * gnu/xml/stream/XMLStreamWriterImpl.java: Allow arbitrary text in writeDTD method. 2006-12-056 Chris Burdess <dog@gnu.org> Fixes PR 28816. * javax/xml/validation/SchemaFactory.java: Use correct algorithm to discover schema factory implementation class. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.8897.2.14&r2=1.8897.2.15 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomAttr.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.3&r2=1.3.12.1 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/dom/DomNode.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.16&r2=1.16.2.1 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/SAXParser.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.21&r2=1.21.4.1 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/xml/stream/XMLStreamWriterImpl.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.5&r2=1.5.12.1 http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/parsers/DocumentBuilderFactory.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.5&r2=1.5.10.1 http://cvs.savannah.gnu.org/viewcvs/classpath/javax/xml/validation/SchemaFactory.java?cvsroot=classpath&only_with_tag=classpath-0_93-branch&r1=1.5&r2=1.5.6.1