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

commit 095d8a6ccb387bcf78de90dda6d1edc68dc48d0c
Author: chaokunyang <[email protected]>
AuthorDate: Sat May 16 15:31:42 2026 +0000

    🔄 synced local 'docs/guide/' with remote 'docs/guide/'
---
 docs/guide/java/configuration.md                  |  1 -
 docs/guide/kotlin/android-support.md              | 14 ++--
 docs/guide/kotlin/default-values.md               | 11 ++-
 docs/guide/kotlin/fory-creation.md                | 38 ++++------
 docs/guide/kotlin/index.md                        | 10 +--
 docs/guide/kotlin/static-generated-serializers.md | 85 +++++++++++++++++------
 docs/guide/kotlin/type-serialization.md           | 11 ++-
 docs/guide/scala/default-values.md                | 23 ++----
 docs/guide/scala/fory-creation.md                 | 59 ++++++----------
 docs/guide/scala/index.md                         | 10 +--
 docs/guide/scala/schema-idl.md                    | 21 +++---
 docs/guide/scala/type-serialization.md            |  7 +-
 docs/guide/xlang/field-reference-tracking.md      |  5 +-
 13 files changed, 137 insertions(+), 158 deletions(-)

diff --git a/docs/guide/java/configuration.md b/docs/guide/java/configuration.md
index e7c09b123e..2ce533a743 100644
--- a/docs/guide/java/configuration.md
+++ b/docs/guide/java/configuration.md
@@ -45,7 +45,6 @@ This page documents all configuration options available 
through `ForyBuilder`.
 | `deserializeUnknownClass`           | Enables or disables 
deserialization/skipping of data for non-existent or unknown classes.           
                                                                                
                                                                                
                                                                                
                                                                                
                                 [...]
 | `codeGenEnabled`                    | Disabling may result in faster initial 
serialization but slower subsequent serializations. When unset, codegen 
defaults to enabled on ordinary JVMs and disabled on Android and GraalVM native 
image. Explicit `withCodegen(true)` on Android or GraalVM native image is 
accepted, but final build configuration forces interpreter serializers and 
emits a warning. If a build-time `@ForyStruct` static serializer is available, 
ordinary JVM `withCodegen(false)` [...]
 | `asyncCompilationEnabled`           | If enabled, serialization uses 
interpreter mode first and switches to JIT serialization after async serializer 
JIT for a class is finished. This option is forced off on Android and GraalVM 
native image because runtime code generation is unavailable there.              
                                                                                
                                                                                
                        [...]
-| `scalaOptimizationEnabled`          | Enables or disables Scala-specific 
serialization optimization.                                                     
                                                                                
                                                                                
                                                                                
                                                                                
                  [...]
 | `copyRef`                           | When disabled, the copy performance 
will be better. But fory deep copy will ignore circular and shared reference. 
Same reference of an object graph will be copied into different objects in one 
`Fory#copy`.                                                                    
                                                                                
                                                                                
                    [...]
 | `serializeEnumByName`               | When enabled, Fory serializes enum 
names instead of numeric enum tags. Without this option, Fory writes 
declaration ordinals by default, or explicit stable ids when the enum is 
configured with `@ForyEnumId`.                                                  
                                                                                
                                                                                
                                    [...]
 
diff --git a/docs/guide/kotlin/android-support.md 
b/docs/guide/kotlin/android-support.md
index 78db86bf6c..ab808d8b9c 100644
--- a/docs/guide/kotlin/android-support.md
+++ b/docs/guide/kotlin/android-support.md
@@ -55,20 +55,20 @@ rules must be packaged with that library artifact.
 
 ## Runtime Setup
 
-Register the Kotlin runtime serializers once for each Fory instance, then
-register application classes through the normal Fory Java registration APIs.
+Create the runtime with `ForyKotlin.builder()`, then register application
+classes through the Kotlin `register<T>` extension or the normal Fory Java
+registration APIs.
 
 ```kotlin
-import org.apache.fory.Fory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
+import org.apache.fory.kotlin.register
 
-val fory = Fory.builder()
+val fory = ForyKotlin.builder()
   .withXlang(true)
   .requireClassRegistration(true)
   .build()
 
-KotlinSerializers.registerSerializers(fory)
-fory.register(User::class.java, "example", "User")
+fory.register<User>("example", "User")
 ```
 
 Do not reference generated serializer classes from application code. The 
