cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [cxf] 02/04: Switch to using list.toArray(new Object[0]) instead of specficially sized array. See: https://shipilev.net/blog/2016/arrays-wisdom-ancients/
Date Fri, 08 Jun 2018 19:31:36 GMT
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit e9797c7076bb43eabef70213e671ae81d7d4f423
Author: Daniel Kulp <dkulp@apache.org>
AuthorDate: Fri Jun 8 14:46:49 2018 -0400

    Switch to using list.toArray(new Object[0]) instead of specficially sized array.
    See:  https://shipilev.net/blog/2016/arrays-wisdom-ancients/
---
 .../apache/cxf/common/classloader/ClassLoaderUtils.java  |  2 +-
 .../org/apache/cxf/common/jaxb/JAXBContextCache.java     |  9 ++++-----
 .../main/java/org/apache/cxf/common/jaxb/JAXBUtils.java  |  2 +-
 .../java/org/apache/cxf/common/logging/Log4jLogger.java  |  2 +-
 .../org/apache/cxf/common/util/CglibProxyHelper.java     |  2 +-
 .../main/java/org/apache/cxf/common/util/Compiler.java   |  6 +++---
 .../java/org/apache/cxf/common/util/ReflectionUtil.java  |  2 +-
 .../java/org/apache/cxf/configuration/jsse/SSLUtils.java |  3 +--
 .../service/factory/AnnotationsFactoryBeanListener.java  |  2 +-
 .../apache/cxf/common/xmlschema/ImportRepairTest.java    |  2 +-
 .../cxf/jca/core/classloader/PlugInClassLoader.java      |  2 +-
 .../java/org/apache/cxf/maven_plugin/WsdlUtilities.java  |  2 +-
 .../apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java |  2 +-
 .../cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java    |  2 +-
 .../corba/maven/plugins/IDLToWSDLPlugin.java             |  2 +-
 .../corba/maven/plugins/WSDLToIDLPlugin.java             |  2 +-
 .../java/org/apache/cxf/maven_plugin/Java2WSMojo.java    |  4 ++--
 .../maven_plugin/wadlto/AbstractCodeGeneratorMojo.java   |  2 +-
 .../org/apache/cxf/maven_plugin/wadlto/OptionLoader.java |  2 +-
 .../org/apache/cxf/maven_plugin/WSDLValidatorMojo.java   |  4 ++--
 .../org/apache/cxf/binding/corba/CorbaDestination.java   |  2 +-
 .../cxf/binding/corba/runtime/CorbaDSIServant.java       |  2 +-
 .../cxf/binding/corba/utils/CorbaBindingHelper.java      |  4 ++--
 .../org/apache/cxf/aegis/type/basic/BeanTypeInfo.java    |  2 +-
 .../org/apache/cxf/aegis/client/BookServiceImpl.java     |  2 +-
 .../src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java  |  2 +-
 .../main/java/org/apache/cxf/jaxb/JAXBDataBinding.java   |  8 ++++----
 .../java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java     |  2 +-
 .../cxf/jaxrs/impl/CacheControlHeaderProvider.java       |  2 +-
 .../org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java   |  2 +-
 .../apache/cxf/jaxrs/provider/AbstractJAXBProvider.java  |  2 +-
 .../cxf/jaxrs/provider/RequestDispatcherProvider.java    |  2 +-
 .../main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java |  2 +-
 .../java/org/apache/cxf/jaxrs/utils/ResourceUtils.java   |  2 +-
 .../apache/cxf/jaxrs/utils/schemas/SchemaHandler.java    |  2 +-
 .../org/apache/cxf/jaxws/context/WrappedAttachments.java |  2 +-
 .../cxf/jaxws/handler/soap/SOAPMessageContextImpl.java   |  2 +-
 .../cxf/jaxws/support/JaxWsServiceFactoryBean.java       |  2 +-
 .../apache/cxf/jaxws/context/WrappedAttachmentsTest.java |  2 +-
 .../java/org/apache/cxf/jaxrs/client/AbstractClient.java |  2 +-
 .../ext/search/jpa/AbstractJPATypedQueryVisitor.java     |  4 ++--
 .../jaxrs/ext/search/jpa/JPACriteriaQueryVisitor.java    |  2 +-
 .../org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java     |  2 +-
 .../cxf/transport/http/asyncclient/AsyncHTTPConduit.java |  2 +-
 .../netty/server/servlet/NettyHttpServletRequest.java    |  2 +-
 .../cxf/transport/http/DestinationRegistryImpl.java      |  2 +-
 .../cxf/transport/https/SSLSocketFactoryWrapper.java     |  2 +-
 .../servlet/servicelist/ServiceListGeneratorServlet.java |  4 ++--
 .../cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java |  2 +-
 .../builder/primitive/PrimitiveAssertionBuilder.java     |  4 ++--
 .../java/org/apache/cxf/ws/rm/ManagedRMEndpoint.java     | 16 ++++++++--------
 .../main/java/org/apache/cxf/ws/rm/ManagedRMManager.java |  2 +-
 .../service/factory/XercesSchemaValidationUtils.java     |  2 +-
 .../org/apache/cxf/sts/claims/LdapClaimsHandler.java     |  2 +-
 .../cxf/xkms/x509/repo/file/FileCertificateRepo.java     |  2 +-
 .../cxf/tools/common/AbstractCXFToolContainer.java       |  2 +-
 .../java/org/apache/cxf/tools/common/ClassUtils.java     |  2 +-
 .../tools/common/toolspec/parser/CommandDocument.java    |  4 ++--
 .../tools/common/toolspec/parser/CommandLineParser.java  |  2 +-
 .../cxf/tools/corba/processors/idl/WSDLASTVisitor.java   |  2 +-
 .../tools/java2wsdl/generator/wsdl11/BeanGenerator.java  |  2 +-
 .../processor/internal/jaxws/RequestWrapper.java         |  2 +-
 .../processor/internal/jaxws/ResponseWrapper.java        |  4 ++--
 .../cxf/tools/validator/internal/SchemaValidator.java    |  4 ++--
 .../apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java   |  2 +-
 .../tools/wsdlto/databinding/jaxb/JAXBDataBinding.java   |  2 +-
 .../cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java  |  2 +-
 .../jaxws/customization/CustomizationParser.java         |  2 +-
 .../frontend/jaxws/generators/ServiceGenerator.java      |  2 +-
 69 files changed, 93 insertions(+), 95 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java b/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
index d90dc4d..e087da1 100644
--- a/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
@@ -93,7 +93,7 @@ public final class ClassLoaderUtils {
     public static ClassLoader getURLClassLoader(
         final List<URL> urlList, final ClassLoader parent
     ) {
-        return getURLClassLoader(urlList.toArray(new URL[urlList.size()]), parent);
+        return getURLClassLoader(urlList.toArray(new URL[0]), parent);
     }
 
     /**
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
index abc403a..a4bf45a 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBContextCache.java
@@ -251,8 +251,7 @@ public final class JAXBContextCache {
                 try {
                     context = AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
                         public JAXBContext run() throws Exception {
-                            return JAXBContext.newInstance(classes
-                                                          .toArray(new Class<?>[classes.size()]), null);
+                            return JAXBContext.newInstance(classes.toArray(new Class<?>[0]), null);
                         }
                     });
                 } catch (PrivilegedActionException e) {
@@ -319,7 +318,7 @@ public final class JAXBContextCache {
                         && m.getParameterTypes().length == 9) {
                         try {
                             return (JAXBContext)m.invoke(null,
-                                     classes.toArray(new Class<?>[classes.size()]),
+                                     classes.toArray(new Class<?>[0]),
                                      typeRefs,
                                      map.get(pfx + "subclassReplacements"),
                                      map.get(pfx + "defaultNamespaceRemap"),
@@ -344,7 +343,7 @@ public final class JAXBContextCache {
         try {
             ctx = AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
                 public JAXBContext run() throws Exception {
-                    return JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()]), map);
+                    return JAXBContext.newInstance(classes.toArray(new Class<?>[0]), map);
                 }
             });
         } catch (PrivilegedActionException e2) {
@@ -355,7 +354,7 @@ public final class JAXBContextCache {
                     && ex.getMessage().contains("com.sun.xml.bind.defaultNamespaceRemap")) {
                     map.put("com.sun.xml.internal.bind.defaultNamespaceRemap",
                             map.remove("com.sun.xml.bind.defaultNamespaceRemap"));
-                    ctx = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()]), map);
+                    ctx = JAXBContext.newInstance(classes.toArray(new Class<?>[0]), map);
                 } else {
                     throw ex;
                 }
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
index cf0a4d9..d0872a9 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
@@ -678,7 +678,7 @@ public final class JAXBUtils {
             for (Method m : cls.getDeclaredMethods()) {
                 if (m.getName().equals("newInstance")
                     && m.getParameterTypes().length == 6) {
-                    ctx = m.invoke(null, clses.toArray(new Class<?>[clses.size()]),
+                    ctx = m.invoke(null, clses.toArray(new Class<?>[0]),
                                          typeRefs, null, null, true, null);
 
                 }
diff --git a/core/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java b/core/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
index 7f52fac..a0e6b86 100644
--- a/core/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
+++ b/core/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
@@ -103,7 +103,7 @@ public class Log4jLogger extends AbstractDelegatingLogger {
                 ret.add(((HandlerWrapper)ap).getHandler());
             }
         }
-        return ret.toArray(new Handler[ret.size()]);
+        return ret.toArray(new Handler[0]);
     }
 
     protected void internalLogFormatted(String msg, LogRecord record) {
diff --git a/core/src/main/java/org/apache/cxf/common/util/CglibProxyHelper.java b/core/src/main/java/org/apache/cxf/common/util/CglibProxyHelper.java
index fa12576..e7fc78c 100644
--- a/core/src/main/java/org/apache/cxf/common/util/CglibProxyHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/CglibProxyHelper.java
@@ -59,7 +59,7 @@ class CglibProxyHelper extends ProxyHelper {
             Enhancer enhancer = new Enhancer();
             enhancer.setClassLoader(loader);
             enhancer.setSuperclass(superClass);
-            enhancer.setInterfaces(theInterfaces.toArray(new Class<?>[theInterfaces.size()]));
+            enhancer.setInterfaces(theInterfaces.toArray(new Class<?>[0]));
             enhancer.setCallback(new MethodInterceptor() {
 
                 public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
diff --git a/core/src/main/java/org/apache/cxf/common/util/Compiler.java b/core/src/main/java/org/apache/cxf/common/util/Compiler.java
index a7acdf7..ebf1f4c 100644
--- a/core/src/main/java/org/apache/cxf/common/util/Compiler.java
+++ b/core/src/main/java/org/apache/cxf/common/util/Compiler.java
@@ -127,14 +127,14 @@ public class Compiler {
         for (File file : files) {
             f.add(file.getAbsolutePath());
         }
-        return compileFiles(f.toArray(new String[files.length]));
+        return compileFiles(f.toArray(new String[0]));
     }
     public boolean compileFiles(List<File> files) {
         List<String> f = new ArrayList<>(files.size());
         for (File file : files) {
             f.add(file.getAbsolutePath());
         }
-        return compileFiles(f.toArray(new String[files.size()]));
+        return compileFiles(f.toArray(new String[0]));
     }
     public boolean compileFiles(String[] files) {
         String endorsed = SystemPropertyAction.getProperty("java.endorsed.dirs");
@@ -190,7 +190,7 @@ public class Compiler {
         int idx = list.size();
         list.addAll(Arrays.asList(files));
 
-        return internalCompile(list.toArray(new String[list.size()]), idx);
+        return internalCompile(list.toArray(new String[0]), idx);
     }
 
     protected boolean useJava6Compiler(String[] files) {
diff --git a/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java b/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
index fd801c8..b3f5aa5 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
@@ -255,7 +255,7 @@ public final class ReflectionUtil {
                         throw new RuntimeException(e.getCause());
                     }
                 }
-                return descriptors.toArray(new PropertyDescriptor[descriptors.size()]);
+                return descriptors.toArray(new PropertyDescriptor[0]);
             }
             return null;
         }
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
index f889541..a974159 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
@@ -484,8 +484,7 @@ public final class SSLUtils {
     private static String[] getCiphersFromList(List<String> cipherSuitesList,
                                                Logger log,
                                                boolean exclude) {
-        int numCipherSuites = cipherSuitesList.size();
-        String[] cipherSuites = cipherSuitesList.toArray(new String[numCipherSuites]);
+        String[] cipherSuites = cipherSuitesList.toArray(new String[0]);
         if (log.isLoggable(Level.FINE)) {
             StringBuilder ciphsStr = new StringBuilder();
             for (String s : cipherSuites) {
diff --git a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
index 5e757f5..fb7d8b4 100644
--- a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
+++ b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
@@ -117,7 +117,7 @@ public class AnnotationsFactoryBeanListener implements FactoryBeanListener {
             if (docs != null) {
                 addDocumentation(ep,
                                  WSDLDocumentation.Placement.SERVICE,
-                                 docs.toArray(new WSDLDocumentation[docs.size()]));
+                                 docs.toArray(new WSDLDocumentation[0]));
             }
             addBindingOperationDocs(ep);
             for (Method method : implCls.getMethods()) {
diff --git a/core/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java b/core/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
index 7f03285..56c0381 100644
--- a/core/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
+++ b/core/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
@@ -206,7 +206,7 @@ public class ImportRepairTest extends Assert {
             name = name.replace("xs.LS", "impl.xs.util.LS");
             Class<?> c = Class.forName(name);
             Object inputList = c.getConstructor(LSInput[].class, Integer.TYPE)
-            .newInstance(inputs.toArray(new LSInput[inputs.size()]), inputs.size());
+            .newInstance(inputs.toArray(new LSInput[0]), inputs.size());
 
             findMethod(schemaLoader, "loadInputList").invoke(schemaLoader, inputList);
         } catch (InvocationTargetException ite) {
diff --git a/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java b/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
index b350bc2..5823b78 100644
--- a/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
+++ b/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
@@ -118,7 +118,7 @@ public class PlugInClassLoader extends SecureClassLoader {
             }
         }
 
-        return urlList.toArray(new String[urlList.size()]);
+        return urlList.toArray(new String[0]);
     }
 
     protected Class<?> findClass(String name) throws ClassNotFoundException {
diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java
index 10ff437..91b473e 100644
--- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java
+++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlUtilities.java
@@ -68,7 +68,7 @@ public final class WsdlUtilities {
         exList.addAll(Arrays.asList(org.codehaus.plexus.util.FileUtils.getDefaultExcludes()));
 
         String inc = joinWithComma(includes);
-        String ex = joinWithComma(exList.toArray(new String[exList.size()]));
+        String ex = joinWithComma(exList.toArray(new String[0]));
 
         try {
             List<?> newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
index f722d77..96c94e8 100644
--- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
+++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
@@ -376,7 +376,7 @@ public class WSDL2JavaMojo extends AbstractCodegenMoho {
             list.add(0, "-encoding");
             list.add(1, encoding);
         }
-        String[] args = list.toArray(new String[list.size()]);
+        String[] args = list.toArray(new String[0]);
         getLog().debug("Calling wsdl2java with args: " + Arrays.toString(args));
 
         if (!"false".equals(fork)) {
diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
index 458aa09..a0c5839 100644
--- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
+++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
@@ -97,7 +97,7 @@ public class WSDL2JavaScriptMojo extends AbstractCodegenMoho {
 
         List<String> list = wsdlOption.generateCommandLine(outputDirFile, basedir, wsdlURI, getLog()
             .isDebugEnabled());
-        String[] args = list.toArray(new String[list.size()]);
+        String[] args = list.toArray(new String[0]);
         getLog().debug("Calling wsdl2js with args: " + Arrays.toString(args));
 
         if (!"false".equals(fork)) {
diff --git a/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java b/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java
index 92a7e8f..2311d44 100644
--- a/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java
+++ b/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/IDLToWSDLPlugin.java
@@ -74,7 +74,7 @@ public class IDLToWSDLPlugin extends AbstractMojo {
                 list.addAll(idltowsdlOptions[x].getExtraargs());
                 list.add(idltowsdlOptions[x].getIDL());
                 try {
-                    IDLToWSDL.run(list.toArray(new String[list.size()]));
+                    IDLToWSDL.run(list.toArray(new String[0]));
                     doneFile.delete();
                     doneFile.createNewFile();
                 } catch (Throwable e) {
diff --git a/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java b/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
index fa2edb4..f175c64 100644
--- a/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
+++ b/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
@@ -154,7 +154,7 @@ public class WSDLToIDLPlugin extends AbstractMojo {
                     }
                     list.add(wsdltoidlOptions[x].getWSDL());
                     try {
-                        WSDLToIDL.run(list.toArray(new String[list.size()]));
+                        WSDLToIDL.run(list.toArray(new String[0]));
                         doneFile.delete();
                         doneFile.createNewFile();
                     } catch (Throwable e) {
diff --git a/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java b/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java
index acd8189..c3c2abd 100644
--- a/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java
+++ b/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSMojo.java
@@ -391,7 +391,7 @@ public class Java2WSMojo extends AbstractMojo {
         if (!fork) {
             try {
                 CommandInterfaceUtils.commandCommonMain();
-                JavaToWS j2w = new JavaToWS(args.toArray(new String[args.size()]));
+                JavaToWS j2w = new JavaToWS(args.toArray(new String[0]));
                 j2w.run();
             } catch (OutOfMemoryError e) {
                 getLog().debug(e);
@@ -418,7 +418,7 @@ public class Java2WSMojo extends AbstractMojo {
                 throw new MojoExecutionException(e.getMessage(), e);
             }
 
-            cmd.addArguments(args.toArray(new String[args.size()]));
+            cmd.addArguments(args.toArray(new String[0]));
 
             CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
             CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
index f114ba5..f2a621e 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
@@ -386,7 +386,7 @@ public abstract class AbstractCodeGeneratorMojo extends AbstractMojo {
 
             List<String> list = option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
                                                                .isDebugEnabled());
-            String[] args = list.toArray(new String[list.size()]);
+            String[] args = list.toArray(new String[0]);
             getLog().debug("Calling wadl2java with args: " + Arrays.toString(args));
 
             if (!"false".equals(fork)) {
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
index 1bb2b36..88822fd 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
@@ -127,7 +127,7 @@ public final class OptionLoader {
         exList.addAll(Arrays.asList(org.codehaus.plexus.util.FileUtils.getDefaultExcludes()));
 
         String inc = joinWithComma(includes);
-        String ex = joinWithComma(exList.toArray(new String[exList.size()]));
+        String ex = joinWithComma(exList.toArray(new String[0]));
 
         try {
             List<?> newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
diff --git a/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java b/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
index 3cdb215..35aadbb 100644
--- a/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
+++ b/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
@@ -96,7 +96,7 @@ public class WSDLValidatorMojo extends AbstractMojo {
         exList.addAll(Arrays.asList(org.codehaus.plexus.util.FileUtils.getDefaultExcludes()));
 
         String inc = getIncludeExcludeString(includes);
-        String ex = getIncludeExcludeString(exList.toArray(new String[exList.size()]));
+        String ex = getIncludeExcludeString(exList.toArray(new String[0]));
 
         try {
             List<?> newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
@@ -136,7 +136,7 @@ public class WSDLValidatorMojo extends AbstractMojo {
             getLog().debug("Calling wsdlvalidator with args: " + list);
             try {
                 list.add(file.getCanonicalPath());
-                String[] pargs = list.toArray(new String[list.size()]);
+                String[] pargs = list.toArray(new String[0]);
 
                 ToolSpec spec = null;
                 try (InputStream toolspecStream = WSDLValidator.class .getResourceAsStream("wsdlvalidator.xml")) {
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java
index eef037f..fa5d2f0 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java
@@ -416,7 +416,7 @@ public class CorbaDestination implements MultiplexDestination {
 
         orbConfig.addPOAPolicies(orb, name, parentPOA, poaManager, policies);
 
-        Policy[] policyList = policies.toArray(new Policy[policies.size()]);
+        Policy[] policyList = policies.toArray(new Policy[0]);
 
         try {
             return parentPOA.create_POA(name, poaManager, policyList);
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/runtime/CorbaDSIServant.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/runtime/CorbaDSIServant.java
index 4f5b45c..6f5e304 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/runtime/CorbaDSIServant.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/runtime/CorbaDSIServant.java
@@ -176,7 +176,7 @@ public class CorbaDSIServant extends DynamicImplementation {
     }
 
     public String[] _all_interfaces(POA poa, byte[] objectId) {
-        return interfaces.toArray(new String[interfaces.size()]);
+        return interfaces.toArray(new String[0]);
     }
 
     public POA _default_POA() {
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaBindingHelper.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaBindingHelper.java
index 89ab320..327f127 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaBindingHelper.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaBindingHelper.java
@@ -54,7 +54,7 @@ public final class CorbaBindingHelper {
                 props.put("org.omg.CORBA.ORBSingletonClass", config.getOrbSingletonClass());
             }
             List<String> orbArgs = config.getOrbArgs();
-            defaultORB = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
+            defaultORB = ORB.init(orbArgs.toArray(new String[0]), props);
             if (defaultORB == null) {
                 LOG.severe("Could not create instance of the ORB");
                 throw new CorbaBindingException("Could not create instance of the ORB");
@@ -123,7 +123,7 @@ public final class CorbaBindingHelper {
         } else {
             throw new CorbaBindingException("Unsupported address scheme type " + scheme);
         }
-        orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
+        orb = ORB.init(orbArgs.toArray(new String[0]), props);
         orbList.put(getORBNameFromAddress(address), orb);
 
         return orb;
diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
index 8215095..29e8852 100644
--- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
+++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
@@ -309,7 +309,7 @@ public class BeanTypeInfo {
 
         getInterfacePropertyDescriptors(clazz, pds, new HashSet<Class<?>>());
 
-        return pds.toArray(new PropertyDescriptor[pds.size()]);
+        return pds.toArray(new PropertyDescriptor[0]);
     }
 
     private void getInterfacePropertyDescriptors(Class<?> clazz, List<PropertyDescriptor> pds,
diff --git a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/BookServiceImpl.java b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/BookServiceImpl.java
index 5af69a6..5b85231 100644
--- a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/BookServiceImpl.java
+++ b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/BookServiceImpl.java
@@ -38,7 +38,7 @@ public class BookServiceImpl implements BookService {
     }
 
     public Book[] getBooks() {
-        return allBooks.toArray(new Book[allBooks.size()]);
+        return allBooks.toArray(new Book[0]);
     }
 
     public Book findBook(String isbn) {
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
index 404fe15..c7b9446 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
@@ -103,7 +103,7 @@ public abstract class JAXBDataBase {
                 annoList = extractJAXBAnnotations(getReturnMethodAnnotations(mpi));
             }
         }
-        return annoList == null ? new Annotation[0] : annoList.toArray(new Annotation[annoList.size()]);
+        return annoList == null ? new Annotation[0] : annoList.toArray(new Annotation[0]);
     }
 
     private List<Annotation> extractJAXBAnnotations(Annotation[] anns) {
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
index d56d192..56ce6bc 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
@@ -808,10 +808,10 @@ public class JAXBDataBinding extends AbstractInterceptorProvidingDataBinding
         }
 
         return createWrapperHelper(wrapperType,
-                                 setMethods.toArray(new Method[setMethods.size()]),
-                                 getMethods.toArray(new Method[getMethods.size()]),
-                                 jaxbMethods.toArray(new Method[jaxbMethods.size()]),
-                                 fields.toArray(new Field[fields.size()]),
+                                 setMethods.toArray(new Method[0]),
+                                 getMethods.toArray(new Method[0]),
+                                 jaxbMethods.toArray(new Method[0]),
+                                 fields.toArray(new Field[0]),
                                  objectFactory);
     }
 
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
index a7073b2..1e6ec27 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
@@ -474,7 +474,7 @@ public final class JAXBEncoderDecoder {
         Class<?> cls = null;
         if (mObj instanceof List) {
             List<?> l = (List<?>)mObj;
-            objArray = l.toArray(new Object[l.size()]);
+            objArray = l.toArray();
             cls = null;
         } else {
             objArray = mObj;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/CacheControlHeaderProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/CacheControlHeaderProvider.java
index 10e529c..07b1718 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/CacheControlHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/CacheControlHeaderProvider.java
@@ -128,7 +128,7 @@ public class CacheControlHeaderProvider implements HeaderDelegate<CacheControl>
                     values.add(val);
                 }
             }
-            return values.toArray(new String[values.size()]);
+            return values.toArray(new String[0]);
         }
         String separator = getSeparator();
         return StringUtils.split(c, separator);
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
index bf797c2..7edee82 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
@@ -280,7 +280,7 @@ public class ResponseBuilderImpl extends ResponseBuilder implements Cloneable {
         if (methods == null) {
             return allow();
         }
-        return allow(methods.toArray(new String[methods.size()]));
+        return allow(methods.toArray(new String[0]));
     }
 
     @Override
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
index bf45677..ec13c5f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
@@ -354,7 +354,7 @@ public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvid
                 collectionContextClasses.add(type);
             }
             return JAXBContext.newInstance(
-                collectionContextClasses.toArray(new Class[collectionContextClasses.size()]), cProperties);
+                collectionContextClasses.toArray(new Class[0]), cProperties);
         }
     }
 
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
index a4b3264..2ef4ba2 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
@@ -256,7 +256,7 @@ public class RequestDispatcherProvider extends AbstractResponseViewProvider {
         }
 
         public void setParameters(String name, List<String> values) {
-            doSetParameters(name, values.toArray(new String[values.size()]));
+            doSetParameters(name, values.toArray(new String[0]));
         }
 
         private void doSetParameters(String name, String[] values) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 252f4cd..4685270 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -204,7 +204,7 @@ public final class JAXRSUtils {
                 types = ((AbstractConfigurableProvider)provider).getProduceMediaTypes();
             }
             if (types != null) {
-                values = !types.isEmpty() ? types.toArray(new String[types.size()])
+                values = !types.isEmpty() ? types.toArray(new String[0])
                                            : new String[]{"*/*"};
             }
         }
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
index 1b32e85..88536a9 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
@@ -1032,7 +1032,7 @@ public final class ResourceUtils {
 
         JAXBContext ctx;
         try {
-            ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]),
+            ctx = JAXBContext.newInstance(classes.toArray(new Class[0]),
                                           contextProperties);
             return ctx;
         } catch (JAXBException ex) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
index 70a55f7..e5823d2 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
@@ -152,7 +152,7 @@ public class SchemaHandler {
                     }
                 }
             }
-            s = factory.newSchema(sources.toArray(new Source[sources.size()]));
+            s = factory.newSchema(sources.toArray(new Source[0]));
         } catch (Exception ex) {
             throw new IllegalArgumentException("Failed to load XML schema : " + ex.getMessage(), ex);
         }
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedAttachments.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedAttachments.java
index 009e200..920d22a 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedAttachments.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedAttachments.java
@@ -65,7 +65,7 @@ class WrappedAttachments implements Set<Attachment> {
     }
 
     public Object[] toArray() {
-        return toArray(new Object[attachments.size()]);
+        return toArray(new Object[0]);
     }
 
     @SuppressWarnings("unchecked")
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
index 4a61b7d..c26fab8 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
@@ -101,7 +101,7 @@ public class SOAPMessageContextImpl extends WrappedMessageContext implements SOA
                     ret.add(JAXBUtils.unmarshall(context, she));
                 }
             }
-            return ret.toArray(new Object[ret.size()]);
+            return ret.toArray(new Object[0]);
         } catch (SOAPException e) {
             throw new WebServiceException(e);
         } catch (JAXBException e) {
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
index 8631221..249b5ca 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
@@ -268,7 +268,7 @@ public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
             asyncHandlerParams.add(AsyncHandler.class);
             Method futureMethod = ReflectionUtil
                 .getDeclaredMethod(method.getDeclaringClass(), method.getName() + "Async",
-                                   asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
+                                   asyncHandlerParams.toArray(new Class<?>[0]));
 
             getMethodDispatcher().bind(op, method, responseMethod, futureMethod);
 
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedAttachmentsTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedAttachmentsTest.java
index de9a8b9..c705d6e 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedAttachmentsTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedAttachmentsTest.java
@@ -63,7 +63,7 @@ public class WrappedAttachmentsTest extends Assert {
 
         assertEquals(1, attachments.size());
 
-        Attachment[] atts = attachments.toArray(new Attachment[attachments.size()]);
+        Attachment[] atts = attachments.toArray(new Attachment[0]);
         assertEquals(1, atts.length);
         assertEquals("att-1".equals(attx.getId()) ? "att-2" : "att-1", atts[0].getId());
 
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
index 9f726c8..d8bd43f 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
@@ -896,7 +896,7 @@ public abstract class AbstractClient implements Client {
                 }
             }
         }
