You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/05/28 17:10:41 UTC

svn commit: r1890295 [1/2] - in /xmlbeans: site/src/documentation/content/xdocs/ trunk/src/main/java/org/apache/xmlbeans/impl/schema/ trunk/src/main/java/org/apache/xmlbeans/impl/tool/ trunk/src/main/java/org/apache/xmlbeans/impl/util/ trunk/src/main/j...

Author: kiwiwings
Date: Fri May 28 17:10:41 2021
New Revision: 1890295

URL: http://svn.apache.org/viewvc?rev=1890295&view=rev
Log:
XMLBEANS-235 - Support annotations > 64kb

Added:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataInputStream.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataOutputStream.java
    xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java
    xmlbeans/trunk/src/test/resources/xbean/compile/scomp/largeAnnotation/
    xmlbeans/trunk/src/test/resources/xbean/compile/scomp/largeAnnotation/largeAnnotation.xsd
Modified:
    xmlbeans/site/src/documentation/content/xdocs/status.xml
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XsbDumper.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java

Modified: xmlbeans/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/xmlbeans/site/src/documentation/content/xdocs/status.xml?rev=1890295&r1=1890294&r2=1890295&view=diff
==============================================================================
--- xmlbeans/site/src/documentation/content/xdocs/status.xml (original)
+++ xmlbeans/site/src/documentation/content/xdocs/status.xml Fri May 28 17:10:41 2021
@@ -52,6 +52,7 @@
             <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-565">Generate TypeSystemHolder as .java (in sources) instead of .class (in resources)</action>
             <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-214">Support the 2009 version of xml.xsd</action>
             <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-563">maven plugin does not have feature parity with codehaus maven plugin or allow all configuration options</action>
+            <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-235">Support annotations &gt; 64kb</action>
         </actions>
     </release>
 

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?rev=1890295&r1=1890294&r2=1890295&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java Fri May 28 17:10:41 2021
@@ -21,6 +21,8 @@ import org.apache.xmlbeans.impl.common.Q
 import org.apache.xmlbeans.impl.common.XBeanDebug;
 import org.apache.xmlbeans.impl.util.FilerImpl;
 import org.apache.xmlbeans.impl.util.HexBin;
+import org.apache.xmlbeans.impl.util.LongUTFDataInputStream;
+import org.apache.xmlbeans.impl.util.LongUTFDataOutputStream;
 import org.apache.xmlbeans.impl.values.XmlObjectBase;
 import org.apache.xmlbeans.impl.xb.xsdschema.AttributeGroupDocument;
 import org.apache.xmlbeans.impl.xb.xsdschema.GroupDocument;
@@ -512,7 +514,7 @@ public class SchemaTypeSystemImpl extend
         if (_random == null) {
             try {
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                DataOutputStream daos = new DataOutputStream(baos);
+                LongUTFDataOutputStream daos = new LongUTFDataOutputStream(baos);
 
                 // at least 10 bits of unqieueness, right?  Maybe even 50 or 60.
                 daos.writeInt(System.identityHashCode(SchemaTypeSystemImpl.class));
@@ -640,7 +642,7 @@ public class SchemaTypeSystemImpl extend
             return intsToStrings.get(code);
         }
 
-        void writeTo(DataOutputStream output) {
+        void writeTo(LongUTFDataOutputStream output) {
             if (intsToStrings.size() >= MAX_UNSIGNED_SHORT) {
                 throw new SchemaTypeLoaderException("Too many strings (" + intsToStrings.size() + ")", _name, _handle, SchemaTypeLoaderException.INT_TOO_LARGE);
             }
@@ -650,7 +652,7 @@ public class SchemaTypeSystemImpl extend
                 boolean isNext = false;
                 for (String str : intsToStrings) {
                     if (isNext) {
-                        output.writeUTF(str);
+                        output.writeLongUTF(str);
                     }
                     isNext = true;
                 }
@@ -659,7 +661,7 @@ public class SchemaTypeSystemImpl extend
             }
         }
 
-        void readFrom(DataInputStream input) {
+        void readFrom(LongUTFDataInputStream input) {
             if (intsToStrings.size() != 1 || stringsToInts.size() != 0) {
                 throw new IllegalStateException();
             }
@@ -667,7 +669,7 @@ public class SchemaTypeSystemImpl extend
             try {
                 int size = input.readUnsignedShort();
                 for (int i = 1; i < size; i++) {
-                    String str = input.readUTF().intern();
+                    String str = input.readLongUTF().intern();
                     int code = codeForString(str);
                     if (code != i) {
                         throw new IllegalStateException();
@@ -1069,7 +1071,7 @@ public class SchemaTypeSystemImpl extend
     }
 
     public static String crackPointer(InputStream stream) {
-        try (DataInputStream input = new DataInputStream(stream)) {
+        try (LongUTFDataInputStream input = new LongUTFDataInputStream(stream)) {
 
             int magic = input.readInt();
             if (magic != DATA_BABE) {
@@ -1106,8 +1108,8 @@ public class SchemaTypeSystemImpl extend
     }
 
     private class XsbReader {
-        DataInputStream _input;
-        DataOutputStream _output;
+        LongUTFDataInputStream _input;
+        LongUTFDataOutputStream _output;
         StringPool _stringPool;
         String _handle;
         private int _majorver;
@@ -1122,7 +1124,7 @@ public class SchemaTypeSystemImpl extend
                 throw new SchemaTypeLoaderException("XML-BEANS compiled schema: Could not locate compiled schema resource " + resourcename, _name, handle, SchemaTypeLoaderException.NO_RESOURCE);
             }
 
-            _input = new DataInputStream(rawinput);
+            _input = new LongUTFDataInputStream(rawinput);
             _handle = handle;
 
             int magic = readInt();
@@ -1220,7 +1222,7 @@ public class SchemaTypeSystemImpl extend
                 throw new SchemaTypeLoaderException("Could not write compiled schema resource " + resourcename, _name, handle, SchemaTypeLoaderException.NOT_WRITEABLE);
             }
 
-            _output = new DataOutputStream(rawoutput);
+            _output = new LongUTFDataOutputStream(rawoutput);
             _handle = handle;
 
             writeInt(DATA_BABE);

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XsbDumper.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XsbDumper.java?rev=1890295&r1=1890294&r2=1890295&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XsbDumper.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XsbDumper.java Fri May 28 17:10:41 2021
@@ -18,6 +18,7 @@ package org.apache.xmlbeans.impl.tool;
 import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.util.HexBin;
+import org.apache.xmlbeans.impl.util.LongUTFDataInputStream;
 import org.apache.xmlbeans.soap.SOAPArrayType;
 
 import javax.xml.namespace.QName;
@@ -103,7 +104,7 @@ public class XsbDumper {
     }
 
     private XsbDumper(InputStream stream, String indent, PrintStream ostream) {
-        _input = new DataInputStream(stream);
+        _input = new LongUTFDataInputStream(stream);
         _indent = indent;
         _out = ostream;
     }
@@ -501,7 +502,7 @@ public class XsbDumper {
             return result;
         }
 
-        void readFrom(DataInputStream input) {
+        void readFrom(LongUTFDataInputStream input) {
             if (intsToStrings.size() != 1 || stringsToInts.size() != 0) {
                 throw new IllegalStateException();
             }
@@ -511,7 +512,7 @@ public class XsbDumper {
                 emit("String pool (" + size + "):");
                 indent();
                 for (int i = 1; i < size; i++) {
-                    String str = input.readUTF();
+                    String str = input.readLongUTF();
                     int code = codeForString(str);
                     if (code != i) {
                         throw new IllegalStateException();
@@ -526,7 +527,7 @@ public class XsbDumper {
     }
 
     // active while loading one type.
-    DataInputStream _input;
+    LongUTFDataInputStream _input;
     StringPool _stringPool;
 
     int readShort() {

Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataInputStream.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataInputStream.java?rev=1890295&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataInputStream.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataInputStream.java Fri May 28 17:10:41 2021
@@ -0,0 +1,109 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.util;
+
+import java.io.*;
+
+import static org.apache.xmlbeans.impl.util.LongUTFDataOutputStream.DATA_OUTPUT_CHUNKS;
+import static org.apache.xmlbeans.impl.util.LongUTFDataOutputStream.LONG_UTF_MAGIC;
+
+/**
+ * This class works around the size limitation of UTF strings (&lt; 64kb) of DataInputStream
+ * and needs to be used with LongUTFDataOutputStream
+ */
+public class LongUTFDataInputStream extends DataInputStream {
+    public LongUTFDataInputStream(InputStream in) {
+        super(wrap(in));
+    }
+
+    private static InputStream wrap(InputStream is) {
+        return is.markSupported() ? is : new BufferedInputStream(is);
+    }
+
+    private interface IOCall {
+        byte onebyte(int[] readBuf, int[] fillBuf, int[] readLen) throws IOException;
+    }
+
+    public String readLongUTF() throws IOException {
+        mark(6);
+        int utfLen1 = readShort() & 0x0000FFFF;
+        if (utfLen1 < DATA_OUTPUT_CHUNKS) {
+            reset();
+            return readUTF();
+        }
+        int magic = readInt();
+        if (magic != LONG_UTF_MAGIC) {
+            reset();
+            return readUTF();
+        }
+
+        final int utfLen = readInt();
+        StringBuilder sb = new StringBuilder(utfLen/2);
+        final byte[] bytearr = new byte[4096];
+
+        IOCall give = (readBuf, fillBuf, readLen) -> {
+            if (readLen[0]+1 > utfLen) {
+                throw new UTFDataFormatException("malformed input: partial character at end");
+            }
+
+            if (readBuf[0] >= fillBuf[0]) {
+                fillBuf[0] = Math.min(bytearr.length, utfLen-readLen[0]);
+                readFully(bytearr, 0, fillBuf[0]);
+                readBuf[0] = 0;
+            }
+            readLen[0]++;
+            return bytearr[readBuf[0]++];
+        };
+
+        final int[] readLen = { 0 }, readBuf = { 0 }, fillBuf = { 0 };
+        while (readLen[0] < utfLen) {
+            int c = (int)give.onebyte(readBuf, fillBuf, readLen) & 0xff;
+            switch (c >> 4) {
+                case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
+                    /* 0xxxxxxx*/
+                    sb.append((char)c);
+                    break;
+                case 12: case 13: {
+                    /* 110x xxxx   10xx xxxx*/
+                    int char2 = give.onebyte(readBuf, fillBuf, readLen);
+                    if ((char2 & 0xC0) != 0x80) {
+                        throw new UTFDataFormatException("malformed input around byte " + readLen[0]);
+                    }
+                    sb.append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
+                    break;
+                }
+                case 14: {
+                    /* 1110 xxxx  10xx xxxx  10xx xxxx */
+                    int char2 = give.onebyte(readBuf, fillBuf, readLen);
+                    int char3 = give.onebyte(readBuf, fillBuf, readLen);
+
+                    if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
+                        throw new UTFDataFormatException("malformed input around byte " + (readLen[0]-1));
+                    }
+                    sb.append((char) (((c & 0x0F) << 12) |
+                                      ((char2 & 0x3F) << 6) |
+                                      ((char3 & 0x3F))));
+                    break;
+                }
+                default:
+                    /* 10xx xxxx,  1111 xxxx */
+                    throw new UTFDataFormatException("malformed input around byte " + readLen[0]);
+            }
+        }
+        return sb.toString();
+    }
+}
+

Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataOutputStream.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataOutputStream.java?rev=1890295&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataOutputStream.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/util/LongUTFDataOutputStream.java Fri May 28 17:10:41 2021
@@ -0,0 +1,95 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.util;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * This class works around the size limitation of UTF strings (&lt; 64kb) of DataOutputStream
+ * and needs to be used with LongUTFDataInputStream
+ */
+public class LongUTFDataOutputStream extends DataOutputStream {
+    /**
+     * Max. chunk size for string part to be output to DataOutputStream is 64kb
+     */
+    static final int DATA_OUTPUT_CHUNKS = 0x0000FFFF;
+
+    static final int LONG_UTF_MAGIC = 0xDA7A_DA7A;
+
+    public LongUTFDataOutputStream(OutputStream out) {
+        super(out);
+    }
+
+    /**
+     * Checks the length of the to-be-written UTF-8 array, if the length is below 64k then
+     * {@link DataOutputStream#writeUTF(String)} is called, otherwise a 4-byte (int) is injected to list/count
+     * the appended UTF-8 bytes
+     * @param str the string to be written as UTF8-modified
+     */
+    public void writeLongUTF(String str) throws IOException {
+        // DataOutputStream allows only 64k chunks - see XMLBeans-235
+        final int utfLen = countUTF(str);
+        if (utfLen < DATA_OUTPUT_CHUNKS) {
+            writeUTF(str);
+            return;
+        }
+
+        writeShort(0xFFFF);
+        writeInt(LONG_UTF_MAGIC);
+        writeInt(utfLen);
+
+        final byte[] bytearr = new byte[4096];
+        final int strlen = str.length();
+        int count = 0;
+        for (int i=0; i < strlen; i++) {
+            if (count >= bytearr.length-3) {
+                write(bytearr, 0, count);
+                count = 0;
+            }
+            char c = str.charAt(i);
+            if ((c >= 0x0001) && (c <= 0x007F)) {
+                bytearr[count++] = (byte) c;
+            } else {
+                if (c > 0x07FF) {
+                    bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+                    bytearr[count++] = (byte) (0x80 | ((c >>  6) & 0x3F));
+                } else {
+                    bytearr[count++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
+                }
+                bytearr[count++] = (byte) (0x80 | (c & 0x3F));
+            }
+        }
+        write(bytearr, 0, count);
+    }
+
+    public static int countUTF(String str) {
+        final int strlen = str.length();
+        int count = 0;
+        for (int i=0; i<strlen; i++) {
+            char c = str.charAt(i);
+            if ((c >= 0x0001) && (c <= 0x007F)) {
+                count += 1;
+            } else if (c > 0x07FF) {
+                count += 3;
+            } else {
+                count += 2;
+            }
+        }
+        return count;
+    }
+}

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java?rev=1890295&r1=1890294&r2=1890295&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java Fri May 28 17:10:41 2021
@@ -19,6 +19,7 @@ import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.*;
 import org.apache.xmlbeans.impl.schema.SchemaTypeImpl;
 import org.apache.xmlbeans.impl.schema.SchemaTypeVisitorImpl;
+import org.apache.xmlbeans.impl.util.LongUTFDataInputStream;
 import org.apache.xmlbeans.impl.validator.Validator;
 import org.w3c.dom.Node;
 import org.xml.sax.ContentHandler;
@@ -2964,11 +2965,11 @@ public abstract class XmlObjectBase impl
             // now set up a DataInputStream to read those
             // bytes as a UTF-8 String i.e. as though we'd never
             // read the first 2 bytes from the original stream
-            DataInputStream dis = null;
+            LongUTFDataInputStream dis = null;
             String str;
             try {
-                dis = new DataInputStream(new ByteArrayInputStream(bArray));
-                str = dis.readUTF();
+                dis = new LongUTFDataInputStream(new ByteArrayInputStream(bArray));
+                str = dis.readLongUTF();
             } finally {
                 if (dis != null) {
                     dis.close();

Added: xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java?rev=1890295&view=auto
==============================================================================
--- xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java (added)
+++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/LargeAnnotation.java Fri May 28 17:10:41 2021
@@ -0,0 +1,123 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package compile.scomp.detailed;
+
+import compile.scomp.common.CompileCommon;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.util.LongUTFDataInputStream;
+import org.apache.xmlbeans.impl.util.LongUTFDataOutputStream;
+import org.junit.Test;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Random;
+
+import static org.junit.Assert.*;
+
+public class LargeAnnotation {
+    @Test
+    public void longUTFInOutput() throws IOException {
+        int leftLimit = 48; // numeral '0'
+        int rightLimit = 0x01FF_FFFF;
+        int targetStringLength = 0x0001_FFFF;
+
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream(targetStringLength * 2)) {
+            Random random = new Random();
+
+            String generatedString = random.ints(leftLimit, rightLimit + 1)
+                .filter(Character::isValidCodePoint)
+                .limit(targetStringLength)
+                .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
+                .toString();
+
+            try (LongUTFDataOutputStream ldos = new LongUTFDataOutputStream(bos)) {
+                ldos.writeLongUTF(generatedString);
+
+                try (ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+                     LongUTFDataInputStream ldis = new LongUTFDataInputStream(bis)) {
+                    String str = ldis.readLongUTF();
+                    assertEquals(generatedString, str);
+                }
+            }
+        }
+
+        targetStringLength = 0xFFFF;
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream(targetStringLength + 3)) {
+            try (LongUTFDataOutputStream ldos = new LongUTFDataOutputStream(bos)) {
+                String exp;
+                {
+                    char[] chs = new char[0xFFFF];
+                    Arrays.fill(chs, 'a');
+                    exp = new String(chs);
+                }
+
+                ldos.writeUTF(exp);
+
+                try (ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+                     LongUTFDataInputStream ldis = new LongUTFDataInputStream(bis)) {
+                    String str = ldis.readLongUTF();
+                    assertEquals(exp, str);
+                }
+            }
+
+            String exp;
+            {
+                char[] chs = new char[0xFFFF];
+                Arrays.fill(chs, 'a');
+                chs[0xFFFD] = '\u1234';
+                chs[0xFFFE] = '\u5678';
+                exp = new String(chs);
+            }
+
+            bos.reset();
+            try (LongUTFDataOutputStream ldos = new LongUTFDataOutputStream(bos)) {
+                assertThrows(UTFDataFormatException.class, () -> ldos.writeUTF(exp));
+            }
+
+            bos.reset();
+            try (LongUTFDataOutputStream ldos = new LongUTFDataOutputStream(bos)) {
+                ldos.writeLongUTF(exp);
+
+                try (ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+                     LongUTFDataInputStream ldis = new LongUTFDataInputStream(bis)) {
+                    String str = ldis.readLongUTF();
+                    assertEquals(exp, str);
+                }
+            }
+        }
+    }
+
+
+    @Test
+    public void bug235() throws XmlException, IOException {
+        ArrayList<XmlError> err = new ArrayList<>();
+        XmlOptions xm_opt = new XmlOptions().setErrorListener(err);
+        xm_opt.setSavePrettyPrint();
+
+        File dir = new File(CompileCommon.fileLocation + "/largeAnnotation");
+        File[] files = dir.listFiles((x) -> x.getName().endsWith(".xsd"));
+        assertNotNull(files);
+        XmlObject[] schemas = new XmlObject[files.length];
+        for (int i=0; i<files.length; i++) {
+            schemas[i] = XmlObject.Factory.parse(files[i]);
+        }
+
+        SchemaTypeSystem sts = XmlBeans.compileXmlBeans(null, null,
+            schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opt);
+
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org