Author: kiwiwings
Date: Mon Mar  8 00:09:34 2021
New Revision: 1887308

URL: http://svn.apache.org/viewvc?rev=1887308&view=rev
Log:
Prepare for release
Fix Spotbugs errors
Replace XBeanDebug logging with Log4j

Modified:
    xmlbeans/site/src/documentation/content/xdocs/status.xml
    xmlbeans/trunk/build.xml
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/GDateBuilder.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SystemProperties.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlBeans.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/repackage/Repackage.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscResolver.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCopy.java
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XsbDumper.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
    
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
    xmlbeans/trunk/src/main/resources/maven/plugin.xml
    xmlbeans/trunk/xkit/README.txt

Modified: xmlbeans/site/src/documentation/content/xdocs/status.xml
URL: 
http://svn.apache.org/viewvc/xmlbeans/site/src/documentation/content/xdocs/status.xml?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/site/src/documentation/content/xdocs/status.xml (original)
+++ xmlbeans/site/src/documentation/content/xdocs/status.xml Mon Mar  8 
00:09:34 2021
@@ -48,7 +48,7 @@
 
     <release version="5.0.0" date="2021-03-??">
         <actions>
-            <action dev="PD" type="update" context="code" 
fixes-bug="XMLBEANS-555">Partial method generation and remove inner factory 
classes</action>
+            <action dev="PD" type="update" context="code" 
fixes-bug="XMLBEANS-555" breaks-compatibility="true">Partial method generation 
and remove inner factory classes - re-generation of the beans necessary</action>
             <action dev="PD" type="update" context="code" 
fixes-bug="XMLBEANS-551">use log4j-2 for logging</action>
             <action dev="PD" type="update" context="code" 
fixes-bug="XMLBEANS-486">Provide Maven plugin</action>
         </actions>

Modified: xmlbeans/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/build.xml?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/build.xml (original)
+++ xmlbeans/trunk/build.xml Mon Mar  8 00:09:34 2021
@@ -21,7 +21,7 @@
     <property name="jdk.version.class" value="1.8" description="JDK version of 
generated class files"/>
     <property name="compile.debug" value="true"/>
 
-    <property name="version.base" value="4.0.1"/>
+    <property name="version.base" value="5.0.0"/>
     <property name="version.rc" value=""/>
 
     <property name="cases.location" location="src/test/resources"/>
@@ -978,7 +978,7 @@
                   effort="max"
                   failOnError="true">
             <fileset dir="build">
-                <include name="xmlbeans-4.0.1.jar"/>
+                <include name="xmlbeans-5.0.0.jar"/>
             </fileset>
             <auxClasspath path="${xml-apis.jar}"/>
             <auxClasspath path="${saxon.jar}"/>

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/GDateBuilder.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/GDateBuilder.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/GDateBuilder.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/GDateBuilder.java Mon Mar  
8 00:09:34 2021
@@ -904,7 +904,7 @@ public final class GDateBuilder implemen
 
         if (datemath) {
             // days: may require renormalization
-            _D += sign * day + carry;
+            _D += (long) sign * day + carry;
             _normalizeDate();
         }
     }
@@ -918,11 +918,8 @@ public final class GDateBuilder implemen
             return 30;
         }
 
-        if (month == 2) {
-            return (_isLeapYear(year) ? 29 : 28);
-        }
+        return month == 2 ? (_isLeapYear(year) ? 29 : 28) : 31;
 
-        return 31;
     }
 
     /**
@@ -934,11 +931,8 @@ public final class GDateBuilder implemen
             return 30;
         }
 
-        if (month == 2) {
-            return 29;
-        }
+        return month == 2 ? 29 : 31;
 
-        return 31;
     }
 
     /**
@@ -1107,12 +1101,12 @@ public final class GDateBuilder implemen
         long to1970Ms = 1000 * 60 * 60 * 24 * to1970Date;
 
         to1970Ms += date.getMillisecond();
-        to1970Ms += date.getSecond() * 1000;
-        to1970Ms += date.getMinute() * 60 * 1000;
-        to1970Ms += date.getHour() * 60 * 60 * 1000;
+        to1970Ms += date.getSecond() * 1000L;
+        to1970Ms += date.getMinute() * 60 * 1000L;
+        to1970Ms += date.getHour() * 60 * 60 * 1000L;
         if (date.hasTimeZone()) {
-            to1970Ms -= (date.getTimeZoneMinute() * date.getTimeZoneSign()) * 
60 * 1000;
-            to1970Ms -= (date.getTimeZoneHour() * date.getTimeZoneSign()) * 60 
* 60 * 1000;
+            to1970Ms -= date.getTimeZoneMinute() * date.getTimeZoneSign() * 60 
* 1000L;
+            to1970Ms -= date.getTimeZoneHour() * date.getTimeZoneSign() * 60 * 
60 * 1000L;
         } else {
             TimeZone def = TimeZone.getDefault();
             int offset = def.getOffset(to1970Ms);
@@ -1134,11 +1128,8 @@ public final class GDateBuilder implemen
      * fQuotient(a, b) = the greatest integer less than or equal to a/b
      */
     private static long _fQuotient(long a, int b) {
-        if ((a < 0) == (b < 0)) {
-            return a / b;
-        }
+        return ((a < 0) == (b < 0)) ? (a / b) : -((b - a - 1) / b);
 
-        return -((b - a - 1) / b);
     }
 
     /**

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SystemProperties.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SystemProperties.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SystemProperties.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SystemProperties.java Mon 
Mar  8 00:09:34 2021
@@ -15,36 +15,37 @@
 
 package org.apache.xmlbeans;
 
-import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
 
 
-public class SystemProperties
-{
+public class SystemProperties {
 
-       protected static Hashtable propertyH;
+    private static Map<Object, Object> propertyH;
 
-       public static String getProperty(String key) {
-               if (propertyH == null) {
-                       try {
-                               propertyH = System.getProperties();
-                       } catch(SecurityException ex) {
-                               propertyH = new Hashtable();
-                               return null;
-                       }
-               }
-               return (String)propertyH.get(key);
-       }
-
-       public static String getProperty(String key, String defaultValue) {
-               String result = getProperty(key);
-               if (result == null)
-                       return defaultValue;
-               return result;
-       }
-
-       public static void setPropertyH(Hashtable aPropertyH) {
-               propertyH = aPropertyH;
-       }
+    public static String getProperty(String key) {
+        if (propertyH == null) {
+            try {
+                propertyH = System.getProperties();
+            } catch (SecurityException ex) {
+                propertyH = new Properties();
+                return null;
+            }
+        }
+        return (String) propertyH.get(key);
+    }
+
+    public static String getProperty(String key, String defaultValue) {
+        String result = getProperty(key);
+        if (result == null) {
+            return defaultValue;
+        }
+        return result;
+    }
+
+    public static void setPropertyH(Map<Object, Object> aPropertyH) {
+        propertyH = aPropertyH;
+    }
 
 }
 

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlBeans.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlBeans.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlBeans.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlBeans.java Mon Mar  8 
00:09:34 2021
@@ -38,7 +38,7 @@ public final class XmlBeans {
     private static final String TYPE_SYSTEM_FIELD = "typeSystem";
 
     private static String XMLBEANS_TITLE = "org.apache.xmlbeans";
-    private static String XMLBEANS_VERSION = "4.0.1";
+    private static String XMLBEANS_VERSION = "5.0.0";
     private static String XMLBEANS_VENDOR = "Apache Software Foundation";
 
     static {

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java 
Mon Mar  8 00:09:34 2021
@@ -15,107 +15,98 @@
 
 package org.apache.xmlbeans.impl.common;
 
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.Writer;
-import java.io.Reader;
-import java.io.FileWriter;
-import java.io.FileReader;
+import java.io.*;
 import java.net.URI;
 import java.nio.channels.FileChannel;
 
-public class IOUtil
-{
+public class IOUtil {
     public static void copyCompletely(InputStream input, OutputStream output)
-        throws IOException
-    {
+        throws IOException {
         //if both are file streams, use channel IO
-        if ((output instanceof FileOutputStream) && (input instanceof 
FileInputStream))
-        {
-            try
-            {
+        if ((output instanceof FileOutputStream) && (input instanceof 
FileInputStream)) {
+            try {
                 FileChannel target = ((FileOutputStream) output).getChannel();
                 FileChannel source = ((FileInputStream) input).getChannel();
-                
+
                 source.transferTo(0, Integer.MAX_VALUE, target);
-                
+
                 source.close();
                 target.close();
-                
+
                 return;
-            }
-            catch (Exception e)
-            { /* failover to byte stream version */ }
+            } catch (Exception e) { /* failover to byte stream version */ }
         }
