From 6c704796747b48605972c9939e336d5f89ea10c0 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Fri, 29 Oct 2021 16:17:19 +1100 Subject: [PATCH] Disallow public final methods on recorders 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. --- .../java/io/quarkus/deployment/proxy/ProxyFactory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/proxy/ProxyFactory.java b/core/deployment/src/main/java/io/quarkus/deployment/proxy/ProxyFactory.java index f6e534ac2478b..f1c7514e1554b 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/proxy/ProxyFactory.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/proxy/ProxyFactory.java @@ -137,8 +137,13 @@ private void addMethodsOfClass(Class clazz, Set 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("")) { methods.add(methodInfo); }