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-site.git
The following commit(s) were added to refs/heads/main by this push:
new f48e9655b1 π synced local 'docs/guide/' with remote 'docs/guide/'
f48e9655b1 is described below
commit f48e9655b1fb98e19ae928e4def67659fa6cbe29
Author: chaokunyang <[email protected]>
AuthorDate: Wed May 6 08:01:42 2026 +0000
π synced local 'docs/guide/' with remote 'docs/guide/'
---
docs/guide/cpp/basic-serialization.md | 4 ++--
docs/guide/cpp/configuration.md | 8 ++++----
docs/guide/cpp/cross-language.md | 8 ++++----
docs/guide/cpp/custom-serializers.md | 4 ++--
docs/guide/cpp/index.md | 6 +++---
docs/guide/cpp/schema-evolution.md | 8 ++++----
docs/guide/cpp/type-registration.md | 10 +++++-----
docs/guide/csharp/cross-language.md | 4 ++--
docs/guide/dart/configuration.md | 4 ++--
docs/guide/dart/cross-language.md | 4 ++--
docs/guide/dart/schema-evolution.md | 4 ++--
docs/guide/dart/troubleshooting.md | 4 ++--
docs/guide/go/configuration.md | 2 +-
docs/guide/go/cross-language.md | 18 +++++++++---------
docs/guide/java/cross-language.md | 8 ++++----
docs/guide/java/schema-evolution.md | 8 +++++---
docs/guide/java/troubleshooting.md | 2 +-
docs/guide/javascript/schema-evolution.md | 4 ++--
docs/guide/javascript/troubleshooting.md | 2 +-
docs/guide/python/basic-serialization.md | 2 +-
docs/guide/python/configuration.md | 28 ++++++++++++++--------------
docs/guide/python/cross-language.md | 8 ++++----
docs/guide/python/troubleshooting.md | 2 +-
docs/guide/rust/configuration.md | 15 ++++++++++++---
docs/guide/rust/cross-language.md | 4 ++--
docs/guide/swift/configuration.md | 14 +++++++-------
docs/guide/swift/cross-language.md | 4 ++--
docs/guide/swift/references.md | 6 +++---
docs/guide/swift/schema-evolution.md | 2 +-
docs/guide/xlang/field-nullability.md | 6 +++---
docs/guide/xlang/field-reference-tracking.md | 12 ++++++------
docs/guide/xlang/getting-started.md | 22 ++++++++++++----------
docs/guide/xlang/index.md | 4 ++--
docs/guide/xlang/serialization.md | 22 +++++++++++-----------
docs/guide/xlang/troubleshooting.md | 28 +++++++++++++++++++++++++---
docs/guide/xlang/zero-copy.md | 6 +++---
36 files changed, 166 insertions(+), 131 deletions(-)
diff --git a/docs/guide/cpp/basic-serialization.md
b/docs/guide/cpp/basic-serialization.md
index d8b3ebcb57..630b68388c 100644
--- a/docs/guide/cpp/basic-serialization.md
+++ b/docs/guide/cpp/basic-serialization.md
@@ -70,7 +70,7 @@ struct Person {
FORY_STRUCT(Person, name, age, address, hobbies, metadata);
int main() {
- auto fory = Fory::builder().xlang(true).build();
+ auto fory = Fory::builder().xlang(true).compatible(true).build();
fory.register_struct<Address>(100);
fory.register_struct<Person>(200);
@@ -93,7 +93,7 @@ int main() {
### Serialize to New Vector
```cpp
-auto fory = Fory::builder().xlang(true).build();
+auto fory = Fory::builder().xlang(true).compatible(true).build();
fory.register_struct<MyStruct>(1);
MyStruct obj{/* ... */};
diff --git a/docs/guide/cpp/configuration.md b/docs/guide/cpp/configuration.md
index 5dd106ea26..0c73995a7c 100644
--- a/docs/guide/cpp/configuration.md
+++ b/docs/guide/cpp/configuration.md
@@ -60,7 +60,7 @@ auto fory = Fory::builder()
// Cross-language mode
auto fory = Fory::builder()
- .xlang(true)
+ .xlang(true).compatible(true)
.build();
// Full configuration
@@ -81,7 +81,7 @@ Enable/disable cross-language (xlang) serialization mode.
```cpp
auto fory = Fory::builder()
- .xlang(true) // Enable cross-language compatibility
+ .xlang(true).compatible(true) // Enable cross-language compatibility
.build();
```
@@ -156,7 +156,7 @@ When enabled, validates type hashes to detect schema
mismatches.
```cpp
auto fory = Fory::builder()
- .xlang(true)
+ .xlang(true).compatible(true)
.build(); // Returns Fory
```
@@ -166,7 +166,7 @@ Single-threaded `Fory` is the fastest option, but NOT
thread-safe. Use one insta
```cpp
auto fory = Fory::builder()
- .xlang(true)
+ .xlang(true).compatible(true)
.build_thread_safe(); // Returns ThreadSafeFory
```
diff --git a/docs/guide/cpp/cross-language.md b/docs/guide/cpp/cross-language.md
index b4d05f4757..c54b197e28 100644
--- a/docs/guide/cpp/cross-language.md
+++ b/docs/guide/cpp/cross-language.md
@@ -33,7 +33,7 @@ Apache Foryβ’ enables seamless data exchange between C++,
Java, Python, Go, Rus
using namespace fory::serialization;
auto fory = Fory::builder()
- .xlang(true) // Enable cross-language mode
+ .xlang(true).compatible(true) // Enable cross-language mode
.build();
```
@@ -61,7 +61,7 @@ struct Message {
FORY_STRUCT(Message, topic, timestamp, headers, payload);
int main() {
- auto fory = Fory::builder().xlang(true).build();
+ auto fory = Fory::builder().xlang(true).compatible(true).build();
fory.register_struct<Message>(100);
Message msg{
@@ -97,7 +97,7 @@ public class Message {
public class Consumer {
public static void main(String[] args) throws Exception {
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.build();
fory.register(Message.class, 100); // Same ID as C++
@@ -121,7 +121,7 @@ class Message:
headers: dict[str, str]
payload: bytes
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register(Message, type_id=100) # Same ID as C++
with open("message.bin", "rb") as f:
diff --git a/docs/guide/cpp/custom-serializers.md
b/docs/guide/cpp/custom-serializers.md
index 478b4e899e..9e013ac556 100644
--- a/docs/guide/cpp/custom-serializers.md
+++ b/docs/guide/cpp/custom-serializers.md
@@ -146,7 +146,7 @@ The `type_id` constant should be set to `TypeId::EXT` for
custom extension types
Register your custom serializer with Fory before use:
```cpp
-auto fory = Fory::builder().xlang(true).build();
+auto fory = Fory::builder().xlang(true).compatible(true).build();
// Register with numeric type ID (must match across languages)
auto result = fory.register_extension_type<MyExt>(103);
@@ -255,7 +255,7 @@ struct Serializer<CustomType> {
} // namespace fory
int main() {
- auto fory = Fory::builder().xlang(true).build();
+ auto fory = Fory::builder().xlang(true).compatible(true).build();
fory.register_extension_type<CustomType>(100);
CustomType original{42, "test"};
diff --git a/docs/guide/cpp/index.md b/docs/guide/cpp/index.md
index 193cb7a8b5..a87f0a5d82 100644
--- a/docs/guide/cpp/index.md
+++ b/docs/guide/cpp/index.md
@@ -157,7 +157,7 @@ FORY_STRUCT(Person, name, age, hobbies);
int main() {
// Create a Fory instance
auto fory = Fory::builder()
- .xlang(true) // Enable cross-language mode
+ .xlang(true).compatible(true) // Enable cross-language mode
.track_ref(false) // Disable reference tracking for simple types
.build();
@@ -215,7 +215,7 @@ Apache Foryβ’ C++ provides two variants for different
threading needs:
```cpp
// Single-threaded Fory - fastest, NOT thread-safe
auto fory = Fory::builder()
- .xlang(true)
+ .xlang(true).compatible(true)
.build();
```
@@ -224,7 +224,7 @@ auto fory = Fory::builder()
```cpp
// Thread-safe Fory - uses context pools
auto fory = Fory::builder()
- .xlang(true)
+ .xlang(true).compatible(true)
.build_thread_safe();
// Can be used from multiple threads safely
diff --git a/docs/guide/cpp/schema-evolution.md
b/docs/guide/cpp/schema-evolution.md
index b91441521a..9369c1d6c0 100644
--- a/docs/guide/cpp/schema-evolution.md
+++ b/docs/guide/cpp/schema-evolution.md
@@ -292,15 +292,15 @@ When fields are missing, C++ default initialization is
used:
| `std::optional<T>` | `std::nullopt` |
| Struct types | Default-constructed |
-## Schema Consistent Mode (Default)
+## Schema Consistent Mode
-Without compatible mode, schemas must match exactly:
+Without compatible mode, schemas must match exactly. In xlang mode, compatible
mode is the default, so disable it explicitly only when schemas do not change
or all services deploy schema changes at the same time:
```cpp
-// Strict mode (default)
+// Strict schema-consistent mode
auto fory = Fory::builder()
- .compatible(false) // Default: schema must match
.xlang(true)
+ .compatible(false)
.build();
// Serialization/deserialization requires identical schemas
diff --git a/docs/guide/cpp/type-registration.md
b/docs/guide/cpp/type-registration.md
index 4b77f80955..9e9a34350e 100644
--- a/docs/guide/cpp/type-registration.md
+++ b/docs/guide/cpp/type-registration.md
@@ -45,7 +45,7 @@ struct Person {
FORY_STRUCT(Person, name, age);
int main() {
- auto fory = Fory::builder().xlang(true).build();
+ auto fory = Fory::builder().xlang(true).compatible(true).build();
// Register with a unique type ID
fory.register_struct<Person>(100);
@@ -112,7 +112,7 @@ fory.register_enum<LegacyStatus>(2);
For `ThreadSafeFory`, register types before spawning threads:
```cpp
-auto fory = Fory::builder().xlang(true).build_thread_safe();
+auto fory = Fory::builder().xlang(true).compatible(true).build_thread_safe();
// Register all types first
fory.register_struct<TypeA>(100);
@@ -137,7 +137,7 @@ For cross-language compatibility, ensure:
### Java
```java
-Fory fory = Fory.builder().withXlang(true).build();
+Fory fory = Fory.builder().withXlang(true).withCompatible(true).build();
fory.register(Person.class, 100);
fory.register(Address.class, 101);
```
@@ -147,7 +147,7 @@ fory.register(Address.class, 101);
```python
import pyfory
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register(Person, type_id=100)
fory.register(Address, type_id=101)
```
@@ -155,7 +155,7 @@ fory.register(Address, type_id=101)
### C++
```cpp
-auto fory = Fory::builder().xlang(true).build();
+auto fory = Fory::builder().xlang(true).compatible(true).build();
fory.register_struct<Person>(100);
fory.register_struct<Address>(101);
```
diff --git a/docs/guide/csharp/cross-language.md
b/docs/guide/csharp/cross-language.md
index c712ed0c32..4598bd23fb 100644
--- a/docs/guide/csharp/cross-language.md
+++ b/docs/guide/csharp/cross-language.md
@@ -71,7 +71,7 @@ byte[] payload = fory.Serialize(person);
```java
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
@@ -84,7 +84,7 @@ Person value = (Person) fory.deserialize(payloadFromCSharp);
```python
import pyfory
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
fory.register_type(Person, type_id=100)
value = fory.deserialize(payload_from_csharp)
```
diff --git a/docs/guide/dart/configuration.md b/docs/guide/dart/configuration.md
index 2cd0a94c46..46d87556d3 100644
--- a/docs/guide/dart/configuration.md
+++ b/docs/guide/dart/configuration.md
@@ -55,9 +55,9 @@ When `compatible: true`:
- Adding or removing fields on one side does not break the other.
- Peers must still use the same `namespace` + `typeName` (or numeric `id`) to
identify types.
-When `compatible: false` (default):
+When `compatible: false`:
-- Both sides must have exactly the same schema. This is slightly faster and is
fine when you deploy Dart-only services or always update all sides together.
+- Both sides must have exactly the same schema. This is slightly faster and is
fine when schemas do not change or all services deploy schema changes at the
same time.
### `checkStructVersion`
diff --git a/docs/guide/dart/cross-language.md
b/docs/guide/dart/cross-language.md
index 843e0cf38d..077a771dbb 100644
--- a/docs/guide/dart/cross-language.md
+++ b/docs/guide/dart/cross-language.md
@@ -90,7 +90,7 @@ final bytes = fory.serialize(Person()
```java
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.build();
fory.register(Person.class, 100);
@@ -147,7 +147,7 @@ type Person struct {
Age int32
}
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
_ = f.RegisterStruct(Person{}, 100)
var person Person
diff --git a/docs/guide/dart/schema-evolution.md
b/docs/guide/dart/schema-evolution.md
index 1afbbdeb4f..81b4a8a36c 100644
--- a/docs/guide/dart/schema-evolution.md
+++ b/docs/guide/dart/schema-evolution.md
@@ -33,12 +33,12 @@ final fory = Fory(compatible: true);
In compatible mode, Fory includes enough field metadata in each message so
that the reader can skip unknown fields and use defaults for missing ones. Use
stable field IDs (see below) to anchor the schema across changes.
-### Schema-Consistent Mode (default)
+### Schema-Consistent Mode
Both sides must have the same model. Fory validates that the schemas match and
will reject messages from a different schema version. Use this when all
services are always updated together and you want schema mismatches to be
caught as fast errors.
```dart
-final fory = Fory(); // compatible: false by default
+final fory = Fory(compatible: false);
```
## Setting Up for Evolution
diff --git a/docs/guide/dart/troubleshooting.md
b/docs/guide/dart/troubleshooting.md
index 3938e95a5a..cc5b295b8a 100644
--- a/docs/guide/dart/troubleshooting.md
+++ b/docs/guide/dart/troubleshooting.md
@@ -25,8 +25,8 @@ This page covers common Dart runtime issues and fixes.
The writer is sending a native-mode (non-xlang) payload. Make sure every
service uses the xlang-compatible path:
-- **Java**: add `.withXlang(true)` to the Fory builder.
-- **Go**: use `WithXlang(true)` in the Fory options.
+- **Java**: add `.withXlang(true).withCompatible(true)` to the Fory builder.
+- **Go**: use `WithXlang(true), WithCompatible(true)` in the Fory options.
- **Other runtimes**: check their respective guides for enabling
cross-language mode.
## `Type ... is not registered.`
diff --git a/docs/guide/go/configuration.md b/docs/guide/go/configuration.md
index 848fda7f2b..5b428008da 100644
--- a/docs/guide/go/configuration.md
+++ b/docs/guide/go/configuration.md
@@ -123,7 +123,7 @@ f := fory.New(fory.WithMaxDepth(30))
Enable cross-language serialization mode:
```go
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
```
**When enabled:**
diff --git a/docs/guide/go/cross-language.md b/docs/guide/go/cross-language.md
index 44d2e56543..7a4403f4b7 100644
--- a/docs/guide/go/cross-language.md
+++ b/docs/guide/go/cross-language.md
@@ -26,7 +26,7 @@ Fory Go enables seamless data exchange with Java, Python,
C++, Rust, and JavaScr
Cross-language (xlang) mode must be explicitly enabled:
```go
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
```
## Type Registration for Cross-Language
@@ -41,7 +41,7 @@ type User struct {
Name string
}
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
f.RegisterStruct(User{}, 1)
data, _ := f.Serialize(&User{ID: 1, Name: "Alice"})
```
@@ -53,7 +53,7 @@ public class User {
public long id;
public String name;
}
-Fory fory = Fory.builder().withXlang(true).build();
+Fory fory = Fory.builder().withXlang(true).withCompatible(true).build();
fory.register(User.class, 1);
User user = fory.deserialize(data, User.class);
```
@@ -69,7 +69,7 @@ class User:
id: pyfory.Int64
name: str
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register(User, type_id=1)
user = fory.deserialize(data)
```
@@ -118,7 +118,7 @@ type Order struct {
Items []string
}
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
f.RegisterStruct(Order{}, 1)
order := &Order{
@@ -141,7 +141,7 @@ public class Order {
public List<String> items;
}
-Fory fory = Fory.builder().withXlang(true).build();
+Fory fory = Fory.builder().withXlang(true).withCompatible(true).build();
fory.register(Order.class, 1);
Order order = fory.deserialize(data, Order.class);
@@ -161,7 +161,7 @@ class Message:
content: str
timestamp: pyfory.Int64
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register(Message, type_id=1)
msg = Message(id=1, content="Hello from Python", timestamp=1234567890)
@@ -177,7 +177,7 @@ type Message struct {
Timestamp int64
}
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
f.RegisterStruct(Message{}, 1)
var msg Message
@@ -226,7 +226,7 @@ type Company struct {
Address Address
}
-f := fory.New(fory.WithXlang(true))
+f := fory.New(fory.WithXlang(true), fory.WithCompatible(true))
f.RegisterStruct(Address{}, 1)
f.RegisterStruct(Company{}, 2)
```
diff --git a/docs/guide/java/cross-language.md
b/docs/guide/java/cross-language.md
index 5be83ce9a9..3f43f3a278 100644
--- a/docs/guide/java/cross-language.md
+++ b/docs/guide/java/cross-language.md
@@ -31,7 +31,7 @@ import org.apache.fory.config.*;
// Create Fory instance with XLANG mode
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true) // Enable reference tracking for complex graphs
.build();
```
@@ -85,7 +85,7 @@ public record Person(String name, int age) {}
public class Example {
public static void main(String[] args) {
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
@@ -112,7 +112,7 @@ class Person:
age: pyfory.Int32
# Create Fory in xlang mode
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
# Register with the SAME name as Java
fory.register_type(Person, typename="example.Person")
@@ -134,7 +134,7 @@ public class Node {
}
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true) // Required for circular references
.build();
diff --git a/docs/guide/java/schema-evolution.md
b/docs/guide/java/schema-evolution.md
index 8ae9b8ccc7..d2db111388 100644
--- a/docs/guide/java/schema-evolution.md
+++ b/docs/guide/java/schema-evolution.md
@@ -25,13 +25,15 @@ This page covers schema evolution, meta sharing, and
handling non-existent/unkno
In many systems, the schema of a class used for serialization may change over
time. For instance, fields within a class may be added or removed. When
serialization and deserialization processes use different versions of jars, the
schema of the class being deserialized may differ from the one used during
serialization.
-### Default Mode: Schema Consistent
+### Default Mode
-By default, Fory serializes objects using schema-consistent mode. This mode
assumes that the deserialization process uses the same class schema as the
serialization process, minimizing payload overhead. However, if there is a
schema inconsistency, deserialization will fail.
+In Java-native mode (`xlang=false`), Fory serializes objects using
schema-consistent mode by default. This mode assumes that the deserialization
process uses the same class schema as the serialization process, minimizing
payload overhead. However, if there is a schema inconsistency, deserialization
will fail.
+
+In cross-language mode (`xlang=true`), Fory defaults to compatible mode
because schemas can diverge more easily across independently deployed services
and language implementations.
### Compatible Mode
-If the schema is expected to change, to make deserialization succeed (i.e.,
schema forward/backward compatibility), users must configure Fory with
`ForyBuilder#withCompatible(true)`.
+If the schema is expected to change, to make deserialization succeed (i.e.,
schema forward/backward compatibility), users must configure Fory with
`ForyBuilder#withCompatible(true)`. Cross-language mode already uses this
setting by default; it is still recommended to set it explicitly in examples
and service configuration.
In this compatible mode, deserialization can handle schema changes such as
missing or extra fields, allowing it to succeed even when the serialization and
deserialization processes have different class schemas.
diff --git a/docs/guide/java/troubleshooting.md
b/docs/guide/java/troubleshooting.md
index d46d66c5bc..6734997774 100644
--- a/docs/guide/java/troubleshooting.md
+++ b/docs/guide/java/troubleshooting.md
@@ -41,7 +41,7 @@ Fory fory = Fory.builder()
.build();
```
-**Note**: compatible mode has more performance and space cost. Do not set it
by default if your classes are always consistent between serialization and
deserialization.
+**Note**: compatible mode has more performance and space cost. For xlang mode
it is the default and recommended setting. Use schema-consistent mode only if
your classes are always consistent between serialization and deserialization,
or if all services deploy schema changes at the same time.
## Using Wrong API for Deserialization
diff --git a/docs/guide/javascript/schema-evolution.md
b/docs/guide/javascript/schema-evolution.md
index 4387e7cc3d..e46414a53e 100644
--- a/docs/guide/javascript/schema-evolution.md
+++ b/docs/guide/javascript/schema-evolution.md
@@ -23,8 +23,8 @@ Schema evolution lets different versions of your service
exchange messages safel
## Two Modes
-- **Schema-consistent mode** (default): more compact, but both sides must have
exactly the same schema. Good when all services update together.
-- **Compatible mode**: writes extra field metadata so readers can skip unknown
fields and tolerate missing ones. Good for independent deployments or rolling
upgrades.
+- **Compatible mode** (default): writes extra field metadata so readers can
skip unknown fields and tolerate missing ones. Good for independent
deployments, rolling upgrades, and xlang services.
+- **Schema-consistent mode**: more compact, but both sides must have exactly
the same schema. Use it only when schemas do not change, or when all services
update together.
## Enable Compatible Mode
diff --git a/docs/guide/javascript/troubleshooting.md
b/docs/guide/javascript/troubleshooting.md
index aa77c7fe80..624591adec 100644
--- a/docs/guide/javascript/troubleshooting.md
+++ b/docs/guide/javascript/troubleshooting.md
@@ -25,7 +25,7 @@ This page covers common problems when using Fory JavaScript.
The Fory JavaScript runtime only reads Fory cross-language payloads. If the
producer is a Java or Go service using a language-native format, the JavaScript
side cannot decode it.
-Fix: switch the producer to the cross-language mode. For Java, use
`.withXlang(true)`; for Go, use `WithXlang(true)`.
+Fix: switch the producer to the cross-language mode. For Java, use
`.withXlang(true).withCompatible(true)`; for Go, use `WithXlang(true),
WithCompatible(true)`.
## `maxDepth must be an integer >= 2`
diff --git a/docs/guide/python/basic-serialization.md
b/docs/guide/python/basic-serialization.md
index 57a510f0fa..5350453779 100644
--- a/docs/guide/python/basic-serialization.md
+++ b/docs/guide/python/basic-serialization.md
@@ -29,7 +29,7 @@ Serialize and deserialize Python objects with a simple API:
import pyfory
# Create Fory instance
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
# Serialize any Python object
data = fory.dumps({"name": "Alice", "age": 30, "scores": [95, 87, 92]})
diff --git a/docs/guide/python/configuration.md
b/docs/guide/python/configuration.md
index 1c45ab4761..b8ae54f8a5 100644
--- a/docs/guide/python/configuration.md
+++ b/docs/guide/python/configuration.md
@@ -87,17 +87,17 @@ fory.register(MyClass, typename="my.package.MyClass",
serializer=custom_serializ
## Language Modes Comparison
-| Feature | Python Mode (`xlang=False`) |
Cross-Language Mode (`xlang=True`) |
-| --------------------- | ------------------------------------ |
------------------------------------- |
-| **Use Case** | Pure Python applications |
Multi-language systems |
-| **Compatibility** | Python only | Java, Go,
Rust, C++, JavaScript, etc. |
-| **Supported Types** | All Python types |
Cross-language compatible types only |
-| **Functions/Lambdas** | β Supported | β Not allowed
|
-| **Local Classes** | β Supported | β Not allowed
|
-| **Dynamic Classes** | β Supported | β Not allowed
|
-| **Schema Evolution** | β Supported (with `compatible=True`) | β Supported
(with `compatible=True`) |
-| **Performance** | Extremely fast | Very fast
|
-| **Data Size** | Compact | Compact with
type metadata |
+| Feature | Python Mode (`xlang=False`) |
Cross-Language Mode (`xlang=True, compatible=True`) |
+| --------------------- | ------------------------------------ |
--------------------------------------------------- |
+| **Use Case** | Pure Python applications |
Multi-language systems |
+| **Compatibility** | Python only | Java, Go,
Rust, C++, JavaScript, etc. |
+| **Supported Types** | All Python types |
Cross-language compatible types only |
+| **Functions/Lambdas** | β Supported | β Not allowed
|
+| **Local Classes** | β Supported | β Not allowed
|
+| **Dynamic Classes** | β Supported | β Not allowed
|
+| **Schema Evolution** | β Supported (with `compatible=True`) | β Supported
(with `compatible=True`) |
+| **Performance** | Extremely fast | Very fast
|
+| **Data Size** | Compact | Compact with
type metadata |
## Python Mode (`xlang=False`)
@@ -123,7 +123,7 @@ obj = [1, 2, {"nested": [3, 4]}]
assert fory.loads(fory.dumps(obj)) == pickle.loads(pickle.dumps(obj))
```
-## Cross-Language Mode (`xlang=True`)
+## Cross-Language Mode (`xlang=True, compatible=True`)
Cross-language mode restricts types to those compatible across all Fory
implementations:
@@ -131,7 +131,7 @@ Cross-language mode restricts types to those compatible
across all Fory implemen
import pyfory
# Cross-language compatibility mode
-f = pyfory.Fory(xlang=True, ref=True)
+f = pyfory.Fory(xlang=True, compatible=True, ref=True)
# Only supports cross-language compatible types
f.register(MyDataClass, typename="com.example.MyDataClass")
@@ -152,7 +152,7 @@ fory = pyfory.Fory(
xlang=False, # Use True if you need cross-language support
ref=False, # Enable if you have shared/circular references
strict=True, # CRITICAL: Always True in production
- compatible=False, # Enable only if you need schema evolution
+ compatible=False, # Native mode; xlang=True defaults to compatible=True
max_depth=20 # Adjust based on your data structure depth
)
diff --git a/docs/guide/python/cross-language.md
b/docs/guide/python/cross-language.md
index 8b857f44e5..0022958245 100644
--- a/docs/guide/python/cross-language.md
+++ b/docs/guide/python/cross-language.md
@@ -23,11 +23,11 @@ license: |
## Enable Cross-Language Mode
-To use xlang mode, create `Fory` with `xlang=True`:
+To use xlang mode, create `Fory` with `xlang=True, compatible=True`:
```python
import pyfory
-fory = pyfory.Fory(xlang=True, ref=False, strict=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=False, strict=True)
```
## Cross-Language Example
@@ -39,7 +39,7 @@ import pyfory
from dataclasses import dataclass
# Cross-language mode for interoperability
-f = pyfory.Fory(xlang=True, ref=True)
+f = pyfory.Fory(xlang=True, compatible=True, ref=True)
# Register type for cross-language compatibility
@dataclass
@@ -65,7 +65,7 @@ public class Person {
}
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
diff --git a/docs/guide/python/troubleshooting.md
b/docs/guide/python/troubleshooting.md
index 8e6a5d1615..168927fe8a 100644
--- a/docs/guide/python/troubleshooting.md
+++ b/docs/guide/python/troubleshooting.md
@@ -48,7 +48,7 @@ print(pyfory.ENABLE_FORY_CYTHON_SERIALIZATION) # Should be
True
```python
# Use explicit type registration with consistent naming
-f = pyfory.Fory(xlang=True)
+f = pyfory.Fory(xlang=True, compatible=True)
f.register(MyClass, typename="com.package.MyClass") # Use same name in all
languages
```
diff --git a/docs/guide/rust/configuration.md b/docs/guide/rust/configuration.md
index dd6435ee39..c405894fab 100644
--- a/docs/guide/rust/configuration.md
+++ b/docs/guide/rust/configuration.md
@@ -25,17 +25,26 @@ This page covers Fory configuration options and
serialization modes.
Apache Foryβ’ supports two serialization modes:
-### SchemaConsistent Mode (Default)
+### Compatible Mode (xlang default)
+
+Compatible mode is recommended for cross-language services because schemas can
diverge more
+easily across languages:
+
+```rust
+let fory = Fory::builder().xlang(true).compatible(true).build();
+```
+
+### SchemaConsistent Mode
Type declarations must match exactly between peers:
```rust
-let fory = Fory::default(); // SchemaConsistent by default
+let fory = Fory::builder().xlang(true).compatible(false).build();
```
### Compatible Mode
-Allows independent schema evolution:
+For native Rust-only payloads, compatible mode is still explicit:
```rust
let fory = Fory::builder().compatible(true).build();
diff --git a/docs/guide/rust/cross-language.md
b/docs/guide/rust/cross-language.md
index c067f1315b..b95e1741bf 100644
--- a/docs/guide/rust/cross-language.md
+++ b/docs/guide/rust/cross-language.md
@@ -101,7 +101,7 @@ public class Person {
}
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
@@ -121,7 +121,7 @@ class Person:
name: str
age: pyfory.Int32
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
fory.register_type(Person, type_id=100) # Same ID as Rust
person = fory.deserialize(bytes_from_rust)
diff --git a/docs/guide/swift/configuration.md
b/docs/guide/swift/configuration.md
index 0e464807ac..8a1b9d7ae9 100644
--- a/docs/guide/swift/configuration.md
+++ b/docs/guide/swift/configuration.md
@@ -36,7 +36,7 @@ public struct ForyConfig {
Default configuration:
```swift
-let fory = Fory() // xlang=true, trackRef=false, compatible=false
+let fory = Fory() // xlang=true, ref=false, compatible=true
```
## Threading
@@ -54,7 +54,7 @@ Controls cross-language protocol mode.
- `false`: Use Swift-native mode
```swift
-let fory = Fory(xlang: true)
+let fory = Fory(xlang: true, compatible: true)
```
### `trackRef`
@@ -65,7 +65,7 @@ Enables shared/circular reference tracking for
reference-trackable types.
- `true`: Preserve object identity for class/reference graphs
```swift
-let fory = Fory(xlang: true, trackRef: true)
+let fory = Fory(xlang: true, ref: true, compatible: true)
```
### `compatible`
@@ -76,7 +76,7 @@ Enables compatible schema mode for evolution across versions.
- `true`: Compatible mode (supports add/remove/reorder fields)
```swift
-let fory = Fory(xlang: true, trackRef: false, compatible: true)
+let fory = Fory(xlang: true, ref: false, compatible: true)
```
## Recommended Presets
@@ -84,17 +84,17 @@ let fory = Fory(xlang: true, trackRef: false, compatible:
true)
### Local, strict schema
```swift
-let fory = Fory(xlang: false, trackRef: false, compatible: false)
+let fory = Fory(xlang: false, ref: false, compatible: false)
```
### Cross-language service payloads
```swift
-let fory = Fory(xlang: true, trackRef: false, compatible: true)
+let fory = Fory(xlang: true, ref: false, compatible: true)
```
### Graph/object identity workloads
```swift
-let fory = Fory(xlang: true, trackRef: true, compatible: true)
+let fory = Fory(xlang: true, ref: true, compatible: true)
```
diff --git a/docs/guide/swift/cross-language.md
b/docs/guide/swift/cross-language.md
index 8d32c60523..441276624b 100644
--- a/docs/guide/swift/cross-language.md
+++ b/docs/guide/swift/cross-language.md
@@ -24,7 +24,7 @@ Fory Swift can exchange payloads with other Fory runtimes
using the xlang protoc
## Recommended Cross-language Configuration
```swift
-let fory = Fory(xlang: true, trackRef: false, compatible: true)
+let fory = Fory(xlang: true, ref: false, compatible: true)
```
## Register Types with Shared Identity
@@ -95,7 +95,7 @@ Generated Swift code includes:
Use generated registration before cross-language serialization:
```swift
-let fory = Fory(xlang: true, trackRef: true, compatible: true)
+let fory = Fory(xlang: true, ref: true, compatible: true)
try Addressbook.ForyRegistration.register(fory)
let payload = try fory.serialize(book)
diff --git a/docs/guide/swift/references.md b/docs/guide/swift/references.md
index fa4206ef66..edf62216ce 100644
--- a/docs/guide/swift/references.md
+++ b/docs/guide/swift/references.md
@@ -24,7 +24,7 @@ Swift reference tracking is controlled by
`ForyConfig.trackRef`.
## Enable Reference Tracking
```swift
-let fory = Fory(xlang: true, trackRef: true, compatible: false)
+let fory = Fory(xlang: true, ref: true, compatible: false)
```
When enabled, reference-trackable types preserve identity and cycles.
@@ -58,7 +58,7 @@ final class AnimalPair {
}
}
-let fory = Fory(xlang: true, trackRef: true)
+let fory = Fory(xlang: true, ref: true, compatible: true)
fory.register(Animal.self, id: 200)
fory.register(AnimalPair.self, id: 201)
@@ -92,7 +92,7 @@ final class Node {
}
}
-let fory = Fory(xlang: true, trackRef: true)
+let fory = Fory(xlang: true, ref: true, compatible: true)
fory.register(Node.self, id: 300)
let node = Node(value: 7)
diff --git a/docs/guide/swift/schema-evolution.md
b/docs/guide/swift/schema-evolution.md
index be70d12143..c7ccad1f8a 100644
--- a/docs/guide/swift/schema-evolution.md
+++ b/docs/guide/swift/schema-evolution.md
@@ -24,7 +24,7 @@ Fory supports schema evolution through compatible mode.
## Enable Compatible Mode
```swift
-let fory = Fory(xlang: true, trackRef: false, compatible: true)
+let fory = Fory(xlang: true, ref: false, compatible: true)
```
## Example: Evolving a Struct
diff --git a/docs/guide/xlang/field-nullability.md
b/docs/guide/xlang/field-nullability.md
index 5740344714..fc8d3736c9 100644
--- a/docs/guide/xlang/field-nullability.md
+++ b/docs/guide/xlang/field-nullability.md
@@ -107,7 +107,7 @@ public class Person {
}
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.build();
fory.register(Person.class, "example.Person");
```
@@ -130,7 +130,7 @@ class Person:
nickname: Optional[str] = None # Can be None
bio: Optional[str] = None # Can be None
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register_type(Person, typename="example.Person")
```
@@ -166,7 +166,7 @@ type Person struct {
Bio *string // Can be nil
}
-fory := forygo.NewFory(forygo.WithXlang(true))
+fory := forygo.NewFory(forygo.WithXlang(true), forygo.WithCompatible(true))
fory.RegisterNamedStruct(Person{}, "example.Person")
```
diff --git a/docs/guide/xlang/field-reference-tracking.md
b/docs/guide/xlang/field-reference-tracking.md
index d7bfb4ebf1..9d32c0e88b 100644
--- a/docs/guide/xlang/field-reference-tracking.md
+++ b/docs/guide/xlang/field-reference-tracking.md
@@ -35,7 +35,7 @@ Reference tracking enables:
```java
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
```
@@ -43,14 +43,14 @@ Fory fory = Fory.builder()
### Python
```python
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
```
### Go
```go
fory := forygo.NewFory(
- forygo.WithXlang(true),
+ forygo.WithXlang(true), forygo.WithCompatible(true),
forygo.WithTrackRef(true),
)
```
@@ -58,14 +58,14 @@ fory := forygo.NewFory(
### C++
```cpp
-auto fory = fory::Fory::builder().xlang(true).track_ref(true).build();
+auto fory =
fory::Fory::builder().xlang(true).compatible(true).track_ref(true).build();
```
### Rust
```rust
let fory = Fory::builder()
- .xlang(true)
+ .xlang(true).compatible(true)
.track_ref(true).build();
```
@@ -103,7 +103,7 @@ Key behavior:
```java
// Reference tracking enabled, but non-nullable fields still skip ref flags
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
```
diff --git a/docs/guide/xlang/getting-started.md
b/docs/guide/xlang/getting-started.md
index 23a4cdcdf4..7d091e3912 100644
--- a/docs/guide/xlang/getting-started.md
+++ b/docs/guide/xlang/getting-started.md
@@ -82,6 +82,7 @@ import org.apache.fory.config.*;
Fory fory = Fory.builder()
.withXlang(true) // Enable cross-language mode
+ .withCompatible(true) // Recommended xlang default
.withRefTracking(true) // Optional: for circular references
.build();
```
@@ -91,11 +92,11 @@ Fory fory = Fory.builder()
```python
import pyfory
-# Cross-language mode must be enabled explicitly
-fory = pyfory.Fory(xlang=True)
+# Cross-language mode uses compatible=True by default; set it explicitly in
examples.
+fory = pyfory.Fory(xlang=True, compatible=True)
# Enable reference tracking when needed
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
```
### Go
@@ -103,9 +104,9 @@ fory = pyfory.Fory(xlang=True, ref=True)
```go
import forygo "github.com/apache/fory/go/fory"
-fory := forygo.NewFory(forygo.WithXlang(true))
+fory := forygo.NewFory(forygo.WithXlang(true), forygo.WithCompatible(true))
// Or with reference tracking
-fory := forygo.NewFory(forygo.WithXlang(true), forygo.WithTrackRef(true))
+fory := forygo.NewFory(forygo.WithXlang(true), forygo.WithCompatible(true),
forygo.WithTrackRef(true))
```
### Rust
@@ -113,7 +114,7 @@ fory := forygo.NewFory(forygo.WithXlang(true),
forygo.WithTrackRef(true))
```rust
use fory::Fory;
-let fory = Fory::builder().xlang(true).build();
+let fory = Fory::builder().xlang(true).compatible(true).build();
```
### JavaScript
@@ -121,7 +122,7 @@ let fory = Fory::builder().xlang(true).build();
```javascript
import Fory from "@apache-fory/fory";
-const fory = new Fory();
+const fory = new Fory({ compatible: true });
```
### C++
@@ -133,6 +134,7 @@ using namespace fory::serialization;
auto fory = Fory::builder()
.xlang(true)
+ .compatible(true)
.build();
```
@@ -173,7 +175,7 @@ struct Person {
age: i32,
}
-let mut fory = Fory::builder().xlang(true).build();
+let mut fory = Fory::builder().xlang(true).compatible(true).build();
fory
.register_by_namespace::<Person>("example", "Person")
.expect("register Person");
@@ -246,7 +248,7 @@ public class Person {
public class HelloWorld {
public static void main(String[] args) throws Exception {
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.build();
fory.register(Person.class, "example.Person");
@@ -272,7 +274,7 @@ class Person:
name: str
age: pyfory.Int32
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register_type(Person, typename="example.Person")
with open("person.bin", "rb") as f:
diff --git a/docs/guide/xlang/index.md b/docs/guide/xlang/index.md
index 8ddc120942..1aa2958123 100644
--- a/docs/guide/xlang/index.md
+++ b/docs/guide/xlang/index.md
@@ -69,7 +69,7 @@ public class Person {
}
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.build();
fory.register(Person.class, "example.Person");
@@ -91,7 +91,7 @@ class Person:
name: str
age: pyfory.Int32
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
fory.register_type(Person, typename="example.Person")
# Receive bytes from Java
diff --git a/docs/guide/xlang/serialization.md
b/docs/guide/xlang/serialization.md
index ca82a69ea8..794293d329 100644
--- a/docs/guide/xlang/serialization.md
+++ b/docs/guide/xlang/serialization.md
@@ -42,7 +42,7 @@ import java.util.*;
public class Example1 {
public static void main(String[] args) {
- Fory fory = Fory.builder().withXlang(true).build();
+ Fory fory = Fory.builder().withXlang(true).withCompatible(true).build();
List<Object> list = ofArrayList(true, false, "str", -1.1, 1, new int[100],
new double[20]);
byte[] bytes = fory.serialize(list);
// bytes can be deserialized by other languages
@@ -64,7 +64,7 @@ public class Example1 {
import pyfory
import numpy as np
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
object_list = [True, False, "str", -1.1, 1,
np.full(100, 0, dtype=np.int32), np.full(20, 0.0,
dtype=np.double)]
data = fory.serialize(object_list)
@@ -87,7 +87,7 @@ import "fmt"
func main() {
list := []any{true, false, "str", -1.1, 1, make([]int32, 10),
make([]float64, 20)}
- fory := forygo.NewFory(forygo.WithXlang(true))
+ fory := forygo.NewFory(forygo.WithXlang(true), forygo.WithCompatible(true))
bytes, err := fory.Marshal(list)
if err != nil {
panic(err)
@@ -140,7 +140,7 @@ console.log(result);
use fory::Fory;
fn run() {
- let fory = Fory::builder().xlang(true).build();
+ let fory = Fory::builder().xlang(true).compatible(true).build();
let bin = fory.serialize(&"hello".to_string()).expect("serialize success");
let obj: String = fory.deserialize(&bin).expect("deserialize success");
assert_eq!("hello".to_string(), obj);
@@ -201,7 +201,7 @@ public class Example2 {
// mvn exec:java -Dexec.mainClass="org.apache.fory.examples.Example2"
public static void main(String[] args) {
- Fory fory = Fory.builder().withXlang(true).build();
+ Fory fory = Fory.builder().withXlang(true).withCompatible(true).build();
fory.register(SomeClass1.class, "example.SomeClass1");
fory.register(SomeClass2.class, "example.SomeClass2");
byte[] bytes = fory.serialize(createObject());
@@ -245,7 +245,7 @@ class SomeClass2:
if __name__ == "__main__":
- f = pyfory.Fory(xlang=True)
+ f = pyfory.Fory(xlang=True, compatible=True)
f.register_type(SomeClass1, typename="example.SomeClass1")
f.register_type(SomeClass2, typename="example.SomeClass2")
obj1 = SomeClass1(f1=True, f2={-1: 2})
@@ -296,7 +296,7 @@ func main() {
F11 []int16
F12 []int16
}
- serializer := forygo.NewFory(forygo.WithXlang(true))
+ serializer := forygo.NewFory(forygo.WithXlang(true),
forygo.WithCompatible(true))
if err := serializer.RegisterNamedStruct(SomeClass1{},
"example.SomeClass1"); err != nil {
panic(err)
}
@@ -406,7 +406,7 @@ fn complex_struct() {
c6: 4.0,
};
- let mut fory = Fory::builder().xlang(true).build();
+ let mut fory = Fory::builder().xlang(true).compatible(true).build();
fory
.register_by_namespace::<Animal>("example", "foo2")
.expect("register Animal");
@@ -447,7 +447,7 @@ public class ReferenceExample {
// mvn exec:java -Dexec.mainClass="org.apache.fory.examples.ReferenceExample"
public static void main(String[] args) {
- Fory fory = Fory.builder().withXlang(true)
+ Fory fory = Fory.builder().withXlang(true).withCompatible(true)
.withRefTracking(true).build();
fory.register(SomeClass.class, "example.SomeClass");
byte[] bytes = fory.serialize(createObject());
@@ -468,7 +468,7 @@ class SomeClass:
f2: Dict[str, str]
f3: Dict[str, str]
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
fory.register_type(SomeClass, typename="example.SomeClass")
obj = SomeClass()
obj.f2 = {"k1": "v1", "k2": "v2"}
@@ -493,7 +493,7 @@ func main() {
F3 map[string]string
}
fory := forygo.NewFory(
- forygo.WithXlang(true),
+ forygo.WithXlang(true), forygo.WithCompatible(true),
forygo.WithTrackRef(true),
)
if err := fory.RegisterStruct(SomeClass{}, 65); err != nil {
diff --git a/docs/guide/xlang/troubleshooting.md
b/docs/guide/xlang/troubleshooting.md
index b3931eeb06..9b5ab032fd 100644
--- a/docs/guide/xlang/troubleshooting.md
+++ b/docs/guide/xlang/troubleshooting.md
@@ -180,14 +180,14 @@ StackOverflowError or RecursionError
```java
// Java
Fory fory = Fory.builder()
- .withXlang(true)
+ .withXlang(true).withCompatible(true)
.withRefTracking(true)
.build();
```
```python
# Python
-fory = pyfory.Fory(xlang=True, ref=True)
+fory = pyfory.Fory(xlang=True, compatible=True, ref=True)
```
### Duplicate Objects
@@ -225,6 +225,28 @@ public Set<Status> statuses;
## Version Compatibility
+### Schema Hash Mismatch
+
+**Symptom:** Deserialization fails with an error such as `class version hash
mismatch`,
+`schema version mismatch`, `struct version mismatch`, or `hash mismatch`.
+
+**Cause:** The writer and reader are using schema-consistent mode while their
struct/class
+schemas differ. In xlang mode this can happen even when each language made a
reasonable local
+change, because field names, type annotations, field IDs, nullability, and
generated schema
+metadata must still align exactly.
+
+**Solution:**
+
+1. Align the schemas carefully on every service and language: field names or
field IDs,
+ field order where schema-consistent mode requires it, type annotations,
nullability,
+ and type registration IDs/names.
+2. Or use compatible mode on every peer, for example `withCompatible(true)` in
Java,
+ `compatible=True` in Python, `compatible(true)` in Rust, or
`WithCompatible(true)` in Go.
+ Compatible mode writes extra schema metadata, so payloads are larger, but
it is recommended
+ for `xlang=true` services that may evolve independently.
+3. Use schema-consistent mode only when schemas do not change, or when all
services deploy the
+ schema change at the same time.
+
### Serialization Format Changed
**Symptom:** Deserialization fails after upgrading Fory.
@@ -290,7 +312,7 @@ python deserializer.py data.bin
1. **Not registering types**: Always register custom types before use
2. **Inconsistent type names/IDs**: Use the same names/IDs across all languages
-3. **Forgetting xlang mode**: Use `.withXlang(true)` in Java
+3. **Forgetting xlang mode**: Use `.withXlang(true).withCompatible(true)` in
Java
4. **Wrong type annotations**: Use markers such as `pyfory.Int32` in Python
5. **Ignoring reference tracking**: Enable for circular/shared references
diff --git a/docs/guide/xlang/zero-copy.md b/docs/guide/xlang/zero-copy.md
index 6d7ceba045..aa91bba5ae 100644
--- a/docs/guide/xlang/zero-copy.md
+++ b/docs/guide/xlang/zero-copy.md
@@ -51,7 +51,7 @@ import java.util.stream.Collectors;
public class ZeroCopyExample {
public static void main(String[] args) {
- Fory fory = Fory.builder().withXlang(true).build();
+ Fory fory = Fory.builder().withXlang(true).withCompatible(true).build();
// Data with large arrays
List<Object> list = List.of(
@@ -84,7 +84,7 @@ import array
import pyfory
import numpy as np
-fory = pyfory.Fory(xlang=True)
+fory = pyfory.Fory(xlang=True, compatible=True)
# Data with large arrays
data = [
@@ -115,7 +115,7 @@ import forygo "github.com/apache/fory/go/fory"
import "fmt"
func main() {
- serializer := forygo.NewFory(forygo.WithXlang(true))
+ serializer := forygo.NewFory(forygo.WithXlang(true),
forygo.WithCompatible(true))
// Data with large arrays
list := []any{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]