This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/main by this push:
new 7a1ee4c3 fix(java): descriptors for beans should not include static
methods (#2281)
7a1ee4c3 is described below
commit 7a1ee4c345da6e184ad834b8ed68beb0ef3d4c82
Author: Steven Schlansker <[email protected]>
AuthorDate: Mon Jun 2 17:56:50 2025 -0700
fix(java): descriptors for beans should not include static methods (#2281)
## What does this PR do?
Bean interface method descriptor discovery incorrectly includes static
methods like `static Builder builder()`
---
java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java | 4 +++-
.../java/org/apache/fory/format/encoder/ImplementInterfaceTest.java | 4 ++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java
b/java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java
index 22abee5e..a9cbe190 100644
--- a/java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java
+++ b/java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java
@@ -462,7 +462,9 @@ public class Descriptor {
}
if (clazz.isInterface()) {
for (Method method : clazz.getMethods()) {
- if (method.getParameterCount() == 0 && method.getReturnType() !=
void.class) {
+ if (method.getParameterCount() == 0
+ && method.getReturnType() != void.class
+ && !Modifier.isStatic(method.getModifiers())) {
descriptorMap.put(method, new Descriptor(method));
}
}
diff --git
a/java/fory-format/src/test/java/org/apache/fory/format/encoder/ImplementInterfaceTest.java
b/java/fory-format/src/test/java/org/apache/fory/format/encoder/ImplementInterfaceTest.java
index 9bbd73e5..df18bede 100644
---
a/java/fory-format/src/test/java/org/apache/fory/format/encoder/ImplementInterfaceTest.java
+++
b/java/fory-format/src/test/java/org/apache/fory/format/encoder/ImplementInterfaceTest.java
@@ -37,6 +37,10 @@ public class ImplementInterfaceTest {
NestedType getNested();
PoisonPill getPoison();
+
+ static PoisonPill builder() {
+ return new PoisonPill();
+ }
}
public interface NestedType {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]