[jdom-interest] SAXBuilder and Piccolo

Jason Hunter jhunter at acm.org
Tue Nov 26 10:09:34 PST 2002


Hmm, wouldn't your suggested change be equivalent to
SAXParser.getXMLReader(), which would fail because SAXParser doesn't
have a static getXMLReader() method?  I think we still need to use the
"jaxpParser" returned by "newSAXParser".

But how about this.  Instead of invoking the call on getClass() we
should instead use getClass() and then getSuperclass() to find the
public class, then invoke the method on that.  Thoughts?

-jh-

Martin Schulz wrote:
> 
> After thinking this through, I suggest to replace in
> SAXBuilder.createParser():
> 
>                 Class parserClass = jaxpParser.getClass();
>                 Method getXMLReader =
>                         parserClass.getMethod("getXMLReader", null);
> 
> with the more appropriate:
> 
>                 Method getXMLReader =
> 
> Class.forName("javax.xml.parsers.SAXParser").getMethod("getXMLReader",
> null);
> 
> The reason is that parserClass needlessly refers to the implementing
> class of the SAXParser, whereas non-reflecting
> code such as
>         parser = factory.newSAXParser().getXMLReader();
> would only access the implementing class via the SAXParser interface.
> The implementing class may be unaccessible (as is the case with
> Piccolo).
> 
>         Martin
> 
> -----Original Message-----
> From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]
> On Behalf Of Jason Hunter
> Sent: November 15, 2002 4:24 PM
> To: Martin Schulz
> Cc: jdom-interest at jdom.org; yuval at bluecast.com
> Subject: Re: [jdom-interest] SAXBuilder and Piccolo
> 
> > Shouldn't the inner class JAXPSAXParser be declared public (if I do
> > that, it works for me), and why hasn't this been noted before?
> 
> Seems like it, but it's an internal class to Piccolo, so you may want to
> ask them.  Perhaps they aren't anticipating such usage.
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.385 / Virus Database: 217 - Release Date: 04/09/2002
>



More information about the jdom-interest mailing list