-        return results.toArray(new String[results.size()]);
+        return results.toArray(new String[0]);
     }
 
     protected ClientConfiguration getConfiguration() {
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
index efa9c40..eff9e76 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
@@ -128,7 +128,7 @@ public abstract class AbstractJPATypedQueryVisitor<T, T1, E>
                 condition.accept(this);
             }
             List<Predicate> predsList = predStack.pop();
-            Predicate[] preds = predsList.toArray(new Predicate[predsList.size()]);
+            Predicate[] preds = predsList.toArray(new Predicate[0]);
             Predicate newPred;
             if (sc instanceof OrSearchCondition) {
                 newPred = builder.or(preds);
@@ -158,7 +158,7 @@ public abstract class AbstractJPATypedQueryVisitor<T, T1, E>
     public CriteriaQuery<T1> getCriteriaQuery() {
         if (!criteriaFinalized) {
             List<Predicate> predsList = predStack.pop();
-            cq.where(predsList.toArray(new Predicate[predsList.size()]));
+            cq.where(predsList.toArray(new Predicate[0]));
             criteriaFinalized = true;
         }
         return cq;
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/JPACriteriaQueryVisitor.java b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/JPACriteriaQueryVisitor.java
index 5c27cd9..9bc2153 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/JPACriteriaQueryVisitor.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/JPACriteriaQueryVisitor.java
@@ -151,7 +151,7 @@ public class JPACriteriaQueryVisitor<T, E> extends AbstractJPATypedQueryVisitor<
     }
 
     private static Selection<?>[] toSelectionsArray(List<Selection<?>> selections) {
-        return selections.toArray(new Selection[selections.size()]);
+        return selections.toArray(new Selection[0]);
     }
 
     private TypedQuery<E> getTypedQuery(CriteriaQuery<E> theCriteriaQuery) {
diff --git a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java
index 7a96bc7..d98962a 100644
--- a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java
+++ b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseBroadcasterImpl.java
@@ -87,7 +87,7 @@ public class SseBroadcasterImpl implements SseBroadcaster {
             }
         }
         
-        return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
+        return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
     }
 
     @Override
diff --git a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
index 74ab1c7..e497fae 100755
--- a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
+++ b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
@@ -943,7 +943,7 @@ public class AsyncHTTPConduit extends URLConnectionHTTPConduit {
         if (list.isEmpty()) {
             return null;
         }
-        return list.toArray(new String[list.size()]);
+        return list.toArray(new String[0]);
     }
 
 }
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
index 869448c..b0d564d 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
@@ -253,7 +253,7 @@ public class NettyHttpServletRequest implements HttpServletRequest {
         if (values == null || values.isEmpty()) {
             return null;
         }
-        return values.toArray(new String[values.size()]);
+        return values.toArray(new String[0]);
     }
 
     @Override
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
index 3dfc11d..e7856f9 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
@@ -143,7 +143,7 @@ public class DestinationRegistryImpl implements DestinationRegistry, ServletConf
             }
         });
 
-        return dest2.toArray(new AbstractDestination[dest2.size()]);
+        return dest2.toArray(new AbstractDestination[0]);
     }
 
     public Set<String> getDestinationsPaths() {
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLSocketFactoryWrapper.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLSocketFactoryWrapper.java
index 91be997..e0a762e 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLSocketFactoryWrapper.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLSocketFactoryWrapper.java
@@ -127,7 +127,7 @@ class SSLSocketFactoryWrapper extends SSLSocketFactory {
         if (list.isEmpty()) {
             return null;
         }
-        return list.toArray(new String[list.size()]);
+        return list.toArray(new String[0]);
     }
 
     /*
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
index 541a743..0c9b1ef 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java
@@ -159,7 +159,7 @@ public class ServiceListGeneratorServlet extends HttpServlet {
                 soapEndpoints.add(sd);
             }
         }
-        return soapEndpoints.toArray(new AbstractDestination[soapEndpoints.size()]);
+        return soapEndpoints.toArray(new AbstractDestination[0]);
     }
 
     private AbstractDestination[] getRestEndpoints(AbstractDestination[] destinations,
@@ -172,7 +172,7 @@ public class ServiceListGeneratorServlet extends HttpServlet {
                 restfulDests.add(sd);
             }
         }
-        return restfulDests.toArray(new AbstractDestination[restfulDests.size()]);
+        return restfulDests.toArray(new AbstractDestination[0]);
     }
 
 
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
index a193249..2db4cd7 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
@@ -119,7 +119,7 @@ public class JaxbAssertionBuilder<T> implements AssertionBuilder<Element> {
     }
 
     public QName[] getKnownElements() {
-        return supportedTypes.toArray(new QName[supportedTypes.size()]);
+        return supportedTypes.toArray(new QName[0]);
     }
 
     protected JaxbAssertion<T> buildAssertion() {
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
index b995b4b..08d04e2 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
@@ -36,7 +36,7 @@ public class PrimitiveAssertionBuilder implements AssertionBuilder<Element> {
     public PrimitiveAssertionBuilder() {
     }
     public PrimitiveAssertionBuilder(Collection<QName> els) {
-        knownElements = els.toArray(new QName[els.size()]);
+        knownElements = els.toArray(new QName[0]);
     }
     public PrimitiveAssertionBuilder(QName els[]) {
         knownElements = els;
@@ -52,7 +52,7 @@ public class PrimitiveAssertionBuilder implements AssertionBuilder<Element> {
     }
 
     public void setKnownElements(Collection<QName> k) {
-        knownElements = k.toArray(new QName[k.size()]);
+        knownElements = k.toArray(new QName[0]);
     }
     public void setKnownElements(QName k[]) {
         knownElements = k;
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMEndpoint.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMEndpoint.java
index a418905..74610b4 100755
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMEndpoint.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMEndpoint.java
@@ -172,7 +172,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
         }
 
         List<Long> numbers = rq.getUnacknowledgedMessageNumbers(ss);
-        return numbers.toArray(new Long[numbers.size()]);
+        return numbers.toArray(new Long[0]);
     }
 
     @ManagedOperation(description = "Total Number of Deferred Acknowledgements")
@@ -219,7 +219,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
             list.add(r.getLower());
             list.add(r.getUpper());
         }
-        return list.toArray(new Long[list.size()]);
+        return list.toArray(new Long[0]);
     }
 
     @ManagedOperation(description = "Destination Sequence Acknowledged Range")
@@ -238,7 +238,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
             list.add(r.getLower());
             list.add(r.getUpper());
         }
-        return list.toArray(new Long[list.size()]);
+        return list.toArray(new Long[0]);
     }
 
     @ManagedOperation(description = "Retransmission Status")
@@ -323,7 +323,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
         }
 
         List<Long> numbers = rq.getUndeliveredMessageNumbers(ds);
-        return numbers.toArray(new Long[numbers.size()]);
+        return numbers.toArray(new Long[0]);
     }
 
     @ManagedOperation(description = "List of Source Sequence IDs")
@@ -338,7 +338,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
                 list.add(ss.getIdentifier().getValue());
             }
         }
-        return list.toArray(new String[list.size()]);
+        return list.toArray(new String[0]);
     }
 
 
@@ -349,7 +349,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
         for (DestinationSequence ds : destination.getAllSequences()) {
             list.add(ds.getIdentifier().getValue());
         }
-        return list.toArray(new String[list.size()]);
+        return list.toArray(new String[0]);
     }
 
 
@@ -449,7 +449,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
             }
         }
 
-        return sps.toArray(new CompositeData[sps.size()]);
+        return sps.toArray(new CompositeData[0]);
     }
 
     @ManagedOperation(description = "Destination Sequence Properties")
@@ -471,7 +471,7 @@ public class ManagedRMEndpoint implements ManagedComponent {
             sps.add(getDestinationSequenceProperties(ds));
         }
 
-        return sps.toArray(new CompositeData[sps.size()]);
+        return sps.toArray(new CompositeData[0]);
     }
 
     private SourceSequence getSourceSeq(String sid) {
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java
index 239e7da..b98a4fd 100755
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java
@@ -64,7 +64,7 @@ public class ManagedRMManager implements ManagedComponent {
         for (Endpoint ep : manager.getReliableEndpointsMap().keySet()) {
             identifiers.add(RMUtils.getEndpointIdentifier(ep, manager.getBus()));
         }
-        return identifiers.toArray(new String[identifiers.size()]);
+        return identifiers.toArray(new String[0]);
     }
 
 
diff --git a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/XercesSchemaValidationUtils.java b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/XercesSchemaValidationUtils.java
index ac403b4..138e2bd 100644
--- a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/XercesSchemaValidationUtils.java
+++ b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/XercesSchemaValidationUtils.java
@@ -188,7 +188,7 @@ class XercesSchemaValidationUtils {
             name = name.replace("xs.LS", "impl.xs.util.LS");
             Class<?> c = Class.forName(name);
             Object inputList = c.getConstructor(LSInput[].class, Integer.TYPE)
-                .newInstance(inputs.toArray(new LSInput[inputs.size()]), inputs.size());
+                .newInstance(inputs.toArray(new LSInput[0]), inputs.size());
             m.invoke(schemaLoader, inputList);
         } catch (InvocationTargetException e) {
             throw (Exception)e.getTargetException();
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/LdapClaimsHandler.java b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/LdapClaimsHandler.java
index 7765e51..1b3487d 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/LdapClaimsHandler.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/claims/LdapClaimsHandler.java
@@ -199,7 +199,7 @@ public class LdapClaimsHandler implements ClaimsHandler, RealmSupport {
                 }
             }
 
-            String[] searchAttributes = searchAttributeList.toArray(new String[searchAttributeList.size()]);
+            String[] searchAttributes = searchAttributeList.toArray(new String[0]);
 
             if (this.userBaseDn != null) {
                 ldapAttributes = LdapUtils.getAttributesOfEntry(ldap, this.userBaseDn, this.getObjectClass(), this
diff --git a/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java b/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java
index 9196d61..e178596 100644
--- a/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java
+++ b/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java
@@ -174,7 +174,7 @@ public class FileCertificateRepo implements CertificateRepo {
                                                  "File base persistence storage is not found: "
                                                      + storageDir.getPath());
         }
-        return certificateFiles.toArray(new File[certificateFiles.size()]);
+        return certificateFiles.toArray(new File[0]);
     }
 
     public X509Certificate readCertificate(File certFile) throws CertificateException, FileNotFoundException,
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java b/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
index dd18b99..4becd52 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
@@ -253,7 +253,7 @@ public abstract class AbstractCXFToolContainer extends AbstractToolContainer {
         while (nexcludes.hasMoreElements()) {
             result.add(props.getProperty((String)nexcludes.nextElement()));
         }
-        return result.toArray(new String[result.size()]);
+        return result.toArray(new String[0]);
     }
 
     /**
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java b/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
index 503c094..4ea2c6f 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
@@ -120,7 +120,7 @@ public class ClassUtils {
 
         }
 
-        if (!compiler.compileFiles(fileList.toArray(new String[fileList.size()]))) {
+        if (!compiler.compileFiles(fileList.toArray(new String[0]))) {
             Message msg = new Message("FAIL_TO_COMPILE_GENERATE_CODES", LOG);
             throw new ToolException(msg);
         }
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandDocument.java b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandDocument.java
index b6a4a44..a48ec57 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandDocument.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandDocument.java
@@ -102,7 +102,7 @@ public class CommandDocument {
                 result.add(def);
             }
         }
-        return result.toArray(new String[result.size()]);
+        return result.toArray(new String[0]);
     }
 
     public String[] getParameterNames() {
@@ -113,7 +113,7 @@ public class CommandDocument {
                 result.add(el.getAttribute("name"));
             }
         }
-        return result.toArray(new String[result.size()]);
+        return result.toArray(new String[0]);
     }
 
 }
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
index aacb11a..ef01b55 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
@@ -66,7 +66,7 @@ public class CommandLineParser {
         while (toker.hasMoreTokens()) {
             res.add(toker.nextToken());
         }
-        return res.toArray(new String[res.size()]);
+        return res.toArray(new String[0]);
     }
 
     public CommandDocument parseArguments(String args) throws BadUsageException, IOException {
diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
index baf04d5..2dcf8d9 100644
--- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
+++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
@@ -262,7 +262,7 @@ public final class WSDLASTVisitor implements ASTVisitor {
                 }
             }
         }
-        return result.toArray(new Binding[result.size()]);
+        return result.toArray(new Binding[0]);
     }
 
     public boolean writeDefinition(Writer writer) throws Exception {
diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
index 49e4d2f..1c7996d 100644
--- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
+++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
@@ -91,7 +91,7 @@ public class BeanGenerator extends AbstractGenerator<File> {
             for (File file : generatedFiles) {
                 files.add(file.getAbsolutePath());
             }
-            compiler.compileFiles(files.toArray(new String[files.size()]));
+            compiler.compileFiles(files.toArray(new String[0]));
         } catch (Exception e) {
             e.printStackTrace();
         }
diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
index 0e8d6a2..ca217a3 100644
--- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
+++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
@@ -87,7 +87,7 @@ public class RequestWrapper extends Wrapper {
             }
 
             List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx);
-            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
+            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[0]));
             fields.add(field);
         }
 
diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
index 9ad7fe2..3e1d066 100644
--- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
+++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
@@ -94,7 +94,7 @@ public final class ResponseWrapper extends Wrapper {
             String type = getTypeString(method.getGenericReturnType());
             List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method);
             field.setType(type);
-            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
+            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[0]));
         }
         fields.add(field);
 
@@ -107,7 +107,7 @@ public final class ResponseWrapper extends Wrapper {
                 String type = getTypeString(t);
                 JavaField jf = new JavaField(name, type, "");
                 List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx - 1);
-                jf.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
+                jf.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[0]));
                 if (t instanceof ParameterizedType) {
                     ParameterizedType pt = (ParameterizedType)t;
                     Class<?> c = (Class<?>)pt.getRawType();
diff --git a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
index 0258f7a..f2b52de 100644
--- a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
+++ b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
@@ -264,7 +264,7 @@ public class SchemaValidator extends AbstractDefinitionValidator {
                         throw new ToolException(e);
                     }
                 }
-                return xsdUrls.toArray(new String[xsdUrls.size()]);
+                return xsdUrls.toArray(new String[0]);
             }
         }
         return null;
@@ -316,7 +316,7 @@ class NewStackTraceErrorHandler implements ErrorHandler {
         if (errors == null) {
             return null;
         }
-        return errors.toArray(new SAXParseException[errors.size()]);
+        return errors.toArray(new SAXParseException[0]);
     }
 
     void addError(String msg, SAXParseException ex) {
diff --git a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
index c0a6558..7cce4ad 100644
--- a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
+++ b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
@@ -1953,7 +1953,7 @@ public class SourceGenerator {
                                        .getEntityResolver());
         if (!compilerArgs.isEmpty()) {
             compiler.getOptions().addGrammar(new InputSource("null"));
-            compiler.getOptions().parseArguments(compilerArgs.toArray(new String[compilerArgs.size()]));
+            compiler.getOptions().parseArguments(compilerArgs.toArray(new String[0]));
         }
         addSchemas(schemaElements, compiler);
         for (InputSource is : bindingFiles) {
diff --git a/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java b/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
index 163a77f..a610953 100644
--- a/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
+++ b/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
@@ -407,7 +407,7 @@ public class JAXBDataBinding implements DataBindingProfile {
                 // keep parseArguments happy, supply dummy required command-line
                 // opts
                 opts.addGrammar(new InputSource("null"));
-                opts.parseArguments(args.toArray(new String[args.size()]));
+                opts.parseArguments(args.toArray(new String[0]));
             } catch (BadCommandLineException e) {
                 StringBuilder msg = new StringBuilder("XJC reported 'BadCommandLineException' for -xjc argument:");
                 for (String arg : args) {
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
index b181148..b53873f 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
@@ -100,7 +100,7 @@ public class JAXWSContainer extends WSDLToJavaContainer {
                     n.add(arg);
                 }
             }
-            env.put(key, n.toArray(new String[n.size()]));
+            env.put(key, n.toArray(new String[0]));
         }
     }
 }
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
index b78fb95..f2a0654 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
@@ -479,7 +479,7 @@ public final class CustomizationParser {
                 a.add((Element)item);
             }
         }
-        return a.toArray(new Element[a.size()]);
+        return a.toArray(new Element[0]);
     }
 
     private void addBinding(String bindingFile) throws XMLStreamException {
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ServiceGenerator.java b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ServiceGenerator.java
index 71523ac..13f2d296 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ServiceGenerator.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ServiceGenerator.java
@@ -146,7 +146,7 @@ public class ServiceGenerator extends AbstractJAXWSGenerator {
                     useGetResource = true;
                 }
 
-                setAttributes("cxfPortClassnames", portNames.toArray(new String[portNames.size()]));
+                setAttributes("cxfPortClassnames", portNames.toArray(new String[0]));
                 setAttributes("service", js);
                 setAttributes("wsdlLocation", location);
                 setAttributes("useGetResource", useGetResource);

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.

Mime
View raw message