Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-3054

Replace usages of getParameterTypes().length with getParameterCount()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Minor Minor
    • 6.1.0.Alpha1, 6.1.0.Final
    • None
    • jaxrs
    • None

      getParameterTypes().length is inefficient because it creates an array clone, while getParameterCount() directly returns the length.

      Targets
          Occurrences of 'getParameterTypes().length' in Project
      Found Occurrences in Project  (34 usages found)
          Unclassified  (33 usages found)
              resteasy-client  (4 usages found)
                  org.jboss.resteasy.client.jaxrs.internal.proxy  (1 usage found)
                      SubResourceInvoker.java  (1 usage found)
                          SubResourceInvoker(ResteasyWebTarget, Method, ProxyConfig)  (1 usage found)
                              29 jaxParams = new Annotation[method.getParameterTypes().length];
                  org.jboss.resteasy.client.jaxrs.internal.proxy.processors  (3 usages found)
                      FormProcessor.java  (1 usage found)
                          populateMap(Class, ClientConfiguration, String)  (1 usage found)
                              152 if (method.getParameterTypes().length > 0) continue;
                      ProcessorFactory.java  (2 usages found)
                          createProcessors(Class, Method, ClientConfiguration, MediaType)  (2 usages found)
                              49 Object[] params = new Object[method.getParameterTypes().length];
                              50 for (int i = 0; i < method.getParameterTypes().length; i++)
              resteasy-core  (3 usages found)
                  org.jboss.resteasy.core  (3 usages found)
                      ConstructorInjectorImpl.java  (2 usages found)
                          ConstructorInjectorImpl(Constructor, ResteasyProviderFactory)  (2 usages found)
                              55 params = new ValueInjector[constructor.getParameterTypes().length];
                              57 for (int i = 0; i < constructor.getParameterTypes().length; i++)
                      PropertyInjectorImpl.java  (1 usage found)
                          populateMap(Class<?>, ResteasyProviderFactory)  (1 usage found)
                              86 if (method.getParameterTypes().length != 1) continue;
              resteasy-core-spi  (16 usages found)
                  org.jboss.resteasy.spi.metadata  (6 usages found)
                      DefaultResourceConstructor.java  (2 usages found)
                          DefaultResourceConstructor(ResourceClass, Constructor)  (2 usages found)
                              22 this.params = new ConstructorParameter[constructor.getParameterTypes().length];
                              24 for (int i = 0; i < constructor.getParameterTypes().length; i++)
                      DefaultResourceLocator.java  (2 usages found)
                          DefaultResourceLocator(ResourceClass, Method, Method)  (2 usages found)
                              33 this.params = new MethodParameter[method.getParameterTypes().length];
                              35 for (int i = 0; i < method.getParameterTypes().length; i++)
                      ResourceBuilder.java  (2 usages found)
                          getConstructor(Class<?>)  (1 usage found)
                              857 for (int i = 0; i < constructor.getParameterTypes().length; i++)
                          processDeclaredSetters(ResourceClassBuilder, Class<?>, Set<Long>)  (1 usage found)
                              1163 if (method.getParameterTypes().length != 1)
                  org.jboss.resteasy.spi.util  (10 usages found)
                      PickConstructor.java  (8 usages found)
                          pickSingletonConstructor(Class)  (4 usages found)
                              43 if (con.getParameterTypes().length >= numParameters)
                              45 if (con.getParameterTypes().length > numParameters) {
                              60 if (con.getParameterTypes().length == numParameters && numParameters != 0) {
                              63 numParameters = con.getParameterTypes().length;
                          pickPerRequestConstructor(Class)  (4 usages found)
                              97 if (con.getParameterTypes().length >= numParameters)
                              99 if (con.getParameterTypes().length > numParameters) {
                              115 if (con.getParameterTypes().length == numParameters && numParameters != 0) {
                              118 numParameters = con.getParameterTypes().length;
                      Types.java  (2 usages found)
                          isCompatible(Method, Method)  (2 usages found)
                              139 if (method.getParameterTypes().length != intfMethod.getParameterTypes().length)
                              142 for (int i = 0; i < method.getParameterTypes().length; i++)
              resteasy-jaxb-provider  (1 usage found)
                  org.jboss.resteasy.plugins.providers.jaxb  (1 usage found)
                      JAXBXmlTypeProvider.java  (1 usage found)
                          wrapInJAXBElement(Object, Class<?>)  (1 usage found)
                              277 if (current.getParameterTypes().length == 1 && current.getParameterTypes()[0].equals(type)
              resteasy-jsapi  (1 usage found)
                  org.jboss.resteasy.jsapi  (1 usage found)
                      MethodMetaData.java  (1 usage found)
                          walkForm(Class<?>)  (1 usage found)
                              172 if (method.getParameterTypes().length != 1
              resteasy-links  (1 usage found)
                  org.jboss.resteasy.links.impl  (1 usage found)
                      BeanUtils.java  (1 usage found)
                          isBeanAccessor(Method)  (1 usage found)
                              169 return (name.startsWith("get") || name.startsWith("is")) && m.getParameterTypes().length == 0;
              resteasy-multipart-provider  (2 usages found)
                  org.jboss.resteasy.plugins.providers.multipart  (2 usages found)
                      MultipartFormAnnotationReader.java  (1 usage found)
                          readFrom(Class<Object>, Type, Annotation[], MediaType, MultivaluedMap<String, String>, InputStream)  (1 usage found)
                              91 && method.getParameterTypes().length == 1)
                      MultipartFormAnnotationWriter.java  (1 usage found)
                          getMultipart(Object, Class<?>)  (1 usage found)
                              70 && method.getName().startsWith("get") && method.getParameterTypes().length == 0
              resteasy-validator-provider  (4 usages found)
                  org.jboss.resteasy.plugins.validation  (4 usages found)
                      GeneralValidatorImpl.java  (4 usages found)
                          validateAllParameters(HttpRequest, Object, Method, Object[], Class<?>...)  (1 usage found)
                              172 if (method.getParameterTypes().length == 0)
                          isGetter(Method)  (1 usage found)
                              403 if (m.getParameterTypes().length > 0)
                          overrides(Method, Method)  (1 usage found)
                              496 if (subTypeMethod.getParameterTypes().length != superTypeMethod.getParameterTypes().length)
                          parametersResolveToSameTypes(Method, Method)  (1 usage found)
                              514 if (subTypeMethod.getParameterTypes().length == 0)
              resteasy-wadl  (1 usage found)
                  org.jboss.resteasy.wadl  (1 usage found)
                      ResteasyWadlMethodMetaData.java  (1 usage found)
                          walkForm(Class<?>)  (1 usage found)
                              166 if (method.getParameterTypes().length != 1
          Usage in comments  (1 usage found)
              resteasy-links  (1 usage found)
                  org.jboss.resteasy.links.test  (1 usage found)
                      SeamFunctionMapper.java  (1 usage found)
                          71                if (m.getParameterTypes().length == paramCount) return m;
      

              Unassigned Unassigned
              clara0 Clara Fang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: