Commits

Anonymous committed 4d57ace

XW-723 Creating a lot of garbage Class[] when calling Class.getMethod(String methodname, Class[] argTypes)

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@2056e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (5)

core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java

     //}
     private static final Logger LOG = LoggerFactory.getLogger(DefaultActionInvocation.class);
 
+    private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
     protected Object action;
     protected ActionProxy proxy;
     protected List<PreResultListener> preResultListeners;
             Object methodResult = null;
             Method method = null;
             try {
-                method = getAction().getClass().getMethod(methodName, new Class[0]);
+                method = getAction().getClass().getMethod(methodName, EMPTY_CLASS_ARRAY);
             } catch (NoSuchMethodException e) {
                 // hmm -- OK, try doXxx instead
                 try {
                     String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
-                    method = getAction().getClass().getMethod(altMethodName, new Class[0]);
+                    method = getAction().getClass().getMethod(altMethodName, EMPTY_CLASS_ARRAY);
                 } catch (NoSuchMethodException e1) {
                     // well, give the unknown handler a shot
                     if (unknownHandlerManager.hasUnknownHandlers()) {

core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java

 
     private static final Logger LOG = LoggerFactory.getLogger(DefaultWorkflowInterceptor.class);
 
+    private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+    
     private String inputResultName = Action.INPUT;
 
     /**
                     resultName = ((ValidationWorkflowAware) action).getInputResultName();
                 }
 
-                InputConfig annotation = action.getClass().getMethod(invocation.getProxy().getMethod(), new Class[0]).getAnnotation(InputConfig.class);
+                InputConfig annotation = action.getClass().getMethod(invocation.getProxy().getMethod(), EMPTY_CLASS_ARRAY).getAnnotation(InputConfig.class);
                 if (annotation != null) {
                     if (!annotation.methodName().equals("")) {
                         Method method = action.getClass().getMethod(annotation.methodName());

core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java

 
     private static final String DEFAULT_INVOCATION_METHODNAME = "execute";
 
+    private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
     /**
 	 * This method will prefix <code>actionInvocation</code>'s <code>ActionProxy</code>'s
 	 * <code>method</code> with <code>prefixes</code> before invoking the prefixed method.
         for (String prefixe : prefixes) {
             String prefixedMethodName = prefixe + capitalizedMethodName;
             try {
-                return action.getClass().getMethod(prefixedMethodName, new Class[0]);
+                return action.getClass().getMethod(prefixedMethodName, EMPTY_CLASS_ARRAY);
             }
             catch (NoSuchMethodException e) {
                 // hmm -- OK, try next prefix

core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java

  */
 public class ScopedModelDrivenInterceptor extends AbstractInterceptor {
 
+    private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+    
     private static final String GET_MODEL = "getModel";
     private String scope;
     private String name;
                 String cName = className;
                 if (cName == null) {
                     try {
-                        Method method = action.getClass().getMethod(GET_MODEL, new Class[0]);
+                        Method method = action.getClass().getMethod(GET_MODEL, EMPTY_CLASS_ARRAY);
                         Class cls = method.getReturnType();
                         cName = cls.getName();
                     } catch (NoSuchMethodException e) {

core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java

     }
 
     private final static Logger LOG = LoggerFactory.getLogger(CompoundRootAccessor.class);
+    private final static Class[] EMPTY_CLASS_ARRAY = new Class[0];
     private static Map invalidMethods = new HashMap();
 
     static boolean devMode = false;
 
     private Class[] getArgTypes(Object[] args) {
         if (args == null) {
-            return new Class[0];
+            return EMPTY_CLASS_ARRAY;
         }
 
         Class[] classes = new Class[args.length];