Patch: FYI: disable XML service files
Gary Benson
gbenson@redhat.com
Mon Mar 12 09:55:00 GMT 2007
Tom Tromey wrote:
> I'm checking this in on the trunk and the RH 4.1 branch.
>
> This removes the XML service files from libgcj.so. This lets us
> override things properly again.
>
> Andrew, I tried your test case from ifoox, but I can only see the
> failure if I back out some of the latest XML bug fixes. However a
> simpler test case shows which thing we're actually loading:
>
> import javax.xml.parsers.*;
> public class q {
> public static void main(String[] args) throws Throwable{
> DocumentBuilderFactory tf = DocumentBuilderFactory.newInstance();
> System.out.println(tf.getClass());
> }
> }
>
> Eg, here's the bug in action:
>
> opsy. gij -Djava.class.path=/usr/share/java/xerces-j2.jar:. q
> class gnu.xml.dom.DomDocumentBuilderFactory
This is actually the correct behaviour: xerces should only be loaded
if it is endorsed, and merely being in the classpath should have no
effect. Check this test case with Sun or IBM java:
import javax.xml.parsers.DocumentBuilderFactory;
public class Test {
public static void main(String[] args) throws Throwable{
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setAttribute("bad_attribute", "hello");
}
}
You can't just print the DocumentBuilderFactory here because Sun and
IBM both use xerces internally, but causing an exception lets you see
the line numbers and figure out where it's loading from:
mambo:[~]$ ibmjava Test
Exception in thread "main" java.lang.IllegalArgumentException: bad_attribute
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)
at Test.main(Test.java:7)
mambo:[~]$ ibmjava -cp /usr/share/java/xerces-j2.jar:. Test
Exception in thread "main" java.lang.IllegalArgumentException: bad_attribute
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)
at Test.main(Test.java:7)
mambo:[~]$ ibmjava -Djava.endorsed.dirs=/var/lib/tomcat5/common/endorsed Test
Exception in thread "main" java.lang.IllegalArgumentException: Property 'bad_attribute' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:112)
at Test.main(Test.java:7)
Just being in the classpath has the same behaviour as not being there
at all. gcj had the correct behaviour before the service files were
removed.
Cheers,
Gary
More information about the Java-patches
mailing list