Use Java 8 lambdas instead of anonymous classes in compiler modules
This commit is contained in:
+14
-21
@@ -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();
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user