Skip to content

Commit

Permalink
Disallow public final methods on recorders
Browse files Browse the repository at this point in the history
These can cause problems as the results silently won't be recorded.

This is potentially a breaking change, although I don't think it should
cause issues in practice, as there is no real use case for final public
recorder methods.
  • Loading branch information
stuartwdouglas committed Oct 30, 2021
1 parent c5ff4e9 commit 6c70479
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ private void addMethodsOfClass(Class<?> clazz, Set<MethodKey> seen) {
if (methodInfo.getName().equals("finalize") && methodInfo.getParameterCount() == 0) {
continue;
}
if (!Modifier.isStatic(methodInfo.getModifiers()) &&
!Modifier.isFinal(methodInfo.getModifiers()) &&
int modifiers = methodInfo.getModifiers();
if (Modifier.isPublic(modifiers) && Modifier.isFinal(modifiers) && !Modifier.isStatic(modifiers)
&& clazz != Object.class) {
throw new RuntimeException("Public method " + methodInfo + " cannot be proxied as it is final");
}
if (!Modifier.isStatic(modifiers) &&
!Modifier.isFinal(modifiers) &&
!methodInfo.getName().equals("<init>")) {
methods.add(methodInfo);
}
Expand Down

0 comments on commit 6c70479

Please sign in to comment.