-        
+
         byte[] buf = new byte[8192];
-        while (true)
-        {
+        while (true) {
             int length = input.read(buf);
-            if (length < 0)
+            if (length < 0) {
                 break;
+            }
             output.write(buf, 0, length);
         }
-        
-        try { input.close(); } catch (IOException ignore) {}
-        try { output.close(); } catch (IOException ignore) {}
+
+        try {
+            input.close();
+        } catch (IOException ignore) {
+        }
+        try {
+            output.close();
+        } catch (IOException ignore) {
+        }
     }
 
     public static void copyCompletely(Reader input, Writer output)
-        throws IOException
-    {
+        throws IOException {
         char[] buf = new char[8192];
-        while (true)
-        {
+        while (true) {
             int length = input.read(buf);
-            if (length < 0)
+            if (length < 0) {
                 break;
+            }
             output.write(buf, 0, length);
         }
 
-        try { input.close(); } catch (IOException ignore) {}
-        try { output.close(); } catch (IOException ignore) {}
+        try {
+            input.close();
+        } catch (IOException ignore) {
+        }
+        try {
+            output.close();
+        } catch (IOException ignore) {
+        }
     }
 
-    public static void copyCompletely(URI input, URI output)
-        throws IOException
-    {
-        try
-        {
-            InputStream in = null;
-            try
-            {
-                File f = new File(input);
-                if (f.exists())
-                    in = new FileInputStream(f);
-            }
-            catch (Exception notAFile)
-            {}
-            
-            File out = new File(output);
-            File dir = out.getParentFile();
-            dir.mkdirs();
-            
-            if (in == null)
-                in = input.toURL().openStream();
-                
-            IOUtil.copyCompletely(in, new FileOutputStream(out));
-        }
-        catch (IllegalArgumentException e)
-        {
+    public static void copyCompletely(URI input, URI output) throws 
IOException {
+        File out = new File(output);
+        File dir = out.getParentFile();
+        dir.mkdirs();
+
+        try (InputStream in = urlToStream(input);
+            OutputStream os = new FileOutputStream(out)) {
+            IOUtil.copyCompletely(in, os);
+        } catch (IllegalArgumentException e) {
             throw new IOException("Cannot copy to " + output);
         }
     }
 
-    public static File createDir(File rootdir, String subdir)
-    {
+    private static InputStream urlToStream(URI input) throws IOException {
+        try {
+            File f = new File(input);
+            if (f.exists()) {
+                return new FileInputStream(f);
+            }
+        } catch (Exception ignored) {
+            // notAFile
+        }
+
+        return input.toURL().openStream();
+    }
+
+    public static File createDir(File rootdir, String subdir) {
         File newdir = (subdir == null) ? rootdir : new File(rootdir, subdir);
         boolean created = (newdir.exists() && newdir.isDirectory()) || 
newdir.mkdirs();
-        assert(created) : "Could not create " + newdir.getAbsolutePath();
+        assert (created) : "Could not create " + newdir.getAbsolutePath();
         return newdir;
     }
 }

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java 
Mon Mar  8 00:09:34 2021
@@ -16,9 +16,9 @@
 package org.apache.xmlbeans.impl.common;
 
 import java.io.*;
-import java.util.jar.JarOutputStream;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
 
 /**
  * Provides utility services for jarring and unjarring files and directories.
@@ -27,168 +27,171 @@ import java.util.jar.JarInputStream;
  *
  * @author Patrick Calahan <[email protected]>
  */
-public class JarHelper
-{
-  // ========================================================================
-  // Constants
-
-  private static final int BUFFER_SIZE = 2156;
-
-  // ========================================================================
-  // Variables
-
-  private byte[] mBuffer = new byte[BUFFER_SIZE];
-  private int mByteCount = 0;
-  private boolean mVerbose = false;
-  private String mDestJarName = "";
-
-  // ========================================================================
-  // Constructor
-
-  /**
-   * Instantiates a new JarHelper.
-   */
-  public JarHelper() {}
-
-  // ========================================================================
-  // Public methods
-
-  /**
-   * Jars a given directory or single file into a JarOutputStream.
-   */
-  public void jarDir(File dirOrFile2Jar, File destJar)
-          throws IOException {
-
-    if (dirOrFile2Jar == null || destJar == null)
-        throw new IllegalArgumentException();
-
-    mDestJarName = destJar.getCanonicalPath();
-    FileOutputStream fout = new FileOutputStream(destJar);
-    JarOutputStream jout = new JarOutputStream(fout);
-    //jout.setLevel(0);
-    try {
-      jarDir(dirOrFile2Jar, jout, null);
-    } catch(IOException ioe) {
-      throw ioe;
-    } finally {
-      jout.close();
-      fout.close();
-    }
-  }
-
-  /**
-   * Unjars a given jar file into a given directory.
-   */
-  public void unjarDir(File jarFile, File destDir) throws IOException {
-    BufferedOutputStream dest = null;
-    FileInputStream fis = new FileInputStream(jarFile);
-    unjar(fis,destDir);
-  }
-
-  /**
-   * Given an InputStream on a jar file, unjars the contents into the given
-   * directory.
-   */
-  public void unjar(InputStream in, File destDir) throws IOException {
-    BufferedOutputStream dest = null;
-    JarInputStream jis = new JarInputStream(in);
-    JarEntry entry;
-    while ((entry = jis.getNextJarEntry()) != null) {
-      if (entry.isDirectory()) {
-        File dir = new File(destDir,entry.getName());
-        dir.mkdir();
-        if (entry.getTime() != -1) dir.setLastModified(entry.getTime());
-        continue;
-      }
-      int count;
-      byte data[] = new byte[BUFFER_SIZE];
-      File destFile = new File(destDir, entry.getName());
-      if (mVerbose)
-        System.out.println("unjarring " + destFile +
-                           " from " + entry.getName());
-      FileOutputStream fos = new FileOutputStream(destFile);
-      dest = new BufferedOutputStream(fos, BUFFER_SIZE);
-      while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
-        dest.write(data, 0, count);
-      }
-      dest.flush();
-      dest.close();
-      if (entry.getTime() != -1) destFile.setLastModified(entry.getTime());
-    }
-    jis.close();
-  }
-
-  public void setVerbose(boolean b) {
-    mVerbose = b;
-  }
-
-  // ========================================================================
-  // Private methods
-
-  private static final char SEP = '/';
-  /**
-   * Recursively jars up the given path under the given directory.
-   */
-  private void jarDir(File dirOrFile2jar, JarOutputStream jos, String path)
-          throws IOException {
-    if (mVerbose) System.out.println("checking " + dirOrFile2jar);
-    if (dirOrFile2jar.isDirectory()) {
-      String[] dirList = dirOrFile2jar.list();
-      String subPath = (path == null) ? "" : 
(path+dirOrFile2jar.getName()+SEP);
-      if (path != null) {
-        JarEntry je = new JarEntry(subPath);
-        je.setTime(dirOrFile2jar.lastModified());
-        jos.putNextEntry(je);
-        jos.flush();
-        jos.closeEntry();
-      }
-      for (int i = 0; i < dirList.length; i++) {
-        File f = new File(dirOrFile2jar, dirList[i]);
-        jarDir(f,jos,subPath);
-      }
-    } else {
-      if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName))
-      {
-        if (mVerbose) System.out.println("skipping " + 
dirOrFile2jar.getPath());
-        return;
-      }
-
-      if (mVerbose) System.out.println("adding " + dirOrFile2jar.getPath());
-      FileInputStream fis = new FileInputStream(dirOrFile2jar);
-      try {
-        JarEntry entry = new JarEntry(path+dirOrFile2jar.getName());
-        entry.setTime(dirOrFile2jar.lastModified());
-        jos.putNextEntry(entry);
-        while ((mByteCount = fis.read(mBuffer)) != -1) {
-          jos.write(mBuffer, 0, mByteCount);
-          if (mVerbose) System.out.println("wrote " + mByteCount + " bytes");
-        }
-        jos.flush();
-        jos.closeEntry();
-      } catch (IOException ioe) {
-        throw ioe;
-      } finally {
-        fis.close();
-      }
-    }
-  }
-
-  // for debugging
-  public static void main(String[] args)
-      throws IOException
-  {
-      if (args.length < 2)
-      {
-        System.err.println("Usage: JarHelper jarname.jar directory");
-        return;
-      }
+public class JarHelper {
+    // ========================================================================
+    // Constants
+
+    private static final int BUFFER_SIZE = 2156;
+
+    // ========================================================================
+    // Variables
+
+    private final byte[] mBuffer = new byte[BUFFER_SIZE];
+    private boolean mVerbose = false;
+    private String mDestJarName = "";
+
+    // ========================================================================
+    // Constructor
+
+    /**
+     * Instantiates a new JarHelper.
+     */
+    public JarHelper() {
+    }
+
+    // ========================================================================
+    // Public methods
+
+    /**
+     * Jars a given directory or single file into a JarOutputStream.
+     */
+    public void jarDir(File dirOrFile2Jar, File destJar)
+        throws IOException {
+
+        if (dirOrFile2Jar == null || destJar == null) {
+            throw new IllegalArgumentException();
+        }
 
-      JarHelper jarHelper = new JarHelper();
-      jarHelper.mVerbose = true;
+        mDestJarName = destJar.getCanonicalPath();
+        try (FileOutputStream fout = new FileOutputStream(destJar);
+             JarOutputStream jout = new JarOutputStream(fout)) {
+            //jout.setLevel(0);
+            jarDir(dirOrFile2Jar, jout, null);
+        }
+    }
 
-      File destJar = new File(args[0]);
-      File dirOrFile2Jar = new File(args[1]);
+    /**
+     * Unjars a given jar file into a given directory.
+     */
+    public void unjarDir(File jarFile, File destDir) throws IOException {
+        try (FileInputStream fis = new FileInputStream(jarFile)) {
+            unjar(fis, destDir);
+        }
+    }
+
+    /**
+     * Given an InputStream on a jar file, unjars the contents into the given
+     * directory.
+     */
+    public void unjar(InputStream in, File destDir) throws IOException {
+        BufferedOutputStream dest;
+        try (JarInputStream jis = new JarInputStream(in)) {
+            JarEntry entry;
+            while ((entry = jis.getNextJarEntry()) != null) {
+                if (entry.isDirectory()) {
+                    File dir = new File(destDir, entry.getName());
+                    dir.mkdir();
+                    if (entry.getTime() != -1) {
+                        dir.setLastModified(entry.getTime());
+                    }
+                    continue;
+                }
+                int count;
+                byte[] data = new byte[BUFFER_SIZE];
+                File destFile = new File(destDir, entry.getName());
+                if (mVerbose) {
+                    System.out.println("unjarring " + destFile +
+                                       " from " + entry.getName());
+                }
+                FileOutputStream fos = new FileOutputStream(destFile);
+                dest = new BufferedOutputStream(fos, BUFFER_SIZE);
+                while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
+                    dest.write(data, 0, count);
+                }
+                dest.flush();
+                dest.close();
+                if (entry.getTime() != -1) {
+                    destFile.setLastModified(entry.getTime());
+                }
+            }
+        }
+    }
 
-      jarHelper.jarDir(dirOrFile2Jar, destJar);
-  }
+    public void setVerbose(boolean b) {
+        mVerbose = b;
+    }
+
+    // ========================================================================
+    // Private methods
+
+    private static final char SEP = '/';
+
+    /**
+     * Recursively jars up the given path under the given directory.
+     */
+    private void jarDir(File dirOrFile2jar, JarOutputStream jos, String path)
+        throws IOException {
+        if (mVerbose) {
+            System.out.println("checking " + dirOrFile2jar);
+        }
+        if (dirOrFile2jar.isDirectory()) {
+            String[] dirList = dirOrFile2jar.list();
+            String subPath = (path == null) ? "" : (path + 
dirOrFile2jar.getName() + SEP);
+            if (path != null) {
+                JarEntry je = new JarEntry(subPath);
+                je.setTime(dirOrFile2jar.lastModified());
+                jos.putNextEntry(je);
+                jos.flush();
+                jos.closeEntry();
+            }
+            if (dirList != null) {
+                for (String s : dirList) {
+                    File f = new File(dirOrFile2jar, s);
+                    jarDir(f, jos, subPath);
+                }
+            }
+        } else {
+            if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName)) {
+                if (mVerbose) {
+                    System.out.println("skipping " + dirOrFile2jar.getPath());
+                }
+                return;
+            }
+
+            if (mVerbose) {
+                System.out.println("adding " + dirOrFile2jar.getPath());
+            }
+            try (FileInputStream fis = new FileInputStream(dirOrFile2jar)) {
+                JarEntry entry = new JarEntry(path + dirOrFile2jar.getName());
+                entry.setTime(dirOrFile2jar.lastModified());
+                jos.putNextEntry(entry);
+                int mByteCount;
+                while ((mByteCount = fis.read(mBuffer)) != -1) {
+                    jos.write(mBuffer, 0, mByteCount);
+                    if (mVerbose) {
+                        System.out.println("wrote " + mByteCount + " bytes");
+                    }
+                }
+                jos.flush();
+                jos.closeEntry();
+            }
+        }
+    }
+
+    // for debugging
+    public static void main(String[] args)
+        throws IOException {
+        if (args.length < 2) {
+            System.err.println("Usage: JarHelper jarname.jar directory");
+            return;
+        }
+
+        JarHelper jarHelper = new JarHelper();
+        jarHelper.mVerbose = true;
+
+        File destJar = new File(args[0]);
+        File dirOrFile2Jar = new File(args[1]);
+
+        jarHelper.jarDir(dirOrFile2Jar, destJar);
+    }
 }

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java
 (original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java
 Mon Mar  8 00:09:34 2021
@@ -15,41 +15,35 @@
 
 package org.apache.xmlbeans.impl.common;
 
-import java.io.Reader;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.io.UnsupportedEncodingException;
-import java.io.IOException;
-
-public class ReaderInputStream extends PushedInputStream
-{
-    private Reader reader;
-    private Writer writer;
-    private char[] buf;
-    public static int defaultBufferSize = 2048;
+import java.io.*;
 
-    public ReaderInputStream(Reader reader, String encoding) throws 
UnsupportedEncodingException
-    {
+public class ReaderInputStream extends PushedInputStream {
+    public static final int defaultBufferSize = 2048;
+
+    private final Reader reader;
+    private final Writer writer;
+    private final char[] buf;
+
+    public ReaderInputStream(Reader reader, String encoding) throws 
UnsupportedEncodingException {
         this(reader, encoding, defaultBufferSize);
     }
 
-    public ReaderInputStream(Reader reader, String encoding, int bufferSize) 
throws UnsupportedEncodingException
-    {
-        if (bufferSize <= 0)
+    public ReaderInputStream(Reader reader, String encoding, int bufferSize) 
throws UnsupportedEncodingException {
+        if (bufferSize <= 0) {
             throw new IllegalArgumentException("Buffer size <= 0");
+        }
 
         this.reader = reader;
         this.writer = new OutputStreamWriter(getOutputStream(), encoding);
         buf = new char[bufferSize];
     }
 
-    public void fill(int requestedBytes) throws IOException
-    {
-        do
-        {
+    public void fill(int requestedBytes) throws IOException {
+        do {
             int chars = reader.read(buf);
-            if (chars < 0)
+            if (chars < 0) {
                 return;
+            }
 
             writer.write(buf, 0, chars);
             writer.flush();

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java 
(original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java 
Mon Mar  8 00:09:34 2021
@@ -15,86 +15,9 @@
 
 package org.apache.xmlbeans.impl.common;
 
-import org.apache.xmlbeans.SystemProperties;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 public class XBeanDebug {
-    public static final int TRACE_SCHEMA_LOADING = 0x0001;
-    public static final String traceProp = "org.apache.xmlbeans.impl.debug";
-    public static final String defaultProp = ""; // "TRACE_SCHEMA_LOADING";
-
-    private static int _enabled = initializeBitsFromProperty();
-    private static int _indent = 0;
-
-    private static int initializeBitsFromProperty() {
-        String prop = SystemProperties.getProperty(traceProp, defaultProp);
-        return (prop.contains("TRACE_SCHEMA_LOADING")) ? TRACE_SCHEMA_LOADING 
: 0;
-    }
-
-    public static void enable(int bits) {
-        _enabled = _enabled | bits;
-    }
-
-    public static void disable(int bits) {
-        _enabled = _enabled & ~bits;
-    }
-
-    public static void trace(int bits, String message, int indent) {
-        if (test(bits)) {
-            synchronized (XBeanDebug.class) {
-                if (indent < 0) {
-                    _indent += indent;
-                }
-
-                String _indentspace = "                                        
                                        ";
-                String spaces = _indent < 0 ? "" : _indent > 
_indentspace.length() ? _indentspace : _indentspace.substring(0, _indent);
-                String logmessage = Thread.currentThread().getName() + ": " + 
spaces + message + "\n";
-                System.err.print(logmessage);
-
-                if (indent > 0) {
-                    _indent += indent;
-                }
-            }
-        }
-    }
-
-    public static boolean test(int bits) {
-        return (_enabled & bits) != 0;
-    }
-
-    static PrintStream _err;
-
-    public static String log(String message) {
-        log(message, null);
-        return message;
-    }
-
-    public static String logStackTrace(String message) {
-        log(message, new Throwable());
-        return message;
-    }
-
-    private synchronized static String log(String message, Throwable 
stackTrace) {
-        if (_err == null) {
-            try {
-                File diagnosticFile = File.createTempFile("xmlbeandebug", 
".log");
-                _err = new PrintStream(diagnosticFile, "UTF-8");
-                System.err.println("Diagnostic XML Bean debug log file 
created: " + diagnosticFile);
-            } catch (IOException e) {
-                _err = System.err;
-            }
-        }
-        _err.println(message);
-        if (stackTrace != null) {
-            stackTrace.printStackTrace(_err);
-        }
-        return message;
-    }
-
-    public static void logException(Throwable t) {
-        log(t.getMessage(), t);
-    }
+    public static final Logger LOG = LogManager.getLogger(XBeanDebug.class);
 }

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/repackage/Repackage.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/repackage/Repackage.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/repackage/Repackage.java 
(original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/repackage/Repackage.java 
Mon Mar  8 00:09:34 2021
@@ -335,7 +335,7 @@ public class Repackage {
 
     StringBuffer readInputStream(InputStream is) throws IOException {
         try (Reader r = new InputStreamReader(is, StandardCharsets.ISO_8859_1);
-            StringWriter w = new StringWriter()) {
+             StringWriter w = new StringWriter()) {
             copy(r, w);
             return w.getBuffer();
         }
@@ -344,13 +344,10 @@ public class Repackage {
     public static void copyFile(File from, File to) throws IOException {
         to.getParentFile().mkdirs();
 
-        FileInputStream in = new FileInputStream(from);
-        FileOutputStream out = new FileOutputStream(to);
-
-        copy(in, out);
-
-        out.close();
-        in.close();
+        try (FileInputStream in = new FileInputStream(from);
+             FileOutputStream out = new FileOutputStream(to)) {
+            copy(in, out);
+        }
     }
 
     public static void copy(InputStream in, OutputStream out) throws 
IOException {

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
 (original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
 Mon Mar  8 00:09:34 2021
@@ -1909,7 +1909,7 @@ public final class SchemaTypeImpl implem
             try {
                 return (ctr == null) ? null : ctr.newInstance(sType, 
!sType.isSimpleType());
             } catch (InstantiationException | IllegalAccessException | 
InvocationTargetException e) {
-                XBeanDebug.logException(e);
+                XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage());
                 return null;
             }
         } else {

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
 (original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
 Mon Mar  8 00:09:34 2021
@@ -319,10 +319,10 @@ public class SchemaTypeLoaderImpl extend
     }
 
     SchemaTypeSystemImpl getTypeSystemOnClassloader(String name) {
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Finding type system 
" + name + " on classloader", 0);
+        XBeanDebug.LOG.atTrace().log("Finding type system {} on classloader", 
name);
         SchemaTypeSystemImpl result = _classLoaderTypeSystems.get(name);
         if (result == null) {
-            XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Type system " + 
name + " not cached - consulting field", 0);
+            XBeanDebug.LOG.atTrace().log("Type system {}} not cached - 
consulting field", name);
             result = SchemaTypeSystemImpl.forName(name, _classLoader);
             _classLoaderTypeSystems.put(name, result);
         }

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=1887308&r1=1887307&r2=1887308&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
 Mon Mar  8 00:09:34 2021
@@ -16,10 +16,7 @@
 package org.apache.xmlbeans.impl.schema;
 
 import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
-import org.apache.xmlbeans.impl.common.NameUtil;
-import org.apache.xmlbeans.impl.common.QNameHelper;
-import org.apache.xmlbeans.impl.common.XBeanDebug;
+import org.apache.xmlbeans.impl.common.*;
 import org.apache.xmlbeans.impl.repackage.Repackager;
 import org.apache.xmlbeans.impl.util.FilerImpl;
 import org.apache.xmlbeans.impl.util.HexBin;
@@ -40,8 +37,6 @@ import java.util.function.IntFunction;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
 
 public class SchemaTypeSystemImpl extends SchemaTypeLoaderBase implements 
SchemaTypeSystem {
     public static final int DATA_BABE = 0xDA7ABABE;
@@ -120,17 +115,6 @@ public class SchemaTypeSystemImpl extend
      * a new package.
      */
     public static String METADATA_PACKAGE_GEN = "org/apache/xmlbeans/metadata";
-//    public static String METADATA_PACKAGE_GEN;
-//    static
-//    {
-//        // fix for maven classloader
-//        Package stsPackage = SchemaTypeSystem.class.getPackage();
-//        String stsPackageName = (stsPackage==null) ?
-//            SchemaTypeSystem.class.getName().substring(0, 
SchemaTypeSystem.class.getName().lastIndexOf(".")) :
-//            stsPackage.getName();
-//
-//        METADATA_PACKAGE_GEN = stsPackageName.replace('.', '/') + 
"/metadata";
-//    }
 
     private static String nameToPathString(String nameForSystem) {
         nameForSystem = nameForSystem.replace('.', '/');
@@ -145,7 +129,7 @@ public class SchemaTypeSystemImpl extend
     protected SchemaTypeSystemImpl() {
         String fullname = getClass().getName();
         _name = fullname.substring(0, fullname.lastIndexOf('.'));
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Loading type system 
" + _name, 1);
+        XBeanDebug.LOG.atTrace().log("Loading type system {}", _name);
         _basePackage = nameToPathString(_name);
         _classloader = getClass().getClassLoader();
         _linker = this;
@@ -153,16 +137,16 @@ public class SchemaTypeSystemImpl extend
         try {
             initFromHeader();
         } catch (Error | RuntimeException e) {
-            XBeanDebug.logException(e);
+            XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage());
             throw e;
         }
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Finished loading 
type system " + _name, -1);
+        XBeanDebug.LOG.atTrace().log("Finished loading type system {}", _name);
     }
 
     public SchemaTypeSystemImpl(Class<?> indexclass) {
         String fullname = indexclass.getName();
         _name = fullname.substring(0, fullname.lastIndexOf('.'));
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Loading type system 
" + _name, 1);
+        XBeanDebug.LOG.atTrace().log("Loading type system {}", _name);
         _basePackage = nameToPathString(_name);
         _classloader = indexclass.getClassLoader();
         _linker = SchemaTypeLoaderImpl.build(null, null, _classloader, 
getMetadataPath());
@@ -170,27 +154,10 @@ public class SchemaTypeSystemImpl extend
         try {
             initFromHeader();
         } catch (RuntimeException | Error e) {
-            XBeanDebug.logException(e);
+            XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage());
             throw e;
         }
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Finished loading 
type system " + _name, -1);
-    }
-
-    public static boolean fileContainsTypeSystem(File file, String name) {
-        String indexname = nameToPathString(name) + "index.xsb";
-
-        if (file.isDirectory()) {
-            return (new File(file, indexname)).isFile();
-        } else {
-            try (ZipFile zipfile = new ZipFile(file)) {
-                ZipEntry entry = zipfile.getEntry(indexname);
-                return (entry != null && !entry.isDirectory());
-            } catch (IOException e) {
-                XBeanDebug.log("Problem loading SchemaTypeSystem, zipfilename 
" + file);
-                XBeanDebug.logException(e);
-                throw new SchemaTypeLoaderException(e.getMessage(), name, 
"index", SchemaTypeLoaderException.IO_EXCEPTION, e);
-            }
-        }
+        XBeanDebug.LOG.atTrace().log("Finished loading type system {}", _name);
     }
 
     public static SchemaTypeSystemImpl forName(String name, ClassLoader 
loader) {
@@ -210,13 +177,13 @@ public class SchemaTypeSystemImpl extend
         try {
             initFromHeader();
         } catch (RuntimeException | Error e) {
-            XBeanDebug.logException(e);
+            XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage());
             throw e;
         }
     }
 
     private void initFromHeader() {
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Reading unresolved 
handles for type system " + _name, 0);
+        XBeanDebug.LOG.atTrace().log("Reading unresolved handles for type 
system {}", _name);
         XsbReader reader = null;
         try {
             // Read the index file, which starts with a header.
@@ -400,7 +367,7 @@ public class SchemaTypeSystemImpl extend
 
             // we're done with the class' constant pool,
             // we can just copy the rest of the bytes
-            copy(in, out);
+            IOUtil.copyCompletely(in, out);
         } catch (IOException e) {
             // ok
         }
@@ -420,22 +387,6 @@ public class SchemaTypeSystemImpl extend
             _name, null, SchemaTypeLoaderException.IO_EXCEPTION);
     }
 
-    private static long copy(InputStream inp, OutputStream out) throws 
IOException {
-        final byte[] buff = new byte[4096];
-        long totalCount = 0;
-        int readBytes;
-        do {
-            int todoBytes = buff.length;
-            readBytes = inp.read(buff, 0, todoBytes);
-            if (readBytes > 0) {
-                out.write(buff, 0, readBytes);
-                totalCount += readBytes;
-            }
-        } while (readBytes >= 0);
-
-        return totalCount;
-    }
-
     private static final String HOLDER_TEMPLATE_CLASS = 
"org.apache.xmlbeans.impl.schema.TypeSystemHolder";
     private static final String HOLDER_TEMPLATE_CLASSFILE = 
"TypeSystemHolder.template";
     private static final String[] HOLDER_TEMPLATE_NAMES = 
makeClassStrings(HOLDER_TEMPLATE_CLASS);
@@ -636,6 +587,7 @@ public class SchemaTypeSystemImpl extend
         assert new HashSet<>(comp).equals(temp);
     }
 
+    @SuppressWarnings({"AssertWithSideEffects", "ConstantConditions"})
     private void assertContainersSynchronized() {
         boolean assertEnabled = false;
         // This code basically checks whether asserts are enabled so we don't 
do
@@ -724,7 +676,7 @@ public class SchemaTypeSystemImpl extend
                     _mask[j] += i;
                 }
             } catch (IOException e) {
-                XBeanDebug.logException(e);
+                XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage());
             }
 
             _random = new Random(System.currentTimeMillis());
@@ -3139,27 +3091,27 @@ public class SchemaTypeSystemImpl extend
             int filetype = reader.getActualFiletype();
             switch (filetype) {
                 case FILETYPE_SCHEMATYPE:
-                    XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, 
"Resolving type for handle " + handle, 0);
+                    XBeanDebug.LOG.atTrace().log("Resolving type for handle 
{}", handle);
                     result = reader.finishLoadingType();
                     break;
                 case FILETYPE_SCHEMAELEMENT:
-                    XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, 
"Resolving element for handle " + handle, 0);
+                    XBeanDebug.LOG.atTrace().log("Resolving element for handle 
{}", handle);
                     result = reader.finishLoadingElement();
                     break;
                 case FILETYPE_SCHEMAATTRIBUTE:
-                    XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, 
"Resolving attribute for handle " + handle, 0);
+                    XBeanDebug.LOG.atTrace().log("Resolving attribute for 
handle {}", handle);
                     result = reader.finishLoadingAttribute();
                     break;
                 case FILETYPE_SCHEMAMODELGROUP:
-                    XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, 
"Resolving model group for handle " + handle, 0);
+                    XBeanDebug.LOG.atTrace().log("Resolving model group for 
handle {}", handle);
                     result = reader.finishLoadingModelGroup();
                     break;
                 case FILETYPE_SCHEMAATTRIBUTEGROUP:
-                    XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, 
"Resolving attribute group for handle " + handle, 0);
+                    XBeanDebug.LOG.atTrace().log("Resolving attribute group 
for handle {}", handle);
                     result = reader.finishLoadingAttributeGroup();
                     break;
                 case FILETYPE_SCHEMAIDENTITYCONSTRAINT:
-                    XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, 
"Resolving id constraint for handle " + handle, 0);
+                    XBeanDebug.LOG.atTrace().log("Resolving id constraint for 
handle {}", handle);
                     result = reader.finishLoadingIdentityConstraint();
                     break;
                 default:
@@ -3181,12 +3133,12 @@ public class SchemaTypeSystemImpl extend
     private boolean _allNonGroupHandlesResolved = false;
 
     public void resolve() {
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Resolve called type 
system " + _name, 0);
+        XBeanDebug.LOG.atTrace().log("Resolve called type system {}", _name);
         if (_allNonGroupHandlesResolved) {
             return;
         }
 
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Resolving all 
handles for type system " + _name, 1);
+        XBeanDebug.LOG.atTrace().log("Resolving all handles for type system 
{}", _name);
 
         List<SchemaComponent.Ref> refs = new ArrayList<>();
         refs.addAll(_globalElements.values());
@@ -3201,7 +3153,7 @@ public class SchemaTypeSystemImpl extend
             ref.getComponent();
         }
 
-        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Finished resolving 
type system " + _name, -1);
+        XBeanDebug.LOG.atTrace().log("Finished resolving type system {}", 
_name);
         _allNonGroupHandlesResolved = true;
     }
 
@@ -3327,13 +3279,8 @@ public class SchemaTypeSystemImpl extend
         return _name;
     }
 
-    public SchemaTypeSystem typeSystemForName(String name) {
-        return (name != null && name.equals(_name)) ? this : null;
-    }
-
-
     /**
-     * Provide method to be overriden by user typesystems using a different 
metadata path
+     * Provide method to be overridden by user typesystems using a different 
metadata path
      *
      * @return the metadata directory
      * @since XmlBeans 3.1.0

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java 
(original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscChecker.java 
Mon Mar  8 00:09:34 2021
@@ -413,7 +413,8 @@ public class StscChecker {
                         // see Particle Valid (Restriction) (3.9.6) all three 
bulets 2.2.1
                         return true;
                     } else if (baseModel == null || derivedModel == null) {
-                        XBeanDebug.logStackTrace("Null models that weren't 
caught by EMPTY_CONTENT: " + baseType + " (" + baseModel + "), " + sType + " (" 
+ derivedModel + ")");
+                        XBeanDebug.LOG.atTrace().withThrowable(new 
Exception("Stacktrace"))
+                            .log("Null models that weren't caught by 
EMPTY_CONTENT: {} ({}), {} ({})", baseType, baseModel, sType, derivedModel);
                         
state.error(XmlErrorCodes.COMPLEX_TYPE_RESTRICTION$ELEMENT_OR_MIXED_AND_VALID, 
null, location);
                         return false;
                     }
@@ -472,7 +473,8 @@ public class StscChecker {
                             restrictionValid = false;
                             break;
                         default:
-                            assert false : XBeanDebug.logStackTrace("Unknown 
schema type for Derived Type");
+                            XBeanDebug.LOG.atDebug().withThrowable(new 
Exception("stacktrace")).log("Unknown schema type for Derived Type");
+                            assert(false);
                     }
                     break;
                 case SchemaParticle.WILDCARD:
@@ -489,7 +491,8 @@ public class StscChecker {
                             restrictionValid = 
nsRecurseCheckCardinality(baseModel, derivedModel, errors, context);
                             break;
                         default:
-                            assert false : XBeanDebug.logStackTrace("Unknown 
schema type for Derived Type");
+                            XBeanDebug.LOG.atDebug().withThrowable(new 
Exception("stacktrace")).log("Unknown schema type for Derived Type");
+                            assert(false);
                     }
                     break;
                 case SchemaParticle.ALL:
@@ -510,7 +513,8 @@ public class StscChecker {
                             restrictionValid = recurseUnordered(baseModel, 
derivedModel, errors, context);
                             break;
                         default:
-                            assert false : XBeanDebug.logStackTrace("Unknown 
schema type for Derived Type");
+                            XBeanDebug.LOG.atDebug().withThrowable(new 
Exception("stacktrace")).log("Unknown schema type for Derived Type");
+                            assert(false);
                     }
                     break;
                 case SchemaParticle.CHOICE:
@@ -531,7 +535,8 @@ public class StscChecker {
                             restrictionValid = mapAndSum(baseModel, 
derivedModel, errors, context);
                             break;
                         default:
-                            assert false : XBeanDebug.logStackTrace("Unknown 
schema type for Derived Type");
+                            XBeanDebug.LOG.atDebug().withThrowable(new 
Exception("stacktrace")).log("Unknown schema type for Derived Type");
+                            assert(false);
                     }
                     break;
                 case SchemaParticle.SEQUENCE:
@@ -550,11 +555,13 @@ public class StscChecker {
                             restrictionValid = recurse(baseModel, 
derivedModel, errors, context);
                             break;
                         default:
-                            assert false : XBeanDebug.logStackTrace("Unknown 
schema type for Derived Type");
+                            XBeanDebug.LOG.atDebug().withThrowable(new 
Exception("stacktrace")).log("Unknown schema type for Derived Type");
+                            assert(false);
                     }
                     break;
                 default:
-                    assert false : XBeanDebug.logStackTrace("Unknown schema 
type for Base Type");
+                    XBeanDebug.LOG.atDebug().withThrowable(new 
Exception("stacktrace")).log("Unknown schema type for Base Type");
+                    assert(false);
 
             }
         }

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscResolver.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscResolver.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscResolver.java 
(original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscResolver.java 
Mon Mar  8 00:09:34 2021
@@ -132,7 +132,7 @@ public class StscResolver {
             substitutionGroup = StscState.get().findDocumentType(
                 substitutionGroup.getSubstitutionGroup(), 
substitutionGroup.getChameleonNamespace(), null/*no dependency added*/);
 
-            assert substitutionGroup != null : "Could not find document type 
for: " + substitutionGroup.getSubstitutionGroup();
+            assert substitutionGroup != null : "Could not find document type 
for substitutionGroup";
 
             if (!resolveSubstitutionGroup(substitutionGroup)) {
                 substitutionGroup = null; // cyclic dependency - no subst group

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java 
Mon Mar  8 00:09:34 2021
@@ -75,47 +75,47 @@ public class Parameters {
     }
 
     public void setXsdFiles(File... xsdFiles) {
-        this.xsdFiles = xsdFiles;
+        this.xsdFiles = xsdFiles == null ? null : xsdFiles.clone();
     }
 
     public File[] getWsdlFiles() {
         return wsdlFiles;
     }
 
-    public void setWsdlFiles(File[] wsdlFiles) {
-        this.wsdlFiles = wsdlFiles;
+    public void setWsdlFiles(File... wsdlFiles) {
+        this.wsdlFiles = wsdlFiles == null ? null : wsdlFiles.clone();
     }
 
     public File[] getJavaFiles() {
         return javaFiles;
     }
 
-    public void setJavaFiles(File[] javaFiles) {
-        this.javaFiles = javaFiles;
+    public void setJavaFiles(File... javaFiles) {
+        this.javaFiles = javaFiles == null ? null : javaFiles.clone();
     }
 
     public File[] getConfigFiles() {
         return configFiles;
     }
 
-    public void setConfigFiles(File[] configFiles) {
-        this.configFiles = configFiles;
+    public void setConfigFiles(File... configFiles) {
+        this.configFiles = configFiles == null ? null : configFiles.clone();
     }
 
     public URL[] getUrlFiles() {
         return urlFiles;
     }
 
-    public void setUrlFiles(URL[] urlFiles) {
-        this.urlFiles = urlFiles;
+    public void setUrlFiles(URL... urlFiles) {
+        this.urlFiles = urlFiles == null ? null : urlFiles.clone();
     }
 
     public File[] getClasspath() {
         return classpath;
     }
 
-    public void setClasspath(File[] classpath) {
-        this.classpath = classpath;
+    public void setClasspath(File... classpath) {
+        this.classpath = classpath == null ? null : classpath.clone();
     }
 
     public File getOutputJar() {

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCopy.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCopy.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCopy.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/SchemaCopy.java 
Mon Mar  8 00:09:34 2021
@@ -15,31 +15,28 @@
 
 package org.apache.xmlbeans.impl.tool;
 
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.impl.common.IOUtil;
 import org.apache.xmlbeans.impl.xb.substwsdl.DefinitionsDocument;
 import org.apache.xmlbeans.impl.xb.substwsdl.TImport;
+import org.apache.xmlbeans.impl.xb.xsdschema.ImportDocument;
+import org.apache.xmlbeans.impl.xb.xsdschema.IncludeDocument;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
 
+import java.io.File;
 import java.net.URI;
-import java.net.URL;
 import java.net.URISyntaxException;
-import java.util.Map;
+import java.net.URL;
+import java.nio.file.Paths;
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.io.File;
-
-import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
-import org.apache.xmlbeans.impl.xb.xsdschema.ImportDocument;
-import org.apache.xmlbeans.impl.xb.xsdschema.IncludeDocument;
+import java.util.Map;
 
-public class SchemaCopy
-{
-    public static void printUsage()
-    {
+public class SchemaCopy {
+    public static void printUsage() {
         System.out.println("Copies the XML schema at the specified URL to the 
specified file.");
         System.out.println("Usage: scopy sourceurl [targetfile]");
         System.out.println("    sourceurl - The URL at which the schema is 
located.");
@@ -48,99 +45,78 @@ public class SchemaCopy
 
     }
 
-    public static void main(String[] args)
-    {
-        if (args.length < 1 || args.length > 2)
-        {
+    public static void main(String[] args) {
+        if (args.length < 1 || args.length > 2) {
             printUsage();
             return;
         }
 
         URI source = null;
-        URI target = null;
+        URI target;
 
-        try
-        {
-            if(args[0].compareToIgnoreCase("-usage") == 0){
+        try {
+            if (args[0].compareToIgnoreCase("-usage") == 0) {
                 printUsage();
                 return;
             }
 
             source = new URI(args[0]);
             source.toURL(); // to trigger exception
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             System.err.println("Badly formed URL " + source);
             return;
         }
 
-        if (args.length < 2)
-        {
-            try
-            {
+        if (args.length < 2) {
+            try {
                 URI dir = new File(".").getCanonicalFile().toURI();
                 String lastPart = source.getPath();
                 lastPart = lastPart.substring(lastPart.lastIndexOf('/') + 1);
                 target = CodeGenUtil.resolve(dir, URI.create(lastPart));
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 System.err.println("Cannot canonicalize current directory");
                 return;
             }
-        }
-        else
-        {
-            try
-            {
+        } else {
+            try {
                 target = new URI(args[1]);
-                if (!target.isAbsolute())
+                if (!target.isAbsolute()) {
                     target = null;
-                else if (!target.getScheme().equals("file"))
+                } else if (!target.getScheme().equals("file")) {
                     target = null;
-            }
-            catch (Exception e)
-            {
+                }
+            } catch (Exception e) {
                 target = null;
             }
 
-            if (target == null)
-            {
-                try
-                {
-                    target = new File(target).getCanonicalFile().toURI();
-                }
-                catch (Exception e)
-                {
+            if (target == null) {
+                try {
+                    target = Paths.get("").toAbsolutePath().toUri();
+                } catch (Exception e) {
                     System.err.println("Cannot canonicalize current 
directory");
                     return;
                 }
             }
         }
 
-        Map thingsToCopy = findAllRelative(source, target);
+        Map<URI,URI> thingsToCopy = findAllRelative(source, target);
         copyAll(thingsToCopy, true);
     }
 
-    private static void copyAll(Map uriMap, boolean stdout)
-    {
-        for (Iterator i = uriMap.keySet().iterator(); i.hasNext(); )
-        {
-            URI source = (URI)i.next();
-            URI target = (URI)uriMap.get(source);
-            try
-            {
+    private static void copyAll(Map<URI,URI> uriMap, boolean stdout) {
+        for (URI source : uriMap.keySet()) {
+            URI target = uriMap.get(source);
+            try {
                 IOUtil.copyCompletely(source, target);
-            }
-            catch (Exception e)
-            {
-                if (stdout)
+            } catch (Exception e) {
+                if (stdout) {
                     System.out.println("Could not copy " + source + " -> " + 
target);
+                }
                 continue;
             }
-            if (stdout)
-            System.out.println("Copied " + source + " -> " + target);
+            if (stdout) {
+                System.out.println("Copied " + source + " -> " + target);
+            }
         }
     }
 
@@ -156,24 +132,21 @@ public class SchemaCopy
      * @return a map of all the source/target URIs needed to copy
      * the file along with all its relative referents.
      */
-    public static Map findAllRelative(URI source, URI target)
-    {
-        Map result = new LinkedHashMap();
+    public static Map<URI,URI> findAllRelative(URI source, URI target) {
+        Map<URI,URI> result = new LinkedHashMap<>();
         result.put(source, target);
 
-        LinkedList process = new LinkedList();
+        LinkedList<URI> process = new LinkedList<>();
         process.add(source);
 
-        while (!process.isEmpty())
-        {
-            URI nextSource = (URI)process.removeFirst();
-            URI nextTarget = (URI)result.get(nextSource);
-            Map nextResults = findRelativeInOne(nextSource, nextTarget);
-            for (Iterator i = nextResults.keySet().iterator(); i.hasNext(); )
-            {
-                URI newSource = (URI)i.next();
-                if (result.containsKey(newSource))
+        while (!process.isEmpty()) {
+            URI nextSource = process.removeFirst();
+            URI nextTarget = result.get(nextSource);
+            Map<URI,URI> nextResults = findRelativeInOne(nextSource, 
nextTarget);
+            for (URI newSource : nextResults.keySet()) {
+                if (result.containsKey(newSource)) {
                     continue;
+                }
                 result.put(newSource, nextResults.get(newSource));
                 process.add(newSource);
             }
@@ -183,76 +156,68 @@ public class SchemaCopy
     }
 
     private static final XmlOptions loadOptions = new XmlOptions().
-            setLoadSubstituteNamespaces(Collections.singletonMap(
-                    "http://schemas.xmlsoap.org/wsdl/";, 
"http://www.apache.org/internal/xmlbeans/wsdlsubst";
-            ));
-
-    private static Map findRelativeInOne(URI source, URI target)
-    {
-        try
-        {
+        setLoadSubstituteNamespaces(Collections.singletonMap(
+            "http://schemas.xmlsoap.org/wsdl/";, 
"http://www.apache.org/internal/xmlbeans/wsdlsubst";
+        ));
+
+    private static Map<URI,URI> findRelativeInOne(URI source, URI target) {
+        try {
             URL sourceURL = source.toURL();
             XmlObject xobj = XmlObject.Factory.parse(sourceURL, loadOptions);
             XmlCursor xcur = xobj.newCursor();
             xcur.toFirstChild();
 
-            Map result = new LinkedHashMap();
+            Map<URI,URI> result = new LinkedHashMap<>();
 
-            if (xobj instanceof SchemaDocument)
-                putMappingsFromSchema(result, source, target, 
((SchemaDocument)xobj).getSchema());
-            else if (xobj instanceof DefinitionsDocument)
-                putMappingsFromWsdl(result, source, target, 
((DefinitionsDocument)xobj).getDefinitions());
+            if (xobj instanceof SchemaDocument) {
+                putMappingsFromSchema(result, source, target, 
((SchemaDocument) xobj).getSchema());
+            } else if (xobj instanceof DefinitionsDocument) {
+                putMappingsFromWsdl(result, source, target, 
((DefinitionsDocument) xobj).getDefinitions());
+            }
             return result;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             // any exceptions parsing the given URL?  Then skip this file 
silently
         }
-        return Collections.EMPTY_MAP;
+        return Collections.emptyMap();
     }
 
-    private static void putNewMapping(Map result, URI origSource, URI 
origTarget, String literalURI)
-    {
-        try
-        {
-            if (literalURI == null)
+    private static void putNewMapping(Map<URI,URI> result, URI origSource, URI 
origTarget, String literalURI) {
+        try {
+            if (literalURI == null) {
                 return;
+            }
             URI newRelative = new URI(literalURI);
-            if (newRelative.isAbsolute())
+            if (newRelative.isAbsolute()) {
                 return;
+            }
             URI newSource = CodeGenUtil.resolve(origSource, newRelative);
             URI newTarget = CodeGenUtil.resolve(origTarget, newRelative);
             result.put(newSource, newTarget);
-        }
-        catch (URISyntaxException e)
-        {
+        } catch (URISyntaxException e) {
             // uri syntax problem? do nothing silently.
         }
     }
 
-    private static void putMappingsFromSchema(Map result, URI source, URI 
target, SchemaDocument.Schema schema)
-    {
-        ImportDocument.Import[] imports = schema.getImportArray();
-        for (int i = 0; i < imports.length; i++)
-            putNewMapping(result, source, target, 
imports[i].getSchemaLocation());
-
-        IncludeDocument.Include[] includes = schema.getIncludeArray();
-        for (int i = 0; i < includes.length; i++)
-            putNewMapping(result, source, target, 
includes[i].getSchemaLocation());
-    }
-
-    private static void putMappingsFromWsdl(Map result, URI source, URI 
target, DefinitionsDocument.Definitions wdoc)
-    {
-        XmlObject[] types = wdoc.getTypesArray();
-        for (int i = 0; i < types.length; i++)
-        {
-            SchemaDocument.Schema[] schemas = 
(SchemaDocument.Schema[])types[i].selectPath("declare namespace 
xs='http://www.w3.org/2001/XMLSchema' xs:schema");
-            for (int j = 0; j < schemas.length; j++)
-                putMappingsFromSchema(result, source, target, schemas[j]);
-        }
-
-        TImport[] imports = wdoc.getImportArray();
-        for (int i = 0; i < imports.length; i++)
-            putNewMapping(result, source, target, imports[i].getLocation());
+    private static void putMappingsFromSchema(Map<URI,URI> result, URI source, 
URI target, SchemaDocument.Schema schema) {
+        for (ImportDocument.Import anImport : schema.getImportArray()) {
+            putNewMapping(result, source, target, 
anImport.getSchemaLocation());
+        }
+
+        for (IncludeDocument.Include include : schema.getIncludeArray()) {
+            putNewMapping(result, source, target, include.getSchemaLocation());
+        }
+    }
+
+    private static void putMappingsFromWsdl(Map<URI,URI> result, URI source, 
URI target, DefinitionsDocument.Definitions wdoc) {
+        for (XmlObject type : wdoc.getTypesArray()) {
+            SchemaDocument.Schema[] schemas = (SchemaDocument.Schema[]) 
type.selectPath("declare namespace xs='http://www.w3.org/2001/XMLSchema' 
xs:schema");
+            for (SchemaDocument.Schema schema : schemas) {
+                putMappingsFromSchema(result, source, target, schema);
+            }
+        }
+
+        for (TImport anImport : wdoc.getImportArray()) {
+            putNewMapping(result, source, target, anImport.getLocation());
+        }
     }
 }

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=1887308&r1=1887307&r2=1887308&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 
Mon Mar  8 00:09:34 2021
@@ -74,8 +74,7 @@ public class XsbDumper {
     }
 
     public static void dumpZip(File file) {
-        try {
-            ZipFile zipFile = new ZipFile(file);
+        try (ZipFile zipFile = new ZipFile(file)) {
             Enumeration<? extends ZipEntry> e = zipFile.entries();
             while (e.hasMoreElements()) {
                 ZipEntry entry = e.nextElement();

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
 (original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
 Mon Mar  8 00:09:34 2021
@@ -27,6 +27,8 @@ import net.sf.saxon.query.StaticQueryCon
 import net.sf.saxon.query.XQueryExpression;
 import net.sf.saxon.type.BuiltInAtomicType;
 import net.sf.saxon.value.*;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.store.Cur;
 import org.apache.xmlbeans.impl.store.Cursor;
@@ -50,6 +52,8 @@ import java.util.ListIterator;
 import java.util.Map;
 
 public class SaxonXQuery implements XQuery {
+    private static final Logger LOG = LogManager.getLogger(SaxonXQuery.class);
+
     private final XQueryExpression xquery;
     private final String contextVar;
     private final Configuration config;
@@ -94,18 +98,74 @@ public class SaxonXQuery implements XQue
         _version = c.getLocale().version();
         _cur = c.weakCur(this);
         this._options = options;
-        return objectExecute();
+
+        Map<String, Object> bindings = 
XmlOptions.maskNull(_options).getXqueryVariables();
+        List<Object> resultsList = execQuery(_cur.getDom(), bindings);
+
+        XmlObject[] result = new XmlObject[resultsList.size()];
+        for (int i = 0; i < resultsList.size(); i++) {
+            //copy objects into the locale
+            Locale l = 
Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
+
+            l.enter();
+            Object node = resultsList.get(i);
+            Cur res;
+            try {
+                //typed function results of XQuery
+                if (!(node instanceof Node)) {
+                    res = l.load("<xml-fragment/>").tempCur();
+                    res.setValue(node.toString());
+                    SchemaType type = getType(node);
+                    Locale.autoTypeDocument(res, type, null);
+                    result[i] = res.getObject();
+                } else {
+                    res = loadNode(l, (Node) node);
+                }
+                result[i] = res.getObject();
+            } catch (XmlException e) {
+                throw new RuntimeException(e);
+            } finally {
+                l.exit();
+            }
+            res.release();
+        }
+        release();
+        return result;
     }
 
     public XmlCursor cursorExecute(Cur c, XmlOptions options) {
         _version = c.getLocale().version();
         _cur = c.weakCur(this);
         this._options = options;
-        return cursorExecute();
+
+        Map<String, Object> bindings = 
XmlOptions.maskNull(_options).getXqueryVariables();
+        List<Object> resultsList = execQuery(_cur.getDom(), bindings);
+
+        int i;
+
+        Locale locale = 
Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
+        locale.enter();
+        Locale.LoadContext _context = new Cur.CurLoadContext(locale, _options);
+        Cursor resultCur = null;
+        try {
+            for (i = 0; i < resultsList.size(); i++) {
+                loadNodeHelper(locale, (Node) resultsList.get(i), _context);
+            }
+            Cur c2 = _context.finish();
+            Locale.associateSourceName(c, _options);
+            Locale.autoTypeDocument(c, null, _options);
+            resultCur = new Cursor(c2);
+        } catch (XmlException e) {
+            LOG.atInfo().withThrowable(e).log("Can't autotype document");
+        } finally {
+            locale.exit();
+        }
+        release();
+        return resultCur;
     }
 
 
-    public List execQuery(Object node, Map variableBindings) {
+    public List<Object> execQuery(Object node, Map<String,Object> 
variableBindings) {
         try {
             Node contextNode = (Node) node;
 
@@ -120,7 +180,7 @@ public class SaxonXQuery implements XQue
             dc.setParameter(new StructuredQName("", null, contextVar), root);
             // Set the other variables
             if (variableBindings != null) {
-                for (Map.Entry<String, Object> me : ((Map<String, Object>) 
variableBindings).entrySet()) {
+                for (Map.Entry<String, Object> me : 
variableBindings.entrySet()) {
                     StructuredQName key = new StructuredQName("", null, 
me.getKey());
                     Object value = me.getValue();
                     if (value instanceof XmlTokenSource) {
@@ -230,57 +290,11 @@ public class SaxonXQuery implements XQue
             }
             return htm;
         } else {
-            return new ObjectValue(value);
+            return new ObjectValue<>(value);
         }
     }
 
 
-    public XmlObject[] objectExecute() {
-        if (_cur != null && _version != _cur.getLocale().version())
-        //throw new ConcurrentModificationException
-        // ("Document changed during select")
-        {
-            ;
-        }
-
-        Map<String, Object> bindings = 
XmlOptions.maskNull(_options).getXqueryVariables();
-        List resultsList = execQuery(_cur.getDom(), bindings);
-
-        XmlObject[] result = new XmlObject[resultsList.size()];
-        int i;
-        for (i = 0; i < resultsList.size(); i++) {
-            //copy objects into the locale
-            Locale l = 
Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
-
-            l.enter();
-            Object node = resultsList.get(i);
-            Cur res = null;
-            try {
-                //typed function results of XQuery
-                if (!(node instanceof Node)) {
-                    //TODO: exact same code as Path.java
-                    //make a common super-class and pull this--what to name 
that
-                    //superclass???
-                    res = l.load("<xml-fragment/>").tempCur();
-                    res.setValue(node.toString());
-                    SchemaType type = getType(node);
-                    Locale.autoTypeDocument(res, type, null);
-                    result[i] = res.getObject();
-                } else {
-                    res = loadNode(l, (Node) node);
-                }
-                result[i] = res.getObject();
-            } catch (XmlException e) {
-                throw new RuntimeException(e);
-            } finally {
-                l.exit();
-            }
-            res.release();
-        }
-        release();
-        return result;
-    }
-
     private SchemaType getType(Object node) {
         SchemaType type;
         if (node instanceof Integer) {
@@ -305,40 +319,6 @@ public class SaxonXQuery implements XQue
         return type;
     }
 
-    public XmlCursor cursorExecute() {
-        if (_cur != null && _version != _cur.getLocale().version())
-        //throw new ConcurrentModificationException
-        // ("Document changed during select")
-        {
-            ;
-        }
-
-        Map<String, Object> bindings = 
XmlOptions.maskNull(_options).getXqueryVariables();
-        List resultsList = execQuery(_cur.getDom(), bindings);
-
-        int i;
-
-        Locale locale = 
Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
-        locale.enter();
-        Locale.LoadContext _context = new Cur.CurLoadContext(locale, _options);
-        Cursor resultCur = null;
-        try {
-            for (i = 0; i < resultsList.size(); i++) {
-                loadNodeHelper(locale, (Node) resultsList.get(i), _context);
-            }
-            Cur c = _context.finish();
-            Locale.associateSourceName(c, _options);
-            Locale.autoTypeDocument(c, null, _options);
-            resultCur = new Cursor(c);
-        } catch (Exception e) {
-        } finally {
-            locale.exit();
-        }
-        release();
-        return resultCur;
-    }
-
-
     public void release() {
         if (_cur != null) {
             _cur.release();

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
 (original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
 Mon Mar  8 00:09:34 2021
@@ -246,8 +246,7 @@ public class SampleXmlUtil {
     }
 
     // a bit from the Aenid
-    public static final String[] WORDS = new String[]
-        {
+    private static final String[] WORDS = {
             "ipsa", "iovis", "rapidum", "iaculata", "e", "nubibus", "ignem",
             "disiecitque", "rates", "evertitque", "aequora", "ventis",
             "illum", "exspirantem", "transfixo", "pectore", "flammas",

Modified: xmlbeans/trunk/src/main/resources/maven/plugin.xml
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/resources/maven/plugin.xml?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/resources/maven/plugin.xml (original)
+++ xmlbeans/trunk/src/main/resources/maven/plugin.xml Mon Mar  8 00:09:34 2021
@@ -20,7 +20,7 @@
 
 <plugin>
     <name>xmlbeans</name>
-    <description></description>
+    <description>Maven plugin for Apache XmlBeans</description>
     <groupId>org.apache.xmlbeans</groupId>
     <artifactId>xmlbeans</artifactId>
     <version>@VERSION@</version>

Modified: xmlbeans/trunk/xkit/README.txt
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/xkit/README.txt?rev=1887308&r1=1887307&r2=1887308&view=diff
==============================================================================
--- xmlbeans/trunk/xkit/README.txt (original)
+++ xmlbeans/trunk/xkit/README.txt Mon Mar  8 00:09:34 2021
@@ -13,7 +13,7 @@
  *  limitations under the License.
  */
 
-XMLBeans Development Kit Version 4.0.1
+XMLBeans Development Kit Version 5.0.0
 
 
 Welcome to XMLBeans!
@@ -21,9 +21,9 @@ Welcome to XMLBeans!
 
 Kit contents:
 
-(1) One copy of xmlbeans-4.0.1.jar, which contains XMLBeans.
+(1) One copy of xmlbeans-5.0.0.jar, which contains XMLBeans.
     Should work on any JDK 1.8.x or newer.
-    ./lib/xmlbeans-4.0.1.jar
+    ./lib/xmlbeans-5.0.0.jar
 
 (2) License information for XML Beans and included libraries
     ./LICENSE.txt



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to