diff --git a/content/doc/developer/extensibility/serialization-of-anonymous-classes.adoc b/content/doc/developer/extensibility/serialization-of-anonymous-classes.adoc index 787545a4fc5c..0cbff801f7f0 100644 --- a/content/doc/developer/extensibility/serialization-of-anonymous-classes.adoc +++ b/content/doc/developer/extensibility/serialization-of-anonymous-classes.adoc @@ -34,7 +34,7 @@ To fix code like this: int stuff(FilePath workspace, final String arg) throws IOException, InterruptedException { return workspace.act(new MasterToSlaveFileCallable() { @Override - Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { + public Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { return countThings(f, arg); } }); @@ -43,6 +43,21 @@ int stuff(FilePath workspace, final String arg) throws IOException, InterruptedE just use a "convert anonymous to member" refactoring in your IDE, or manually: +[source,java] +---- +private record ThingCounter(String arg) implements ControllerToAgentFileCallable { + @Override + public Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { + return countThings(f, arg); + } +} +int stuff(FilePath workspace, String arg) throws IOException, InterruptedException { + return workspace.act(new ThingCounter(arg)); +} +---- + +or prior to Jenkins 2.485: + [source,java] ---- private static final class ThingCounter extends MasterToSlaveFileCallable { @@ -51,7 +66,7 @@ private static final class ThingCounter extends MasterToSlaveFileCallable