Skip to content

Commit b28f7da

Browse files
Make sure private methods cannot be annotated (#377)
1 parent 9c71385 commit b28f7da

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

sdk-api-gen/src/main/java/dev/restate/sdk/gen/ElementConverter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ private Handler fromExecutableElement(ServiceType serviceType, ExecutableElement
162162
messager.printMessage(
163163
Diagnostic.Kind.ERROR, "You cannot annotate a static init as Restate method");
164164
}
165+
if (element.getModifiers().contains(Modifier.PRIVATE)) {
166+
messager.printMessage(Diagnostic.Kind.ERROR, "The annotated method is private");
167+
}
165168

166169
boolean isAnnotatedWithShared = element.getAnnotation(Shared.class) != null;
167170
boolean isAnnotatedWithExclusive = element.getAnnotation(Exclusive.class) != null;

sdk-api-kotlin-gen/src/main/kotlin/dev/restate/sdk/kotlin/gen/KElementConverter.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class KElementConverter(
135135
if (function.functionKind != FunctionKind.MEMBER) {
136136
logger.error("Only member function declarations are supported as Restate handlers")
137137
}
138+
if (function.getVisibility() == Visibility.PRIVATE) {
139+
logger.error("The annotated function is private", function)
140+
}
138141

139142
val isAnnotatedWithShared =
140143
function.isAnnotationPresent(dev.restate.sdk.annotation.Shared::class)

0 commit comments

Comments
 (0)