diff --git a/examples/java/echo/src/main/java/ftl/echo/Echo.java b/examples/java/echo/src/main/java/ftl/echo/Echo.java index 1339b91066..a73c468d53 100644 --- a/examples/java/echo/src/main/java/ftl/echo/Echo.java +++ b/examples/java/echo/src/main/java/ftl/echo/Echo.java @@ -9,7 +9,7 @@ public class Echo { @Export @Verb public EchoResponse echo(EchoRequest req, TimeClient time) { - var response = time.call(); + var response = time.time(); return new EchoResponse("Hello, " + req.name().orElse("anonymous") + "! The time is " + response.toString() + "."); } } diff --git a/examples/kotlin/echo/src/main/kotlin/ftl/echo/Echo.kt b/examples/kotlin/echo/src/main/kotlin/ftl/echo/Echo.kt index ecf114f4a9..6aaa36f1a4 100644 --- a/examples/kotlin/echo/src/main/kotlin/ftl/echo/Echo.kt +++ b/examples/kotlin/echo/src/main/kotlin/ftl/echo/Echo.kt @@ -10,6 +10,6 @@ data class EchoResponse(val message: String) @Export @Verb fun echo(req: EchoRequest, time: TimeClient): EchoResponse { - val response = time.call() + val response = time.time() return EchoResponse(message = "Hello, ${req.name ?: "anonymous"}! The time is ${response.time}.") } diff --git a/jvm-runtime/ftl-runtime/java/deployment/src/main/java/xyz/block/ftl/javalang/deployment/JavaCodeGenerator.java b/jvm-runtime/ftl-runtime/java/deployment/src/main/java/xyz/block/ftl/javalang/deployment/JavaCodeGenerator.java index bdf41c7ff8..a76e7aa63a 100644 --- a/jvm-runtime/ftl-runtime/java/deployment/src/main/java/xyz/block/ftl/javalang/deployment/JavaCodeGenerator.java +++ b/jvm-runtime/ftl-runtime/java/deployment/src/main/java/xyz/block/ftl/javalang/deployment/JavaCodeGenerator.java @@ -267,11 +267,16 @@ protected void generateDataObject(Module module, Data data, String packageName, protected void generateVerb(Module module, Verb verb, String packageName, Map typeAliasMap, Map nativeTypeAliasMap, Path outputDir) throws IOException { - TypeSpec.Builder clientBuilder = TypeSpec.interfaceBuilder(className(verb.getName()) + CLIENT) + String verbName = verb.getName(); + TypeSpec.Builder clientBuilder = TypeSpec.interfaceBuilder(className(verbName) + CLIENT) .addModifiers(Modifier.PUBLIC) - .addJavadoc("A client for the $L.$L verb", module.getName(), verb.getName()); + .addJavadoc("A client for the $L.$L verb", module.getName(), verbName); - MethodSpec.Builder callMethod = MethodSpec.methodBuilder(verb.getName()) + var methodName = verbName; + if (JAVA_KEYWORDS.contains(verbName)) { + methodName = verbName + "_"; + } + MethodSpec.Builder callMethod = MethodSpec.methodBuilder(methodName) .addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC) .addAnnotation(AnnotationSpec.builder(VerbClient.class) .addMember("module", "\"" + module.getName() + "\"")