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/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 431c91ca1 fix(java): fix extension java module conflict (#2456)
431c91ca1 is described below
commit 431c91ca1e2a2f0b38ec1cc46d38b624d33f73e6
Author: Shawn Yang <[email protected]>
AuthorDate: Mon Aug 11 16:20:14 2025 +0800
fix(java): fix extension java module conflict (#2456)
<!--
**Thanks for contributing to Fory.**
**If this is your first time opening a PR on fory, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory** community has requirements on the naming of pr
titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Fory has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->
## What does this PR do?
<!-- Describe the purpose of this PR. -->
## Related issues
<!--
Is there any related issue? Please attach here.
- #xxxx0
- #xxxx1
- #xxxx2
-->
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---
.../java/org/apache/fory/meta/ClassDefEncoder.java | 13 +++++---
.../fory/extension/meta/ZstdMetaCompressor.java | 3 +-
.../extension/serializer/ByteStringSerializer.java | 3 +-
.../fory/extension/meta/ClassDefEncoderTest.java | 4 ++-
.../serializer/ProtobufSerializerTest.java | 37 ++++++++++++++++++++++
5 files changed, 52 insertions(+), 8 deletions(-)
diff --git
a/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
b/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
index 53c6b0467..c75d7edaf 100644
--- a/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
+++ b/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
@@ -35,6 +35,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.apache.fory.Fory;
+import org.apache.fory.annotation.Internal;
import org.apache.fory.collection.Tuple2;
import org.apache.fory.memory.MemoryBuffer;
import org.apache.fory.memory.MemoryUtils;
@@ -51,7 +52,8 @@ import org.apache.fory.util.MurmurHash3;
* docs/specification/java_serialization_spec.md <a
*
href="https://fory.apache.org/docs/specification/fory_java_serialization_spec">...</a>
*/
-class ClassDefEncoder {
+@Internal
+public class ClassDefEncoder {
// a flag to mark a type is not struct.
static final int NUM_CLASS_THRESHOLD = 0b1111;
@@ -82,11 +84,11 @@ class ClassDefEncoder {
return fields;
}
- static List<FieldInfo> buildFieldsInfo(ClassResolver resolver, Class<?> cls)
{
+ public static List<FieldInfo> buildFieldsInfo(ClassResolver resolver,
Class<?> cls) {
return buildFieldsInfo(resolver, buildFields(resolver.getFory(), cls,
true));
}
- static List<FieldInfo> buildFieldsInfo(TypeResolver resolver, List<Field>
fields) {
+ public static List<FieldInfo> buildFieldsInfo(TypeResolver resolver,
List<Field> fields) {
List<FieldInfo> fieldInfos = new ArrayList<>();
for (Field field : fields) {
FieldInfo fieldInfo =
@@ -126,7 +128,7 @@ class ClassDefEncoder {
// see spec documentation: docs/specification/java_serialization_spec.md
// https://fory.apache.org/docs/specification/fory_java_serialization_spec
- static MemoryBuffer encodeClassDef(
+ public static MemoryBuffer encodeClassDef(
ClassResolver classResolver,
Class<?> type,
Map<String, List<FieldInfo>> classLayers,
@@ -217,7 +219,8 @@ class ClassDefEncoder {
String.format("Class %s doesn't have %s as super class", c, type));
}
- static Map<String, List<FieldInfo>> getClassFields(Class<?> type,
List<FieldInfo> fieldsInfo) {
+ public static Map<String, List<FieldInfo>> getClassFields(
+ Class<?> type, List<FieldInfo> fieldsInfo) {
Map<String, List<FieldInfo>> sortedClassFields = new LinkedHashMap<>();
if (fieldsInfo.isEmpty()) {
sortedClassFields.put(type.getName(), new ArrayList<>());
diff --git
a/java/fory-extensions/src/main/java/org/apache/fory/extension/meta/ZstdMetaCompressor.java
b/java/fory-extensions/src/main/java/org/apache/fory/extension/meta/ZstdMetaCompressor.java
index 28dbf3471..b5b41962d 100644
---
a/java/fory-extensions/src/main/java/org/apache/fory/extension/meta/ZstdMetaCompressor.java
+++
b/java/fory-extensions/src/main/java/org/apache/fory/extension/meta/ZstdMetaCompressor.java
@@ -17,11 +17,12 @@
* under the License.
*/
-package org.apache.fory.meta;
+package org.apache.fory.extension.meta;
import com.github.luben.zstd.Zstd;
import com.github.luben.zstd.ZstdException;
import java.util.Arrays;
+import org.apache.fory.meta.MetaCompressor;
public class ZstdMetaCompressor implements MetaCompressor {
diff --git
a/java/fory-extensions/src/main/java/org/apache/fory/extension/serializer/ByteStringSerializer.java
b/java/fory-extensions/src/main/java/org/apache/fory/extension/serializer/ByteStringSerializer.java
index f438a5ea4..601363a36 100644
---
a/java/fory-extensions/src/main/java/org/apache/fory/extension/serializer/ByteStringSerializer.java
+++
b/java/fory-extensions/src/main/java/org/apache/fory/extension/serializer/ByteStringSerializer.java
@@ -17,11 +17,12 @@
* under the License.
*/
-package org.apache.fory.serializer;
+package org.apache.fory.extension.serializer;
import com.google.protobuf.ByteString;
import org.apache.fory.Fory;
import org.apache.fory.memory.MemoryBuffer;
+import org.apache.fory.serializer.Serializer;
public class ByteStringSerializer extends Serializer<ByteString> {
public ByteStringSerializer(Fory fory, Class<ByteString> type) {
diff --git
a/java/fory-extensions/src/test/java/org/apache/fory/extension/meta/ClassDefEncoderTest.java
b/java/fory-extensions/src/test/java/org/apache/fory/extension/meta/ClassDefEncoderTest.java
index 16a2cca7d..104217060 100644
---
a/java/fory-extensions/src/test/java/org/apache/fory/extension/meta/ClassDefEncoderTest.java
+++
b/java/fory-extensions/src/test/java/org/apache/fory/extension/meta/ClassDefEncoderTest.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.fory.meta;
+package org.apache.fory.extension.meta;
import static org.apache.fory.meta.ClassDefEncoder.buildFieldsInfo;
import static org.apache.fory.meta.ClassDefEncoder.getClassFields;
@@ -25,6 +25,8 @@ import static
org.apache.fory.meta.ClassDefEncoder.getClassFields;
import java.util.List;
import org.apache.fory.Fory;
import org.apache.fory.memory.MemoryBuffer;
+import org.apache.fory.meta.ClassDef;
+import org.apache.fory.meta.ClassDefEncoder;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git
a/java/fory-extensions/src/test/java/org/apache/fory/extension/serializer/ProtobufSerializerTest.java
b/java/fory-extensions/src/test/java/org/apache/fory/extension/serializer/ProtobufSerializerTest.java
new file mode 100644
index 000000000..47b4f1e8d
--- /dev/null
+++
b/java/fory-extensions/src/test/java/org/apache/fory/extension/serializer/ProtobufSerializerTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fory.extension.serializer;
+
+import com.google.protobuf.ByteString;
+import org.apache.fory.Fory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class ProtobufSerializerTest {
+ @Test
+ public void testByteString() {
+ Fory fory = Fory.builder().requireClassRegistration(false).build();
+ Assert.assertEquals(fory.deserialize(fory.serialize(ByteString.empty())),
ByteString.empty());
+ ByteString bytes = ByteString.copyFrom(new byte[] {1, 2, 3});
+ Assert.assertEquals(fory.deserialize(fory.serialize(bytes)), bytes);
+ Class<?> serializerClass =
fory.getClassResolver().getSerializerClass(bytes.getClass());
+ Assert.assertEquals(serializerClass, ByteStringSerializer.class);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]