-
Notifications
You must be signed in to change notification settings - Fork 383
Open
Labels
Description
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
UnsafeAPIs are unavailable or inconsistent across Android versions. - JDK
MethodHandleAPIs 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
Bufferand utility implementations guarded by a static finalIS_ANDROIDconstant, and branch early in original hot paths. - Do not use
MethodHandlein Android execution paths. - Do not generate bytecode at runtime; update
java/fory-core/src/main/java/org/apache/fory/builderto 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/builderto 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/javaand 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:
Reactions are currently unavailable