\latke\latke-core\src\main\java\org\b3log\latke\servlet\DispatcherServlet.java 中有如下代码,请问"writeReplace"这个是什么用法,为啥 clazz 会有"writeReplace"方法?
public Router handler(final ContextHandler handler) {
this.handler = handler;
final Class clazz = handler.getClass();
try {
final Serializable lambda = handler;
final Method m = clazz.getDeclaredMethod("writeReplace");
m.setAccessible(true);
final SerializedLambda sl = (SerializedLambda) m.invoke(lambda);
final String implClassName = sl.getImplClass().replaceAll("/", ".");
final Class<?> implClass = Class.forName(implClassName);
this.method = implClass.getDeclaredMethod(sl.getImplMethodName(), RequestContext.class);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Found lambda method reference impl method failed", e);
}
return this;
}