runtime
diff --git a/docs/guide/kotlin/default-values.md 
b/docs/guide/kotlin/default-values.md
index e706e86563..ed61407b63 100644
--- a/docs/guide/kotlin/default-values.md
+++ b/docs/guide/kotlin/default-values.md
@@ -34,14 +34,13 @@ When a Kotlin data class has parameters with default 
values, Fory can:
 This feature is automatically enabled when:
 
 - Compatible mode is enabled (`withCompatible(true)`)
-- Kotlin serializers are registered 
(`KotlinSerializers.registerSerializers(fory)`)
+- The runtime is built with `ForyKotlin.builder()` or 
`Fory.builder().withModule(ForyKotlin)`
 - A field is missing from the serialized data but exists in the target class 
with a default value
 
 ## Example
 
 ```kotlin
-import org.apache.fory.Fory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
 // Original data class
 data class User(val name: String, val age: Int)
@@ -50,10 +49,9 @@ data class User(val name: String, val age: Int)
 data class UserV2(val name: String, val age: Int, val email: String = 
"[email protected]")
 
 fun main() {
-    val fory = Fory.builder()
+    val fory = ForyKotlin.builder()
         .withCompatible(true)
         .build()
-    KotlinSerializers.registerSerializers(fory)
     fory.register(User::class.java)
     fory.register(UserV2::class.java)
 
@@ -92,10 +90,9 @@ data class ConfigV2(
     val retryCount: Int = 3
 )
 
-val fory = Fory.builder()
+val fory = ForyKotlin.builder()
     .withCompatible(true)
     .build()
-KotlinSerializers.registerSerializers(fory)
 
 val original = ConfigV1("myConfig")
 val serialized = fory.serialize(original)
diff --git a/docs/guide/kotlin/fory-creation.md 
b/docs/guide/kotlin/fory-creation.md
index 0ccb21c14f..e663b60a2c 100644
--- a/docs/guide/kotlin/fory-creation.md
+++ b/docs/guide/kotlin/fory-creation.md
@@ -23,18 +23,14 @@ This page covers Kotlin-specific requirements for creating 
Fory instances.
 
 ## Basic Setup
 
-When using Fory for Kotlin serialization, register Kotlin serializers via 
`KotlinSerializers.registerSerializers(fory)`:
+When using Fory for Kotlin serialization, create the runtime with 
`ForyKotlin.builder()`:
 
 ```kotlin
-import org.apache.fory.Fory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
-val fory = Fory.builder()
+val fory = ForyKotlin.builder()
     .requireClassRegistration(true)
     .build()
-
-// Register Kotlin serializers
-KotlinSerializers.registerSerializers(fory)
 ```
 
 ## Thread Safety
@@ -45,14 +41,12 @@ Fory instance creation is not cheap. Instances should be 
shared between multiple
 
 ```kotlin
 import org.apache.fory.Fory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
 object ForyHolder {
-    val fory: Fory = Fory.builder()
+    val fory: Fory = ForyKotlin.builder()
         .requireClassRegistration(true)
-        .build().also {
-            KotlinSerializers.registerSerializers(it)
-        }
+        .build()
 }
 ```
 
@@ -61,16 +55,13 @@ object ForyHolder {
 For multi-threaded applications, use `ThreadSafeFory`:
 
 ```kotlin
-import org.apache.fory.Fory
 import org.apache.fory.ThreadSafeFory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
 object ForyHolder {
-    val fory: ThreadSafeFory = Fory.builder()
+    val fory: ThreadSafeFory = ForyKotlin.builder()
         .requireClassRegistration(true)
-        .buildThreadSafeFory().also {
-            KotlinSerializers.registerSerializers(it)
-        }
+        .buildThreadSafeFory()
 }
 ```
 
@@ -78,11 +69,9 @@ object ForyHolder {
 
 ```kotlin
 // Thread-safe Fory
-val fory: ThreadSafeFory = Fory.builder()
+val fory: ThreadSafeFory = ForyKotlin.builder()
     .requireClassRegistration(true)
     .buildThreadSafeFory()
