diff options
author | aclement <aclement> | 2005-11-15 17:04:00 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-11-15 17:04:00 +0000 |
commit | fabf1598298cb56705e20b4d6a6d64f5c72798eb (patch) | |
tree | 1b584430bc9d185a77f4f91eb53c44d1e7ed68f4 /loadtime | |
parent | 7860f9718fb7e1656b8b8ef1e8c533c0b260872c (diff) | |
download | aspectj-fabf1598298cb56705e20b4d6a6d64f5c72798eb.tar.gz aspectj-fabf1598298cb56705e20b4d6a6d64f5c72798eb.zip |
fix for pr116255
Diffstat (limited to 'loadtime')
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java b/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java index 3036367b2..931e26d17 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/definition/DocumentParser.java @@ -14,6 +14,7 @@ package org.aspectj.weaver.loadtime.definition; import java.io.InputStream; import java.net.URL; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import org.aspectj.util.LangUtil; @@ -23,6 +24,7 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.helpers.XMLReaderFactory; /** * FIXME AV - doc, concrete aspect @@ -73,13 +75,13 @@ public class DocumentParser extends DefaultHandler { private DocumentParser() { m_definition = new Definition(); } - + public static Definition parse(final URL url) throws Exception { InputStream in = null; try { DocumentParser parser = new DocumentParser(); - XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + XMLReader xmlReader = getXMLReader(); xmlReader.setContentHandler(parser); xmlReader.setErrorHandler(parser); @@ -113,6 +115,21 @@ public class DocumentParser extends DefaultHandler { } } + private static XMLReader getXMLReader() throws SAXException, ParserConfigurationException { + XMLReader xmlReader = null; + + /* Try this first for Java 5 */ + try { + xmlReader = XMLReaderFactory.createXMLReader(); + } + + /* .. and ignore "System property ... not set" and then try this instead */ + catch (SAXException ex) { + xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + } + return xmlReader; + } + public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (publicId.equals(DTD_PUBLIC_ID) || publicId.equals(DTD_PUBLIC_ID_ALIAS)) { InputStream in = DTD_STREAM; |