Merge jdk8u141-b31

Mon, 26 Jun 2017 22:32:29 -0700

author
asaha
date
Mon, 26 Jun 2017 22:32:29 -0700
changeset 1493
c5788159081f
parent 1489
0d15e803ead1
parent 1492
1bd59b39f9af
child 1494
b0b07a36bfac
child 1501
60c9c1e269dc

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Mon Jun 26 22:23:05 2017 -0700
     1.2 +++ b/.hgtags	Mon Jun 26 22:32:29 2017 -0700
     1.3 @@ -696,6 +696,8 @@
     1.4  7817f0d2519573e42405ef96a7c7ff1d768f92ec jdk8u131-b11
     1.5  a432391b6d676847cf83ddacc1d6e42fc6435ac4 jdk8u131-b31
     1.6  cede0cc0bbe9641d70171e062d6b1ed9e52f2ebb jdk8u131-b32
     1.7 +46788dc162ad09e11da8c4368d3371b06fb7ec63 jdk8u131-b33
     1.8 +d5c5a205d7fb0a0b906d23e4aaf9dcdbb9ecfe7c jdk8u131-b34
     1.9  74aa403ef03d56469e9364cc45c2ec18c6e50e33 jdk8u141-b00
    1.10  b1138396b99b1f8ebdb7d28c7143c96eb5b4f991 jdk8u141-b01
    1.11  a7b9281956f9616eab0498386b9605853db7b408 jdk8u141-b02
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/NoEscapeHandler.java	Mon Jun 26 22:32:29 2017 -0700
     2.3 @@ -0,0 +1,45 @@
     2.4 +/*
     2.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.  Oracle designates this
    2.11 + * particular file as subject to the "Classpath" exception as provided
    2.12 + * by Oracle in the LICENSE file that accompanied this code.
    2.13 + *
    2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.17 + * version 2 for more details (a copy is included in the LICENSE file that
    2.18 + * accompanied this code).
    2.19 + *
    2.20 + * You should have received a copy of the GNU General Public License version
    2.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.23 + *
    2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.25 + * or visit www.oracle.com if you need additional information or have any
    2.26 + * questions.
    2.27 + */
    2.28 +
    2.29 +package com.sun.xml.internal.bind.marshaller;
    2.30 +
    2.31 +import java.io.IOException;
    2.32 +import java.io.Writer;
    2.33 +
    2.34 +/**
    2.35 + * Performs no character escaping.
    2.36 + *
    2.37 + * @author
    2.38 + *     Roman Grigoriadi (roman.grigoriadi@oracle.com)
    2.39 + */
    2.40 +public class NoEscapeHandler implements CharacterEscapeHandler {
    2.41 +
    2.42 +    public static final NoEscapeHandler theInstance = new NoEscapeHandler();
    2.43 +
    2.44 +    @Override
    2.45 +    public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException {
    2.46 +        out.write(ch, start, length);
    2.47 +    }
    2.48 +}
     3.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeImpl.java	Mon Jun 26 22:23:05 2017 -0700
     3.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeImpl.java	Mon Jun 26 22:32:29 2017 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -76,7 +76,7 @@
    3.11  
    3.12      public void marshal(Marshaller _m, T t, XMLStreamWriter output) throws JAXBException {
    3.13          MarshallerImpl m = (MarshallerImpl)_m;
    3.14 -        m.write(tagName,bi,t,XMLStreamWriterOutput.create(output,context),new StAXPostInitAction(output,m.serializer));
    3.15 +        m.write(tagName,bi,t,XMLStreamWriterOutput.create(output,context, m.getEscapeHandler()),new StAXPostInitAction(output,m.serializer));
    3.16      }
    3.17  
    3.18      public void marshal(Marshaller _m, T t, OutputStream output, NamespaceContext nsContext) throws JAXBException {
     4.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/MarshallerImpl.java	Mon Jun 26 22:23:05 2017 -0700
     4.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/MarshallerImpl.java	Mon Jun 26 22:32:29 2017 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -160,7 +160,7 @@
    4.11  
    4.12      @Override
    4.13      public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException {
    4.14 -        write(obj, XMLStreamWriterOutput.create(writer,context), new StAXPostInitAction(writer,serializer));
    4.15 +        write(obj, XMLStreamWriterOutput.create(writer,context, escapeHandler), new StAXPostInitAction(writer,serializer));
    4.16      }
    4.17  
    4.18      @Override
    4.19 @@ -364,6 +364,15 @@
    4.20      }
    4.21  
    4.22  
    4.23 +    /**
    4.24 +     * Returns escape handler provided with JAXB context parameters.
    4.25 +     *
    4.26 +     * @return escape handler
    4.27 +     */
    4.28 +    CharacterEscapeHandler getEscapeHandler() {
    4.29 +        return escapeHandler;
    4.30 +    }
    4.31 +
    4.32      //
    4.33      //
    4.34      // create XMLWriter by specifing various type of output.
     5.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/FastInfosetStreamWriterOutput.java	Mon Jun 26 22:23:05 2017 -0700
     5.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/FastInfosetStreamWriterOutput.java	Mon Jun 26 22:32:29 2017 -0700
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -25,6 +25,7 @@
    5.11  
    5.12  package com.sun.xml.internal.bind.v2.runtime.output;
    5.13  
    5.14 +import com.sun.xml.internal.bind.marshaller.NoEscapeHandler;
    5.15  import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
    5.16  import com.sun.xml.internal.bind.v2.runtime.Name;
    5.17  import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
    5.18 @@ -220,7 +221,7 @@
    5.19  
    5.20      public FastInfosetStreamWriterOutput(StAXDocumentSerializer out,
    5.21              JAXBContextImpl context) {
    5.22 -        super(out);
    5.23 +        super(out, NoEscapeHandler.theInstance);
    5.24  
    5.25          this.fiout = out;
    5.26          this.localNames = context.getUTF8NameTable();
     6.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/StAXExStreamWriterOutput.java	Mon Jun 26 22:23:05 2017 -0700
     6.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/StAXExStreamWriterOutput.java	Mon Jun 26 22:32:29 2017 -0700
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -27,6 +27,7 @@
    6.11  
    6.12  import javax.xml.stream.XMLStreamException;
    6.13  
    6.14 +import com.sun.xml.internal.bind.marshaller.NoEscapeHandler;
    6.15  import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data;
    6.16  
    6.17  import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx;
    6.18 @@ -40,7 +41,7 @@
    6.19      private final XMLStreamWriterEx out;
    6.20  
    6.21      public StAXExStreamWriterOutput(XMLStreamWriterEx out) {
    6.22 -        super(out);
    6.23 +        super(out, NoEscapeHandler.theInstance);
    6.24          this.out = out;
    6.25      }
    6.26  
     7.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java	Mon Jun 26 22:23:05 2017 -0700
     7.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java	Mon Jun 26 22:32:29 2017 -0700
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -26,15 +26,16 @@
    7.11  package com.sun.xml.internal.bind.v2.runtime.output;
    7.12  
    7.13  import java.io.IOException;
    7.14 +import java.io.Writer;
    7.15  import java.lang.reflect.Constructor;
    7.16  
    7.17  import javax.xml.stream.XMLStreamException;
    7.18  import javax.xml.stream.XMLStreamWriter;
    7.19  
    7.20 +import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;
    7.21  import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
    7.22  import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
    7.23  
    7.24 -import com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl;
    7.25  import org.xml.sax.SAXException;
    7.26  
    7.27  /**
    7.28 @@ -53,7 +54,7 @@
    7.29       * Creates a new {@link XmlOutput} from a {@link XMLStreamWriter}.
    7.30       * This method recognizes an FI StAX writer.
    7.31       */
    7.32 -    public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context) {
    7.33 +    public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context, CharacterEscapeHandler escapeHandler) {
    7.34          // try optimized path
    7.35          final Class writerClass = out.getClass();
    7.36          if (writerClass==FI_STAX_WRITER_CLASS) {
    7.37 @@ -69,17 +70,26 @@
    7.38              }
    7.39          }
    7.40  
    7.41 +        CharacterEscapeHandler xmlStreamEscapeHandler = escapeHandler != null ?
    7.42 +                escapeHandler : NewLineEscapeHandler.theInstance;
    7.43 +
    7.44          // otherwise the normal writer.
    7.45 -        return new XMLStreamWriterOutput(out);
    7.46 +        return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler);
    7.47      }
    7.48  
    7.49  
    7.50      private final XMLStreamWriter out;
    7.51  
    7.52 +    private final CharacterEscapeHandler escapeHandler;
    7.53 +
    7.54 +    private final XmlStreamOutWriterAdapter writerWrapper;
    7.55 +
    7.56      protected final char[] buf = new char[256];
    7.57  
    7.58 -    protected XMLStreamWriterOutput(XMLStreamWriter out) {
    7.59 +    protected XMLStreamWriterOutput(XMLStreamWriter out, CharacterEscapeHandler escapeHandler) {
    7.60          this.out = out;
    7.61 +        this.escapeHandler = escapeHandler;
    7.62 +        this.writerWrapper = new XmlStreamOutWriterAdapter(out);
    7.63      }
    7.64  
    7.65      // not called if we are generating fragments
    7.66 @@ -137,7 +147,7 @@
    7.67      public void text(String value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException {
    7.68          if(needsSeparatingWhitespace)
    7.69              out.writeCharacters(" ");
    7.70 -        out.writeCharacters(value);
    7.71 +        escapeHandler.escape(value.toCharArray(), 0, value.length(), false, writerWrapper);
    7.72      }
    7.73  
    7.74      public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException {
    7.75 @@ -207,4 +217,82 @@
    7.76          }
    7.77      }
    7.78  
    7.79 +
    7.80 +    /**
    7.81 +     * Performs character escaping only for new lines.
    7.82 +     */
    7.83 +    private static class NewLineEscapeHandler implements CharacterEscapeHandler {
    7.84 +
    7.85 +        public static final NewLineEscapeHandler theInstance = new NewLineEscapeHandler();
    7.86 +
    7.87 +        @Override
    7.88 +        public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException {
    7.89 +            int limit = start+length;
    7.90 +            int lastEscaped = start;
    7.91 +
    7.92 +            for (int i = start; i < limit; i++) {
    7.93 +                char c = ch[i];
    7.94 +                if (c == '\r' || c == '\n') {
    7.95 +                    if (i != lastEscaped) {
    7.96 +                        out.write(ch, lastEscaped, i - lastEscaped);
    7.97 +                    }
    7.98 +                    lastEscaped = i + 1;
    7.99 +                    if (out instanceof XmlStreamOutWriterAdapter) {
   7.100 +                        try {
   7.101 +                            ((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c));
   7.102 +                        } catch (XMLStreamException e) {
   7.103 +                            throw new IOException("Error writing xml stream", e);
   7.104 +                        }
   7.105 +                    } else {
   7.106 +                        out.write("&#x");
   7.107 +                        out.write(Integer.toHexString(c));
   7.108 +                        out.write(';');
   7.109 +                    }
   7.110 +                }
   7.111 +            }
   7.112 +            if (lastEscaped != limit) {
   7.113 +                out.write(ch, lastEscaped, length - lastEscaped);
   7.114 +            }
   7.115 +        }
   7.116 +    }
   7.117 +
   7.118 +    private static final class XmlStreamOutWriterAdapter extends Writer {
   7.119 +
   7.120 +        private final XMLStreamWriter writer;
   7.121 +
   7.122 +        private XmlStreamOutWriterAdapter(XMLStreamWriter writer) {
   7.123 +            this.writer = writer;
   7.124 +        }
   7.125 +
   7.126 +        @Override
   7.127 +        public void write(char[] cbuf, int off, int len) throws IOException {
   7.128 +            try {
   7.129 +                writer.writeCharacters(cbuf, off, len);
   7.130 +            } catch (XMLStreamException e) {
   7.131 +                throw new IOException("Error writing XML stream", e);
   7.132 +            }
   7.133 +        }
   7.134 +
   7.135 +        public void writeEntityRef(String entityReference) throws XMLStreamException {
   7.136 +            writer.writeEntityRef(entityReference);
   7.137 +        }
   7.138 +
   7.139 +        @Override
   7.140 +        public void flush() throws IOException {
   7.141 +            try {
   7.142 +                writer.flush();
   7.143 +            } catch (XMLStreamException e) {
   7.144 +                throw new IOException("Error flushing XML stream", e);
   7.145 +            }
   7.146 +        }
   7.147 +
   7.148 +        @Override
   7.149 +        public void close() throws IOException {
   7.150 +            try {
   7.151 +                writer.close();
   7.152 +            } catch (XMLStreamException e) {
   7.153 +                throw new IOException("Error closing XML stream", e);
   7.154 +            }
   7.155 +        }
   7.156 +    }
   7.157  }

mercurial