Feature Request
Add production-ready Android support for Fory Java serialization.
Is your feature request related to a problem? Please describe
Fory Java does not support Android well today. There are several limitations:
- Android reflection is very slow.
- JDK
Unsafe APIs are unavailable or inconsistent across Android versions.
- JDK
MethodHandle APIs are unavailable for many Android versions.
- Bytecode generated by Janino cannot run on Android.
- Generating source/bytecode on mobile devices is slow and resource-intensive.
Describe the solution you'd like
"Apache Fory Android support" should resolve the above limitations and prove production support for Fory serialization on Android:
- Use reflection only in very rare code paths.
- Add Android-specific
Buffer and utility implementations guarded by a static final IS_ANDROID constant, and branch early in original hot paths.
- Do not use
MethodHandle in Android execution paths.
- Do not generate bytecode at runtime; update
java/fory-core/src/main/java/org/apache/fory/builder to generate stable source code that works across Android/JDK versions.
- Build an annotation processor that invokes
java/fory-core/src/main/java/org/apache/fory/builder to generate target serializer code at build time.
- Hook generated serializers into the current type resolver so serialization uses generated code first.
- Verify Android support introduces no performance regression by running
benchmarks/java and comparing results.
- Add CI coverage and comprehensive Android tests for functionality and compatibility.
- Update Fory Java guide docs and add a dedicated Android support document.
Describe alternatives you've considered
- Keep current Java runtime mechanisms (
Unsafe, MethodHandle, Janino bytecode generation) and try partial Android compatibility. This is still fragile across Android versions.
- Use reflection-based serialization on Android as the default path. This likely causes unacceptable performance overhead.
- Maintain a separate Android-only serialization stack. This increases long-term maintenance cost and divergence.
Additional context
Expected outcomes:
- Android builds use compile-time generated serializers.
- Runtime compatibility is stable across major Android versions.
- Performance remains competitive with existing Java paths (no regressions on shared benchmarks).
- CI continuously validates Android support and prevents regressions.
Related issues:
Feature Request
Add production-ready Android support for Fory Java serialization.
Is your feature request related to a problem? Please describe
Fory Java does not support Android well today. There are several limitations:
UnsafeAPIs are unavailable or inconsistent across Android versions.MethodHandleAPIs are unavailable for many Android versions.Describe the solution you'd like
"Apache Fory Android support" should resolve the above limitations and prove production support for Fory serialization on Android:
Bufferand utility implementations guarded by a static finalIS_ANDROIDconstant, and branch early in original hot paths.MethodHandlein Android execution paths.java/fory-core/src/main/java/org/apache/fory/builderto generate stable source code that works across Android/JDK versions.java/fory-core/src/main/java/org/apache/fory/builderto generate target serializer code at build time.benchmarks/javaand comparing results.Describe alternatives you've considered
Unsafe,MethodHandle, Janino bytecode generation) and try partial Android compatibility. This is still fragile across Android versions.Additional context
Expected outcomes:
Related issues: