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 29, 2021
1 parent fa595c7 commit e897aec
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ 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)) {
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 e897aec

Please sign in to comment.