public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: java-patches@gcc.gnu.org
Subject: Re: Patch: FYI: disable XML service files
Date: Mon, 12 Mar 2007 09:55:00 -0000	[thread overview]
Message-ID: <20070312095509.GA4060@redhat.com> (raw)
In-Reply-To: <m37itq9j4m.fsf@localhost.localdomain>

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

  parent reply	other threads:[~2007-03-12  9:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-09 22:09 Tom Tromey
2007-03-10  6:39 ` Andrew Haley
2007-03-10 18:34   ` Tom Tromey
2007-03-12  9:55 ` Gary Benson [this message]
2007-03-12 13:06   ` Andrew Haley
2007-03-12 15:44     ` Gary Benson
2007-03-12 15:51       ` Andrew Haley
2007-03-12 16:50         ` Gary Benson
2007-03-12 17:08           ` Andrew Haley
2007-03-13 10:07             ` Gary Benson
2007-03-12 18:05   ` Tom Tromey
2007-03-13 10:01     ` Gary Benson
2007-03-13 18:53       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070312095509.GA4060@redhat.com \
    --to=gbenson@redhat.com \
    --cc=java-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).