From e897aec9a7f86191f8ac9fe6d7e9aea714dbeb30 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 | 8 ++++++-- 1 file changed, 6 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..bb93492f9e84a 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,12 @@ 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)) { + 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); }