Skip to content

Commit

Permalink
replace duplicate code with Java.parameterNames()
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Dec 21, 2016
1 parent e598276 commit e847a29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions framework/src/play/mvc/Controller.java
Expand Up @@ -722,10 +722,7 @@ protected static void redirect(String action, boolean permanent, Object... args)
try {
Map<String, Object> newArgs = new HashMap<>(args.length);
Method actionMethod = (Method) ActionInvoker.getActionMethod(action)[1];
String[] names = (String[]) actionMethod.getDeclaringClass()
.getDeclaredField(
"$" + actionMethod.getName() + LocalVariablesNamesTracer.computeMethodHash(actionMethod.getParameterTypes()))
.get(null);
String[] names = Java.parameterNames(actionMethod);
for (int i = 0; i < names.length && i < args.length; i++) {
Annotation[] annotations = actionMethod.getParameterAnnotations()[i];
boolean isDefault = false;
Expand Down
2 changes: 1 addition & 1 deletion framework/src/play/templates/GroovyTemplate.java
Expand Up @@ -540,7 +540,7 @@ public Object invokeMethod(String name, Object param) {
try {
Map<String, Object> r = new HashMap<>();
Method actionMethod = (Method) ActionInvoker.getActionMethod(action)[1];
String[] names = (String[]) actionMethod.getDeclaringClass().getDeclaredField("$" + actionMethod.getName() + LocalVariablesNamesTracer.computeMethodHash(actionMethod.getParameterTypes())).get(null);
String[] names = Java.parameterNames(actionMethod);
if (param instanceof Object[]) {
if(((Object[])param).length == 1 && ((Object[])param)[0] instanceof Map) {
r = (Map<String,Object>)((Object[])param)[0];
Expand Down

0 comments on commit e847a29

Please sign in to comment.