This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new e65c3cabc0 Review "Fix covariant return type overrides of annotated
POJO ..."
e65c3cabc0 is described below
commit e65c3cabc06dfa3c1de253e058aac6c77b5a5edf
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 5 10:07:13 2026 +0000
Review "Fix covariant return type overrides of annotated POJO ..."
Simplify
Co-authored by: Claude / Sonnet 5.5
---
java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
b/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
index 93176ec939..ec1de64b66 100644
--- a/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
+++ b/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
@@ -204,14 +204,12 @@ public class PojoMethodMapping {
private boolean isMethodOverride(Method method1, Method method2) {
- // An overriding method may use a covariant return type so the return
- // types do not have to be equal. They do need to be compatible. The
- // methods may be passed in either order so both directions are
- // checked.
- Class<?> returnType1 = method1.getReturnType();
- Class<?> returnType2 = method2.getReturnType();
+ // The return type is deliberately not compared. An overriding method
may
+ // use a covariant return type and, within a single class hierarchy,
two
+ // methods with the same name and parameter types are override
+ // equivalent since the compiler does not permit them to differ only in
+ // return type unless one overrides the other.
return method1.getName().equals(method2.getName()) &&
- (returnType1.isAssignableFrom(returnType2) ||
returnType2.isAssignableFrom(returnType1)) &&
Arrays.equals(method1.getParameterTypes(),
method2.getParameterTypes());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]