Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-15612

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

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Minor Minor
    • 26.0.0.Beta1, 26.0.0.Final
    • None
    • EE, EJB
    • 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  (45 usages found)
          Unclassified  (45 usages found)
              wildfly-clustering-jgroups-extension  (1 usage found)
                  clustering/jgroups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem  (1 usage found)
                      ProtocolMetricsHandler.java  (1 usage found)
                          findProtocolAttributes(Class<? extends Protocol>)  (1 usage found)
                              285 if ((method.getParameterTypes().length == 0) && isManagedAttribute(method)) {
              wildfly-connector  (1 usage found)
                  connector/src/main/java/org/jboss/as/connector/util  (1 usage found)
                      Injection.java  (1 usage found)
                          findMethod(Class<?>, String, String)  (1 usage found)
                              191 && method.getParameterTypes().length == 1
              wildfly-ee  (5 usages found)
                  ee/src/main/java/org/jboss/as/ee/component  (4 usages found)
                      ManagedReferenceLifecycleMethodInterceptor.java  (1 usage found)
                          ManagedReferenceLifecycleMethodInterceptor(Object, Method, boolean, boolean)  (1 usage found)
                              67 withContext = method.getParameterTypes().length == 1;
                      ViewDescription.java  (2 usages found)
                          findRealMethodForBridgeMethod(Method, ComponentConfiguration, DeploymentReflectionIndex, MethodIdentifier)  (2 usages found)
                              233 final Collection<Method> methods = classIndex.getAllMethods(componentMethod.getName(), componentMethod.getParameterTypes().length);
                              238 for (int i = 0; i < method.getParameterTypes().length; ++i) {
                      ViewService.java  (1 usage found)
                          ViewService(ViewConfiguration)  (1 usage found)
                              85 if (method.getName().equals("finalize") && method.getParameterTypes().length == 0) {
                  ee/src/main/java/org/jboss/as/ee/utils  (1 usage found)
                      InjectionUtils.java  (1 usage found)
                          getInjectionTarget(String, String, ClassLoader, DeploymentReflectionIndex)  (1 usage found)
                              65 if (m.getParameterTypes().length == 1) {
              wildfly-ejb3  (27 usages found)
                  ejb3/src/main/java/org/jboss/as/ejb3/component/session  (6 usages found)
                      SessionBeanObjectViewConfigurator.java  (6 usages found)
                          configure(DeploymentPhaseContext, ComponentConfiguration, ViewDescription, ViewConfiguration)  (6 usages found)
                              70 if (method.getName().equals("getPrimaryKey") && method.getParameterTypes().length == 0) {
                              73 } else if (method.getName().equals("remove") && method.getParameterTypes().length == 0) {
                              76 } else if (method.getName().equals("getEJBLocalHome") && method.getParameterTypes().length == 0) {
                              92 } else if (method.getName().equals("getEJBHome") && method.getParameterTypes().length == 0) {
                              108 } else if (method.getName().equals("getHandle") && method.getParameterTypes().length == 0) {
                              110 getName().equals("isIdentical") && method.getParameterTypes().length == 1 && (method.getParameterTypes()[0].equals(EJBObject.class) || method.getParameterTypes()[0].equals
                  ejb3/src/main/java/org/jboss/as/ejb3/component/singleton  (2 usages found)
                      SingletonComponentDescription.java  (2 usages found)
                          setupViewInterceptors(EJBViewDescription)  (2 usages found)
                              221 if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) ||
                              222 method.getName().equals("equals") && method.getParameterTypes().length == 1 &&
                  ejb3/src/main/java/org/jboss/as/ejb3/component/stateful  (5 usages found)
                      StatefulComponentDescription.java  (5 usages found)
                          addStatefulInstanceAssociatingInterceptor(EJBViewDescription)  (4 usages found)
                              345 if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) ||
                              346 method.getName().equals("equals") && method.getParameterTypes().length == 1 &&
                              359 if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) ||
                              360 method.getName().equals("equals") && method.getParameterTypes().length == 1 &&
                          addRemoveMethodInterceptor(ViewDescription)  (1 usage found)
                              396 if (!object || !viewMethodIdentifier.getName().equals("remove") || viewMethodIdentifier.getParameterTypes().length != 0) {
                  ejb3/src/main/java/org/jboss/as/ejb3/component/stateless  (2 usages found)
                      StatelessComponentDescription.java  (2 usages found)
                          setupViewInterceptors(EJBViewDescription)  (2 usages found)
                              182 if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) ||
                              183 method.getName().equals("equals") && method.getParameterTypes().length == 1 &&
                  ejb3/src/main/java/org/jboss/as/ejb3/deployment  (2 usages found)
                      ApplicableMethodInformation.java  (2 usages found)
                          resolveRealMethod(Method)  (2 usages found)
                              196 && m.getParameterTypes().length == method.getParameterTypes().length
                              202 for(int i = 0; i < method.getParameterTypes().length; ++i) {
                  ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors  (3 usages found)
                      SessionBeanHomeProcessor.java  (3 usages found)
                          configureHome(ComponentDescription, SessionBeanComponentDescription, EJBViewDescription, EJBViewDescription)  (3 usages found)
                              120 } else if (method.getName().equals("getEJBMetaData") && method.getParameterTypes().length == 0 && ((EJBViewDescription)description).getMethodIntf() == MethodIntf.HOME) {
                              141 } else if (method.getName().equals("remove") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) {
                              144 } else if (method.getName().equals("remove") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Handle.class) {
                  ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/dd  (3 usages found)
                      ContainerInterceptorBindingsDDProcessor.java  (1 usage found)
                          deploy(DeploymentPhaseContext)  (1 usage found)
                              183 for (int i = 0; i < method.getParameterTypes().length; ++i) {
                      DeploymentDescriptorInterceptorBindingsProcessor.java  (1 usage found)
                          deploy(DeploymentPhaseContext)  (1 usage found)
                              210 for (int i = 0; i < method.getParameterTypes().length; ++i) {
                      MethodResolutionUtils.java  (1 usage found)
                          resolveMethods(String, MethodParametersMetaData, Class<?>, DeploymentReflectionIndex)  (1 usage found)
                              76 for (int i = 0; i < method.getParameterTypes().length; ++i) {
                  ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/merging  (1 usage found)
                      EjbConcurrencyMergingProcessor.java  (1 usage found)
                          resolveMethod(DeploymentReflectionIndex, Class<?>, Class<?>, NamedMethodMetaData)  (1 usage found)
                              148 for (int i = 0; i < method.getParameterTypes().length; ++i) {
                  ejb3/src/main/java/org/jboss/as/ejb3/timerservice  (3 usages found)
                      TimedObjectInvokerImpl.java  (1 usage found)
                          callTimeout(TimerImpl, Method)  (1 usage found)
                              88 if(timeoutMethod.getParameterTypes().length == 0) {
                      TimerServiceImpl.java  (2 usages found)
                          restoreTimers(List<ScheduleTimer>)  (2 usages found)
                              759 final String[] params = new String[timer.getMethod().getParameterTypes().length];
                              760 for (int i = 0; i < timer.getMethod().getParameterTypes().length; ++i) {
              wildfly-iiop-openjdk  (2 usages found)
                  iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi  (2 usages found)
                      ContainerAnalysis.java  (2 usages found)
                          isAccessor(Method)  (1 usage found)
                              302 if (m.getParameterTypes().length != 0)
                          isMutator(Method)  (1 usage found)
                              318 if (m.getParameterTypes().length != 1)
              wildfly-jaxrs  (1 usage found)
                  jaxrs/src/main/java/org/jboss/as/jaxrs  (1 usage found)
                      JaxrsDeploymentDefinition.java  (1 usage found)
                          formatMethod(ResourceMethodInvoker, String, String, String)  (1 usage found)
                              125 if (resource.getMethod().getParameterTypes().length > 0) {
              wildfly-pojo  (1 usage found)
                  pojo/src/main/java/org/jboss/as/pojo/service  (1 usage found)
                      Callback.java  (1 usage found)
                          getMethod()  (1 usage found)
                              53 if (m.getParameterTypes().length != 1)
              wildfly-sar  (1 usage found)
                  sar/src/main/java/org/jboss/as/service  (1 usage found)
                      ReflectionUtils.java  (1 usage found)
                          getSetter(List<ClassReflectionIndex>, String)  (1 usage found)
                              72 if (setterName.equals(method.getName()) && method.getParameterTypes().length == 1) {
              wildfly-undertow  (1 usage found)
                  undertow/src/main/java/org/wildfly/extension/undertow/filters  (1 usage found)
                      Filter.java  (1 usage found)
                          createHandler(Class<? extends HttpHandler>, ModelNode, List<AttributeDefinition>, HttpHandler)  (1 usage found)
                              77 if (c.getParameterTypes().length == numOfParams) {
              wildfly-weld  (1 usage found)
                  weld/subsystem/src/main/java/org/jboss/as/weld/services/bootstrap  (1 usage found)
                      WeldResourceInjectionServices.java  (1 usage found)
                          resolveResource(InjectionPoint)  (1 usage found)
                              228 if (member instanceof Method && ((Method) member).getParameterTypes().length != 1) {
              wildfly-weld-common  (3 usages found)
                  weld/common/src/main/java/org/jboss/as/weld/util  (3 usages found)
                      ResourceInjectionUtilities.java  (3 usages found)
                          getPropertyName(Method)  (3 usages found)
                              91 if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0) {
                              93 } else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0) {
                              95 } else if (methodName.matches("^(set).*") && method.getParameterTypes().length == 1) {
              wildfly-weld-ejb  (1 usage found)
                  weld/ejb/src/main/java/org/jboss/as/weld/services/bootstrap  (1 usage found)
                      WeldEjbInjectionServices.java  (1 usage found)
                          registerEjbInjectionPoint(InjectionPoint)  (1 usage found)
                              95 if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1) {
      
      

              bstansbe@redhat.com Brian Stansberry
              clara0 Clara Fang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: