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/incubator-fury.git
The following commit(s) were added to refs/heads/main by this push: new 09583c90 fix(java): fix illegal classname caused by negative hash (#1436) 09583c90 is described below commit 09583c90b674cc9341ea8492e43c9a4e67ad53d9 Author: Shawn Yang <shawn.ck.y...@gmail.com> AuthorDate: Sat Mar 30 22:00:00 2024 +0800 fix(java): fix illegal classname caused by negative hash (#1436) Closes #1433 Co-authored-by: chaokunyang <Woaini98> --- .../src/main/java/org/apache/fury/codegen/CodeGenerator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/java/fury-core/src/main/java/org/apache/fury/codegen/CodeGenerator.java b/java/fury-core/src/main/java/org/apache/fury/codegen/CodeGenerator.java index da3bc7e0..397ddca4 100644 --- a/java/fury-core/src/main/java/org/apache/fury/codegen/CodeGenerator.java +++ b/java/fury-core/src/main/java/org/apache/fury/codegen/CodeGenerator.java @@ -344,10 +344,12 @@ public class CodeGenerator { } // classLoader will be null for jdk classes. ClassLoader classLoader = cls.getClassLoader(); + // Hashcode may be negative in open-j9 jdk. While using `abs` to remove sign works fine too. + // it's still possible that hashCodes of two objects only differ in sign. if (classLoader == null) { - return String.valueOf(cls.hashCode()); + return String.valueOf(cls.hashCode()).replace("-", "_"); } else { - return String.format("%s_%s", classLoader.hashCode(), cls.hashCode()); + return String.format("%s_%s", classLoader.hashCode(), cls.hashCode()).replace("-", "_"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For additional commands, e-mail: commits-h...@fury.apache.org