Use Java 8 lambdas instead of anonymous classes in compiler modules

This commit is contained in:
Alexander Udalov
2017-04-01 01:37:15 +03:00
parent 6aa0f7bb65
commit 5ebee6ceca
109 changed files with 1528 additions and 2754 deletions
@@ -107,12 +107,8 @@ public class InterceptionInstrumenter {
}
if (enterData.isEmpty() && normalReturnData.isEmpty() && exceptionData.isEmpty()) {
dumpTasks.add(new DumpAction() {
@Override
public void dump(PrintStream out) {
out.println("WARNING: No relevant methods found in " + field + " of type " + interceptorClass.getCanonicalName());
}
});
dumpTasks.add(out -> out.println("WARNING: No relevant methods found in " + field +
" of type " + interceptorClass.getCanonicalName()));
}
String nameFromAnnotation = annotation.methodName();
@@ -215,24 +211,21 @@ public class InterceptionInstrumenter {
}
private void addDumpTask(Object interceptor, Method method, MethodInstrumenter instrumenter) {
dumpTasks.add(new DumpAction() {
@Override
public void dump(PrintStream out) {
out.println("<<< " + instrumenter + ": " + interceptor.getClass().getName() + " says:");
try {
if (method.getParameterTypes().length == 0) {
method.invoke(interceptor);
}
else {
method.invoke(interceptor, out);
}
dumpTasks.add(out -> {
out.println("<<< " + instrumenter + ": " + interceptor.getClass().getName() + " says:");
try {
if (method.getParameterTypes().length == 0) {
method.invoke(interceptor);
}
catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException(e);
else {
method.invoke(interceptor, out);
}
out.println(">>>");
out.println();
}
catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException(e);
}
out.println(">>>");
out.println();
});
}
@@ -56,16 +56,13 @@ public class Preloader {
Method mainMethod = mainClass.getMethod("main", String[].class);
Runtime.getRuntime().addShutdownHook(
new Thread(new Runnable() {
@Override
public void run() {
if (options.measure) {
System.out.println();
System.out.println("=== Preloader's measurements: ");
System.out.format("Total time: %.3fs\n", (System.nanoTime() - startTime) / 1e9);
}
handler.done();
new Thread(() -> {
if (options.measure) {
System.out.println();
System.out.println("=== Preloader's measurements: ");
System.out.format("Total time: %.3fs\n", (System.nanoTime() - startTime) / 1e9);
}
handler.done();
})
);