-
-KotlinSerializers.registerSerializers(fory)
 ```
 
 ## Configuration
@@ -92,10 +81,9 @@ All configuration options from Fory Java are available. See 
[Java Configuration]
 Common options for Kotlin:
 
 ```kotlin
-import org.apache.fory.Fory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
-val fory = Fory.builder()
+val fory = ForyKotlin.builder()
     // Enable reference tracking for circular references
     .withRefTracking(true)
     // Enable schema evolution support
@@ -106,6 +94,4 @@ val fory = Fory.builder()
     .withIntCompressed(true)
     .withLongCompressed(true)
     .build()
-
-KotlinSerializers.registerSerializers(fory)
 ```
diff --git a/docs/guide/kotlin/index.md b/docs/guide/kotlin/index.md
index 0b65c2a5d1..46bee95a03 100644
--- a/docs/guide/kotlin/index.md
+++ b/docs/guide/kotlin/index.md
@@ -39,6 +39,7 @@ Fory Kotlin inherits all features from Fory Java, plus 
Kotlin-specific optimizat
 - **Kotlin Type Support**: Optimized serializers for data classes, unsigned 
types, ranges, and stdlib types
 - **Default Value Support**: Automatic handling of Kotlin data class default 
parameters during schema evolution
 - **Static Xlang Serializers**: KSP-generated schema serializers for 
Kotlin/JVM and Android xlang mode
+- **Schema IDL Generation**: Fory compiler output for Kotlin models, sealed 
unions, and schema modules
 - **Schema Evolution**: Forward/backward compatibility for class schema changes
 
 See [Java Features](../java/index.md#features) for complete feature list.
@@ -64,23 +65,18 @@ implementation("org.apache.fory:fory-kotlin:0.17.0")
 ## Quick Start
 
 ```kotlin
-import org.apache.fory.Fory
 import org.apache.fory.ThreadSafeFory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
 data class Person(val name: String, val id: Long, val github: String)
 data class Point(val x: Int, val y: Int, val z: Int)
 
 fun main() {
     // Create Fory instance (should be reused)
-    val fory: ThreadSafeFory = Fory.builder()
+    val fory: ThreadSafeFory = ForyKotlin.builder()
         .requireClassRegistration(true)
         .buildThreadSafeFory()
 
-    // Register Kotlin serializers
-    KotlinSerializers.registerSerializers(fory)
-
-    // Register your classes
     fory.register(Person::class.java)
     fory.register(Point::class.java)
 
diff --git a/docs/guide/kotlin/static-generated-serializers.md 
b/docs/guide/kotlin/static-generated-serializers.md
index 99eb4edb38..c98c1b3c16 100644
--- a/docs/guide/kotlin/static-generated-serializers.md
+++ b/docs/guide/kotlin/static-generated-serializers.md
@@ -104,6 +104,10 @@ The processor rejects these declarations:
 Kotlin default constructor arguments are supported for compatible reads. A
 struct can have up to 12 defaulted constructor fields.
 
+Constructor-based generated serializers support wide primary constructors.
+Compatible reads track remote field presence in generated side state instead of
+using constructor bit masks.
+
 ## Nullability
 
 Use Kotlin `?` to describe nullable schema positions. Nullability is preserved
@@ -126,15 +130,19 @@ data class NullabilityExample(
 )
 ```
 
-Do not use Fory `@Nullable` in Kotlin source. The KSP processor rejects it so
-the schema is always read from Kotlin source nullability.
+Do not use Fory `@Nullable` in hand-written constructor-based Kotlin structs.
+The KSP processor rejects it so the schema is always read from Kotlin source
+nullability. Compiler-generated Kotlin IDL sources follow the same rule and use
+Kotlin `?` for nullable fields.
 
 ## References
 
-Kotlin xlang generated serializers reject every `@Ref` annotation, including
-`@Ref(enable = false)`. Generated reads construct Kotlin values through primary
-constructors, so they cannot publish partially constructed objects for cyclic
-back-references. Use non-cyclic schemas for Kotlin xlang structs.
+Kotlin generated serializers preserve `@Ref` metadata for fields, list
+elements, and map values. Constructor-owned reads construct Kotlin values
+through primary constructors. Schema IDL classes that need reference
+publication are emitted as mutable no-arg classes, and their KSP-generated
+serializers publish the instance before reading fields. In both shapes, KSP 
owns
+field descriptors, nested nullability, and `@Ref` metadata.
 
 ## Collections
 
@@ -174,11 +182,14 @@ Kotlin dense primitive and unsigned array fields are 
supported:
 - `UIntArray`
 - `ULongArray`
 
-Dense arrays are supported as top-level fields. Nested dense arrays, such as
-`List<UIntArray>` or `Map<String, IntArray>`, are rejected.
+Dense arrays with unambiguous Kotlin carriers are supported in fields,
+collection elements, map values, and union cases. `array<float16>` and
+`array<bfloat16>` use the Java core `Float16Array` and `BFloat16Array` 
carriers.
 
-`ByteArray` is encoded as Fory `binary` unless you explicitly annotate the
-field with Java `@ArrayType`.
+`ByteArray` is encoded as Fory `binary` unless the `ByteArray` type use is
+annotated with Java `@ArrayType`. Generated Kotlin IDL uses
+`@ArrayType ByteArray` for `array<int8>`, including nested collection and map
+positions.
 
 `@ArrayType` is also supported on top-level `List<T>` fields when `T` is a
 non-null boolean or numeric dense-array element type. In that case the field is
@@ -199,29 +210,63 @@ Without an annotation, xlang `Int`, `Long`, `UInt`, and 
`ULong` use varint
 encoding. This is required by xlang mode and is not controlled by Java native
 mode numeric compression options.
 
+## Duration
+
+Xlang `duration` maps to `kotlin.time.Duration`. Infinite Kotlin durations
+cannot be represented by the xlang duration payload and fail during
+serialization.
+
+## Sealed Unions
+
+KSP generates serializers for top-level sealed classes annotated with
+`@ForyUnion`. Each schema case is a nested class annotated with `@ForyCase` and
+one constructor property named `value`. Case ID `0` is reserved for the unknown
+case carrier:
+
+```kotlin
+@ForyUnion
+sealed class Animal {
+  @ForyCase(id = 0)
+  data class UnknownCase(val caseId: Int, val value: Any?) : Animal()
+
+  @ForyCase(id = 1)
+  data class DogCase(val value: Dog) : Animal()
+}
+```
+
+Generated schema modules register sealed unions through 
`KotlinSerializers.registerUnion`.
+The runtime discovers the generated `<Target>_ForySerializer` automatically, so
+callers do not pass a serializer instance.
+
 ## Register Classes
 
-Register Kotlin struct classes with the normal Fory Java registration APIs. You
+Register Kotlin struct classes with the Kotlin `register<T>` extension. You
 choose the xlang namespace and type name; generated serializers do not choose
 IDs or names for you.
 
 ```kotlin
-val fory = Fory.builder()
+import org.apache.fory.kotlin.ForyKotlin
+import org.apache.fory.kotlin.register
+
+val fory = ForyKotlin.builder()
   .withXlang(true)
   .requireClassRegistration(true)
   .build()
 
-KotlinSerializers.registerSerializers(fory)
-fory.register(User::class.java, "example", "User")
+fory.register<User>("example", "User")
 ```
 
-`KotlinSerializers.registerSerializers(fory)` installs the Kotlin runtime
-serializers used by Kotlin-specific carriers such as unsigned types. The
-`fory.register(...)` call registers your xlang schema type name.
+`ForyKotlin.builder()` installs the Kotlin runtime bootstrap for the Fory
+instance. The `fory.register<T>(...)` extension registers your xlang schema 
type
+name and resolves the generated serializer from the target class.
 
 Do not register or reference generated serializer classes in application code.
 The runtime resolves them from the registered target class.
 
+Generated Schema IDL modules use the same path. They call
+`KotlinSerializers.registerType`, `registerSerializer`, `registerEnum`, and
+`registerUnion` as appropriate and never emit Java files.
+
 ## Generated Names
 
 The generated serializer is emitted in the same package as the target class.
@@ -231,9 +276,9 @@ as `_`; source underscores are encoded as `_u_`.
 These names are an implementation detail. They matter for diagnostics and
 Android shrinking, but user code should only register target classes.
 
-If a Kotlin xlang struct is registered but its KSP generated serializer is
-missing, Fory fails with a configuration error. It does not fall back to
-runtime reflection for Kotlin schema metadata.
+If a constructor-owned Kotlin xlang struct is registered but its KSP generated
+serializer is missing, Fory fails with a configuration error. Compile generated
+IDL sources with KSP before registering generated Kotlin classes.
 
 ## Android And R8
 
diff --git a/docs/guide/kotlin/type-serialization.md 
b/docs/guide/kotlin/type-serialization.md
index 26b6de0a73..c0bd051b42 100644
--- a/docs/guide/kotlin/type-serialization.md
+++ b/docs/guide/kotlin/type-serialization.md
@@ -26,14 +26,11 @@ This page covers serialization of Kotlin-specific types.
 All examples assume the following setup:
 
 ```kotlin
-import org.apache.fory.Fory
-import org.apache.fory.serializer.kotlin.KotlinSerializers
+import org.apache.fory.kotlin.ForyKotlin
 
-val fory = Fory.builder()
+val fory = ForyKotlin.builder()
     .requireClassRegistration(false)
     .build()
-
-KotlinSerializers.registerSerializers(fory)
 ```
 
 ## Data Class
@@ -174,11 +171,11 @@ println(fory.deserialize(fory.serialize(uuid)))
 
 ## Types Working Out of the Box
 
-The following types work with the default Fory Java implementation without 
needing `KotlinSerializers`:
+The following types work with the default Fory Java implementation:
 
 - **Primitives**: `Byte`, `Boolean`, `Int`, `Short`, `Long`, `Char`, `Float`, 
`Double`
 - **String**: `String`
 - **Collections**: `ArrayList`, `HashMap`, `HashSet`, `LinkedHashSet`, 
`LinkedHashMap`
 - **Arrays**: `Array`, `BooleanArray`, `ByteArray`, `CharArray`, 
`DoubleArray`, `FloatArray`, `IntArray`, `LongArray`, `ShortArray`
 
-However, it's recommended to always call 
`KotlinSerializers.registerSerializers(fory)` to ensure all Kotlin types are 
properly supported.
+Use `ForyKotlin.builder()` for Kotlin-specific runtime types such as unsigned 
values, ranges, and `Duration`.
diff --git a/docs/guide/scala/default-values.md 
b/docs/guide/scala/default-values.md
index 7245e92e93..5991e63516 100644
--- a/docs/guide/scala/default-values.md
+++ b/docs/guide/scala/default-values.md
@@ -60,8 +60,7 @@ No additional configuration is required.
 ### Case Class with Default Values
 
 ```scala
-import org.apache.fory.Fory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
 // Class WITHOUT default values (for serialization)
 case class PersonV1(name: String)
@@ -69,13 +68,10 @@ case class PersonV1(name: String)
 // Class WITH default values (for deserialization)
 case class PersonV2(name: String, age: Int = 25, city: String = "Unknown")
 
-val fory = Fory.builder()
+val fory = ForyScala.builder()
   .withCompatible(true)
-  .withScalaOptimizationEnabled(true)
   .build()
 
-ScalaSerializers.registerSerializers(fory)
-
 // Serialize using class without default values
 val original = PersonV1("John")
 val serialized = fory.serialize(original)
@@ -101,13 +97,10 @@ class EmployeeV2(
   val department: String = "Engineering"
 )
 
-val fory = Fory.builder()
+val fory = ForyScala.builder()
   .withCompatible(true)
-  .withScalaOptimizationEnabled(true)
   .build()
 
-ScalaSerializers.registerSerializers(fory)
-
 // Serialize using class without default values
 val original = new EmployeeV1("Jane")
 val serialized = fory.serialize(original)
@@ -135,13 +128,10 @@ case class ConfigV2(
   enabled: Boolean = true
 )
 
-val fory = Fory.builder()
+val fory = ForyScala.builder()
   .withCompatible(true)
-  .withScalaOptimizationEnabled(true)
   .build()
 
-ScalaSerializers.registerSerializers(fory)
-
 val original = ConfigV1("myConfig")
 val serialized = fory.serialize(original)
 
@@ -164,13 +154,10 @@ object Models {
   case class PersonV2(name: String, address: Address = 
Address("DefaultStreet"))
 }
 
-val fory = Fory.builder()
+val fory = ForyScala.builder()
   .withCompatible(true)
-  .withScalaOptimizationEnabled(true)
   .build()
 
-ScalaSerializers.registerSerializers(fory)
-
 val original = Models.PersonV1("Alice")
 val serialized = fory.serialize(original)
 
diff --git a/docs/guide/scala/fory-creation.md 
b/docs/guide/scala/fory-creation.md
index a3f0a2ba6e..c65e384df0 100644
--- a/docs/guide/scala/fory-creation.md
+++ b/docs/guide/scala/fory-creation.md
@@ -25,19 +25,14 @@ This page covers Scala-specific requirements for creating 
Fory instances.
 
 When using Fory for Scala serialization, you must:
 
-1. Enable Scala optimization via `withScalaOptimizationEnabled(true)`
-2. Register Scala serializers via `ScalaSerializers.registerSerializers(fory)`
+1. Create the runtime with `ForyScala.builder()`, or install `ForyScala` with 
`Fory.builder().withModule(ForyScala)`.
+2. Register application classes before serialization.
 
 ```scala
-import org.apache.fory.Fory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
-val fory = Fory.builder()
-  .withScalaOptimizationEnabled(true)
+val fory = ForyScala.builder()
   .build()
-
-// Register optimized Fory serializers for Scala
-ScalaSerializers.registerSerializers(fory)
 ```
 
 ## Registering Scala Internal Types
@@ -51,8 +46,7 @@ fory.register(Class.forName("scala.Enumeration.Val"))
 To avoid such registration, you can disable class registration:
 
 ```scala
-val fory = Fory.builder()
-  .withScalaOptimizationEnabled(true)
+val fory = ForyScala.builder()
   .requireClassRegistration(false)
   .build()
 ```
@@ -64,8 +58,7 @@ val fory = Fory.builder()
 Circular references are common in Scala. Reference tracking should be enabled 
with `withRefTracking(true)`:
 
 ```scala
-val fory = Fory.builder()
-  .withScalaOptimizationEnabled(true)
+val fory = ForyScala.builder()
   .withRefTracking(true)
   .build()
 ```
@@ -80,16 +73,11 @@ Fory instance creation is not cheap. Instances should be 
shared between multiple
 
 ```scala
 import org.apache.fory.Fory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
 object ForyHolder {
-  val fory: Fory = {
-    val f = Fory.builder()
-      .withScalaOptimizationEnabled(true)
-      .build()
-    ScalaSerializers.registerSerializers(f)
-    f
-  }
+  val fory: Fory = ForyScala.builder()
+    .build()
 }
 ```
 
@@ -98,16 +86,12 @@ object ForyHolder {
 For multi-threaded applications, use `ThreadSafeFory`:
 
 ```scala
-import org.apache.fory.Fory
 import org.apache.fory.ThreadSafeFory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
 object ForyHolder {
-  val fory: ThreadSafeFory = Fory.builder()
-    .withScalaOptimizationEnabled(true)
+  val fory: ThreadSafeFory = ForyScala.builder()
     .buildThreadSafeFory()
-
-  ScalaSerializers.registerSerializers(fory)
 }
 ```
 
@@ -118,11 +102,9 @@ All configuration options from Fory Java are available. 
See [Java Configuration]
 Common options for Scala:
 
 ```scala
-import org.apache.fory.Fory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
-val fory = Fory.builder()
-  .withScalaOptimizationEnabled(true)
+val fory = ForyScala.builder()
   // Enable reference tracking for circular references
   .withRefTracking(true)
   // Enable schema evolution support
@@ -130,24 +112,23 @@ val fory = Fory.builder()
   // Enable async compilation for better startup performance
   .withAsyncCompilation(true)
   .build()
-
-ScalaSerializers.registerSerializers(fory)
 ```
 
 ## Cross-Language Mode
 
 For Scala xlang or schema IDL generated code, enable xlang and register the
-Scala serializers before registering generated model types:
+generated schema module:
 
 ```scala
-val fory = Fory.builder()
+import org.apache.fory.scala.ForyScala
+import example.ExampleForyModule
+
+val fory = ForyScala.builder()
   .withXlang(true)
   .withCompatible(true)
-  .withScalaOptimizationEnabled(true)
+  .withRefTracking(true)
+  .withModule(ExampleForyModule)
   .build()
-
-ScalaSerializers.registerSerializers(fory)
-ExampleForyRegistration.register(fory)
 ```
 
 In xlang mode, Scala collections use canonical `list`, `set`, and `map`
diff --git a/docs/guide/scala/index.md b/docs/guide/scala/index.md
index 382b43e1c1..ffa479737d 100644
--- a/docs/guide/scala/index.md
+++ b/docs/guide/scala/index.md
@@ -56,21 +56,15 @@ libraryDependencies += "org.apache.fory" %% "fory-scala" % 
"0.17.0"
 
 ```scala
 import org.apache.fory.Fory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
 case class Person(name: String, id: Long, github: String)
 case class Point(x: Int, y: Int, z: Int)
 
 object ScalaExample {
-  // Create Fory with Scala optimization enabled
-  val fory: Fory = Fory.builder()
-    .withScalaOptimizationEnabled(true)
+  val fory: Fory = ForyScala.builder()
     .build()
 
-  // Register optimized Fory serializers for Scala
-  ScalaSerializers.registerSerializers(fory)
-
-  // Register your classes
   fory.register(classOf[Person])
   fory.register(classOf[Point])
 
diff --git a/docs/guide/scala/schema-idl.md b/docs/guide/scala/schema-idl.md
index f89e81e76a..1396ee2e43 100644
--- a/docs/guide/scala/schema-idl.md
+++ b/docs/guide/scala/schema-idl.md
@@ -30,22 +30,20 @@ the shared JVM annotations in `org.apache.fory.annotation`. 
Macro internals live
 under `org.apache.fory.scala.internal`.
 
 ```scala
-import org.apache.fory.Fory
-import org.apache.fory.scala.ForySerializer
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.{ForyScala, ForySerializer}
+import example.ExampleForyModule
 
-val fory = Fory.builder()
+val fory = ForyScala.builder()
   .withXlang(true)
   .withCompatible(true)
-  .withScalaOptimizationEnabled(true)
+  .withRefTracking(true)
+  .withModule(ExampleForyModule)
   .build()
-
-ScalaSerializers.registerSerializers(fory)
-ExampleForyRegistration.register(fory)
 ```
 
-For `ThreadSafeFory`, generated registration helpers install a callback so each
-runtime instance gets the same serializers.
+Generated schema modules are also Fory modules. Use `.withModule(...)` when
+creating a custom runtime, or use the generated no-argument `toBytes` and
+`fromBytes` helpers when the default xlang-compatible runtime is sufficient.
 
 Generated helpers register message type identities before installing message
 serializers. This two-phase order lets mutually recursive message graphs build
@@ -108,7 +106,8 @@ the schema IDL surface unless explicitly generated.
 
 ## Generated Enums
 
-IDL enums generate Scala 3 enums only. No Java enum sidecar is emitted.
+IDL enums generate Scala 3 enums only. The compiler does not emit Java enum
+files.
 
 ```scala
 import org.apache.fory.annotation.ForyEnumId
diff --git a/docs/guide/scala/type-serialization.md 
b/docs/guide/scala/type-serialization.md
index 56dbc30f56..87661515c1 100644
--- a/docs/guide/scala/type-serialization.md
+++ b/docs/guide/scala/type-serialization.md
@@ -27,13 +27,10 @@ All examples assume the following setup:
 
 ```scala
 import org.apache.fory.Fory
-import org.apache.fory.serializer.scala.ScalaSerializers
+import org.apache.fory.scala.ForyScala
 
-val fory = Fory.builder()
-  .withScalaOptimizationEnabled(true)
+val fory = ForyScala.builder()
   .build()
-
-ScalaSerializers.registerSerializers(fory)
 ```
 
 ## Case Class
diff --git a/docs/guide/xlang/field-reference-tracking.md 
b/docs/guide/xlang/field-reference-tracking.md
index 7bce185926..68405d3edc 100644
--- a/docs/guide/xlang/field-reference-tracking.md
+++ b/docs/guide/xlang/field-reference-tracking.md
@@ -72,11 +72,12 @@ let fory = Fory::builder()
 ### Scala
 
 ```scala
-val fory = Fory.builder()
+import org.apache.fory.scala.ForyScala
+
+val fory = ForyScala.builder()
   .withXlang(true)
   .withCompatible(true)
   .withRefTracking(true)
-  .withScalaOptimizationEnabled(true)
   .build()
 ```
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to