jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java
changeset 31497 4a6b2e733c0d
parent 25868 686eef1e7a79
child 41432 c4036f85c0c5
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java	Wed Jul 05 20:39:43 2017 +0200
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLDOMWriterImpl.java	Tue Jun 30 12:04:27 2015 +0200
@@ -64,7 +64,6 @@
     private Node currentNode = null;
     private Node node = null;
     private NamespaceSupport namespaceContext = null;
-    private Method  mXmlVersion = null;
     private boolean [] needContextPop = null;
     private StringBuffer stringBuffer = null;
     private int resizeValue = 20;
@@ -83,25 +82,11 @@
             ownerDoc = node.getOwnerDocument();
             currentNode = node;
         }
-        getDLThreeMethods();
         stringBuffer = new StringBuffer();
         needContextPop = new boolean[resizeValue];
         namespaceContext = new NamespaceSupport();
     }
 
-    private void getDLThreeMethods(){
-        try{
-            mXmlVersion =  ownerDoc.getClass().getMethod("setXmlVersion",new Class[] {String.class});
-        }catch(NoSuchMethodException mex){
-            //log these errors at fine level.
-            mXmlVersion = null;
-        }catch(SecurityException se){
-            //log these errors at fine level.
-            mXmlVersion = null;
-        }
-    }
-
-
     /**
      * This method has no effect when called.
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
@@ -557,15 +542,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument() throws XMLStreamException {
-        try{
-            if(mXmlVersion != null){
-                mXmlVersion.invoke(ownerDoc, new Object[] {"1.0"});
-            }
-        }catch(IllegalAccessException iae){
-            throw new XMLStreamException(iae);
-        }catch(InvocationTargetException ite){
-            throw new XMLStreamException(ite);
-        }
+        ownerDoc.setXmlVersion("1.0");
     }
 
     /**
@@ -575,15 +552,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument(String version) throws XMLStreamException {
-        try{
-            if(mXmlVersion != null){
-                mXmlVersion.invoke(ownerDoc, new Object[] {version});
-            }
-        }catch(IllegalAccessException iae){
-            throw new XMLStreamException(iae);
-        }catch(InvocationTargetException ite){
-            throw new XMLStreamException(ite);
-        }
+        ownerDoc.setXmlVersion(version);
     }
 
     /**
@@ -594,15 +563,7 @@
      * @throws javax.xml.stream.XMLStreamException {@inheritDoc}
      */
     public void writeStartDocument(String encoding, String version) throws XMLStreamException {
-        try{
-            if(mXmlVersion != null){
-                mXmlVersion.invoke(ownerDoc, new Object[] {version});
-            }
-        }catch(IllegalAccessException iae){
-            throw new XMLStreamException(iae);
-        }catch(InvocationTargetException ite){
-            throw new XMLStreamException(ite);
-        }
+        ownerDoc.setXmlVersion(version);
         //TODO: What to do with encoding.-Venu
     }