Skip to content

Commit

Permalink
drop Java7 support - always use Java8 getParameter() to get action me…
Browse files Browse the repository at this point in the history
…thod parameter names and considerably reduce enhancing
  • Loading branch information
angryziber committed Feb 3, 2017
1 parent 812412f commit b194dd5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 268 deletions.
2 changes: 1 addition & 1 deletion framework/src/play/CorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ protected Enhancer[] defaultEnhancers() {
new SigEnhancer(),
new ControllersEnhancer(),
new MailerEnhancer(),
Play.classes.java8 ? new LocalvariablesNamesEnhancer() : new LocalvariablesNamesEnhancerJava7()
new LocalvariablesNamesEnhancer()
};
}

Expand Down
2 changes: 0 additions & 2 deletions framework/src/play/classloading/ApplicationClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* Application classes container.
*/
public class ApplicationClasses {
public boolean java8 = Play.configuration.getProperty("java.source", System.getProperty("java.version")).compareTo("1.8") >= 0;

/**
* Reference to the eclipse compiler.
*/
Expand Down
6 changes: 2 additions & 4 deletions framework/src/play/classloading/ApplicationCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ public ApplicationCompiler(ApplicationClasses applicationClasses) {
this.settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
this.settings.put(CompilerOptions.OPTION_Encoding, "UTF-8");
this.settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
String javaVersion = applicationClasses.java8 ? CompilerOptions.VERSION_1_8 : CompilerOptions.VERSION_1_7;
String javaVersion = CompilerOptions.VERSION_1_8;
this.settings.put(CompilerOptions.OPTION_Source, javaVersion);
this.settings.put(CompilerOptions.OPTION_TargetPlatform, javaVersion);
this.settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
this.settings.put(CompilerOptions.OPTION_Compliance, javaVersion);
if (applicationClasses.java8) {
this.settings.put(CompilerOptions.OPTION_MethodParametersAttribute, CompilerOptions.GENERATE);
}
this.settings.put(CompilerOptions.OPTION_MethodParametersAttribute, CompilerOptions.GENERATE);
}

/**
Expand Down

This file was deleted.

18 changes: 6 additions & 12 deletions framework/src/play/utils/Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import javassist.bytecode.SourceFileAttribute;
import play.Play;
import play.classloading.ApplicationClassloaderState;
import play.classloading.enhancers.LocalvariablesNamesEnhancerJava7;
import play.data.binding.Binder;
import play.data.binding.ParamNode;
import play.data.binding.RootParamNode;
Expand All @@ -18,6 +17,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.util.*;
import java.util.concurrent.FutureTask;

Expand Down Expand Up @@ -194,18 +194,12 @@ static Object[] prepareArgs(Method method, Map<String, String[]> args) throws Ex
* Retrieve parameter names of a method
*/
public static String[] parameterNames(Method method) throws Exception {
if (Play.classes.java8) {
// No import, so Java 7 will not break trying to load this class
java.lang.reflect.Parameter[] parameters = method.getParameters();
String[] names = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
names[i] = parameters[i].getName();
}
return names;
}
else {
return LocalvariablesNamesEnhancerJava7.parameterNames(method);
Parameter[] parameters = method.getParameters();
String[] names = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
names[i] = parameters[i].getName();
}
return names;
}

public static String rawMethodSignature(Method method) {
Expand Down

0 comments on commit b194dd5

Please sign in to comment.