blob: d3f33dd2a6cb541926082cff44c321faf66adf2f [file]
<!doctype html><html lang=en-US dir=ltr class="docs-wrapper plugin-docs plugin-id-default docs-version-1.3.0 docs-doc-page docs-doc-id-guide/java/static_generated_serializers" data-has-hydrated=false><head><meta charset=UTF-8><meta name=generator content="Docusaurus v3.10.1"><title data-rh=true>Static Generated Serializers | Apache Fory™</title><meta data-rh=true name=viewport content="width=device-width, initial-scale=1.0"/><meta data-rh=true property=og:url content=https://fory.apache.org/docs/guide/java/static_generated_serializers /><meta data-rh=true property=og:locale content=en_US /><meta data-rh=true property=og:locale:alternate content=zh_CN /><meta data-rh=true name=docusaurus_locale content=en-US /><meta data-rh=true name=docsearch:language content=en-US /><meta data-rh=true http-equiv=Content-Security-Policy content="frame-src 'self' https://ghbtns.com/;"/><meta data-rh=true property=og:image content=https://fory.apache.org/img/logo.png /><meta data-rh=true property=og:image:width content=1500 /><meta data-rh=true property=og:image:height content=1500 /><meta data-rh=true name=twitter:card content=summary_large_image /><meta data-rh=true name=twitter:image content=https://fory.apache.org/img/logo.png /><meta data-rh=true name=docusaurus_version content=1.3.0 /><meta data-rh=true name=docusaurus_tag content=docs-default-1.3.0 /><meta data-rh=true name=docsearch:version content=1.3.0 /><meta data-rh=true name=docsearch:docusaurus_tag content=docs-default-1.3.0 /><meta data-rh=true property=og:title content="Static Generated Serializers | Apache Fory™"/><meta data-rh=true name=description content="Static generated serializers are Java serializers generated by javac during your application build."/><meta data-rh=true property=og:description content="Static generated serializers are Java serializers generated by javac during your application build."/><link data-rh=true rel=icon href=/img/favicon.ico /><link data-rh=true rel=canonical href=https://fory.apache.org/docs/guide/java/static_generated_serializers /><link data-rh=true rel=alternate href=https://fory.apache.org/docs/guide/java/static_generated_serializers hreflang=en-US /><link data-rh=true rel=alternate href=https://fory.apache.org/zh-CN/docs/guide/java/static_generated_serializers hreflang=zh-CN /><link data-rh=true rel=alternate href=https://fory.apache.org/docs/guide/java/static_generated_serializers hreflang=x-default /><script data-rh=true type=application/ld+json>{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","item":"https://fory.apache.org/docs/guide/java/","name":"Java","position":1},{"@type":"ListItem","item":"https://fory.apache.org/docs/guide/java/static_generated_serializers","name":"Static Generated Serializers","position":2}]}</script><link rel=alternate type=application/rss+xml href=/blog/rss.xml title="Apache Fory™ RSS Feed"><link rel=alternate type=application/atom+xml href=/blog/atom.xml title="Apache Fory™ Atom Feed"><script type=text/javascript>"fury.apache.org"===window.location.host&&(window.location.href="https://fory.apache.org"),function(){for(var o=window.location.pathname,a=["guide","introduction","start"],n=0;n<a.length;n++){var t=a[n],i=RegExp("^((?:/[a-z]{2}-[A-Z]{2})?/docs(?:/(?:next|[0-9]+.[0-9]+))?)/docs/"+t+"(/.*)?$"),c=o.match(i);if(c){var r=c[1]+"/"+t+(c[2]||"");window.location.replace(r+window.location.search+window.location.hash);return}}}()</script><link rel=stylesheet href=/assets/css/styles.3a1edaa1.css /><script src=/assets/js/runtime~main.605b11b1.js defer></script><script src=/assets/js/main.283fea4b.js defer></script></head><body><svg style="display: none;"><defs>
<symbol id=theme-svg-external-link viewBox="0 0 24 24"><path fill=currentColor d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol>
</defs></svg>
<script>!function(){var t=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();document.documentElement.setAttribute("data-theme",t||"light"),document.documentElement.setAttribute("data-theme-choice",t||"light")}(),function(){try{for(var[t,e]of new URLSearchParams(window.location.search).entries())if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id=__docusaurus><div role=region aria-label="Skip to main content"><a class=skipToContent_fXgn href=#__docusaurus_skipToContent_fallback>Skip to main content</a></div><nav aria-label=Main class="theme-layout-navbar navbar navbar--fixed-top"><div class=navbar__inner><div class="theme-layout-navbar-left navbar__items"><button aria-label="Toggle navigation bar" aria-expanded=false class="navbar__toggle clean-btn" type=button><svg width=30 height=30 viewBox="0 0 30 30" aria-hidden=true><path stroke=currentColor stroke-linecap=round stroke-miterlimit=10 stroke-width=2 d="M4 7h22M4 15h22M4 23h22"/></svg></button><a class=navbar__brand href=/><div class=navbar__logo><img src=/img/fory-logo-light.png alt="Apache Fory™ Logo" class="themedComponent_mlkZ themedComponent--light_NVdE"/><img src=/img/fory-logo-dark.png alt="Apache Fory™ Logo" class="themedComponent_mlkZ themedComponent--dark_xIcU"/></div><b class="navbar__title text--truncate"></b></a><a aria-current=page class="navbar__item navbar__link navbar__link--active" href=/docs/introduction/overview>Docs</a><a class="navbar__item navbar__link" href=/docs/specification/xlang_serialization_spec>Specification</a><a class="navbar__item navbar__link" href=/docs/community/>Community</a><a class="navbar__item navbar__link" href=/user>Users</a><a class="navbar__item navbar__link" href=/download>Download</a><a class="navbar__item navbar__link" href=/blog>Blog</a></div><div class="theme-layout-navbar-right navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href=# aria-haspopup=true aria-expanded=false role=button class=navbar__link>ASF</a><ul class=dropdown__menu><li><a href=https://www.apache.org/ target=_blank rel="noopener noreferrer" class=dropdown__link>Foundation</a><li><a href=https://www.apache.org/licenses/ target=_blank rel="noopener noreferrer" class=dropdown__link>License</a><li><a href=https://www.apache.org/events/current-event.html target=_blank rel="noopener noreferrer" class=dropdown__link>Events</a><li><a href=https://privacy.apache.org/policies/privacy-policy-public.html target=_blank rel="noopener noreferrer" class=dropdown__link>Privacy</a><li><a href=https://www.apache.org/security/ target=_blank rel="noopener noreferrer" class=dropdown__link>Security</a><li><a href=https://www.apache.org/foundation/sponsorship.html target=_blank rel="noopener noreferrer" class=dropdown__link>Sponsorship</a><li><a href=https://www.apache.org/foundation/thanks.html target=_blank rel="noopener noreferrer" class=dropdown__link>Thanks</a><li><a href=https://www.apache.org/foundation/policies/conduct.html target=_blank rel="noopener noreferrer" class=dropdown__link>Code of Conduct</a></ul></div><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a class=navbar__link aria-haspopup=true aria-expanded=false role=button href=/docs/guide/java/static_generated_serializers>1.3.0</a><ul class=dropdown__menu><li><a class=dropdown__link href=/docs/next/guide/java/static_generated_serializers>dev</a><li><a aria-current=page class="dropdown__link dropdown__link--active" href=/docs/guide/java/static_generated_serializers>1.3.0</a><li><a class=dropdown__link href=/docs/1.2.0/guide/java/static_generated_serializers>1.2.0</a><li><a class=dropdown__link href=/docs/1.1.0/guide/java/static_generated_serializers>1.1.0</a><li><a class=dropdown__link href=/docs/1.0.0/guide/java/static_generated_serializers>1.0.0</a><li><a class=dropdown__link href=/docs/0.17/introduction/overview>0.17</a><li><a class=dropdown__link href=/docs/0.16/introduction/overview>0.16</a><li><a class=dropdown__link href=/docs/0.15/introduction/overview>0.15</a><li><a class=dropdown__link href=/docs/0.14/introduction/overview>0.14</a><li><a class=dropdown__link href=/docs/0.13/introduction/overview>0.13</a><li><a class=dropdown__link href=/docs/0.12/introduction/overview>0.12</a><li><a class=dropdown__link href=/docs/0.11/introduction/overview>0.11</a><li><a class=dropdown__link href=/docs/0.10/introduction/overview>0.10</a></ul></div><a href=https://github.com/apache/fory target=_blank rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href=# aria-haspopup=true aria-expanded=false role=button class=navbar__link><svg viewBox="0 0 24 24" width=20 height=20 aria-hidden=true class=iconLanguage_nlXk><path fill=currentColor d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"/></svg>English</a><ul class=dropdown__menu><li><a href=/docs/guide/java/static_generated_serializers target=_self rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang=en-US>English</a><li><a href=/zh-CN/docs/guide/java/static_generated_serializers target=_self rel="noopener noreferrer" class=dropdown__link lang=zh-CN>简体中文</a></ul></div><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type=button disabled title="system mode" aria-label="Switch between dark and light mode (currently system mode)"><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP lightToggleIcon_pyhR"><path fill=currentColor d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP darkToggleIcon_wfgR"><path fill=currentColor d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 aria-hidden=true class="toggleIcon_g3eP systemToggleIcon_QzmC"><path fill=currentColor d="m12 21c4.971 0 9-4.029 9-9s-4.029-9-9-9-9 4.029-9 9 4.029 9 9 9zm4.95-13.95c1.313 1.313 2.05 3.093 2.05 4.95s-0.738 3.637-2.05 4.95c-1.313 1.313-3.093 2.05-4.95 2.05v-14c1.857 0 3.637 0.737 4.95 2.05z"/></svg></button></div><div class=navbarSearchContainer_Bca1><div class=navbar__search><span aria-label="expand searchbar" role=button class=search-icon tabindex=0></span><input id=search_input_react type=search placeholder=Loading... aria-label=Search class="navbar__search-input search-bar" disabled/></div></div></div></div><div role=presentation class=navbar-sidebar__backdrop></div></nav><div id=__docusaurus_skipToContent_fallback class="theme-layout-main main-wrapper mainWrapper_z2l0"><div class=docsWrapper_hBAB><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type=button></button><div class=docRoot_UBD9><aside class="theme-doc-sidebar-container docSidebarContainer_YfHR"><div class=sidebarViewport_aRkj><div class=sidebar_njMd><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role=button aria-expanded=true href=/docs/introduction/overview><span title=Introduction class=categoryLinkLabel_W154>Introduction</span></a></div><ul class=menu__list><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class=menu__link tabindex=0 href=/docs/introduction/overview><span title=Overview class=linkLabel_WmDU>Overview</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class=menu__link tabindex=0 href=/docs/introduction/features><span title=Features class=linkLabel_WmDU>Features</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class=menu__link tabindex=0 href=/docs/introduction/benchmark><span title=Benchmark class=linkLabel_WmDU>Benchmark</span></a></ul><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role=button aria-expanded=true href=/docs/start/install><span title=Start class=categoryLinkLabel_W154>Start</span></a></div><ul class=menu__list><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class=menu__link tabindex=0 href=/docs/start/install><span title=Install class=linkLabel_WmDU>Install</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class=menu__link tabindex=0 href=/docs/start/usage><span title=Usage class=linkLabel_WmDU>Usage</span></a></ul><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role=button aria-expanded=false href=/docs/compiler/><span title="Schema IDL & Compiler" class=categoryLinkLabel_W154>Schema IDL & Compiler</span></a></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" role=button aria-expanded=true href=/docs/guide/java/><span title=Guide class=categoryLinkLabel_W154>Guide</span></a></div><ul class=menu__list><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--active" tabindex=0 href=/docs/guide/java/><span title=Java class=categoryLinkLabel_W154>Java</span></a><button aria-label="Collapse sidebar category 'Java'" aria-expanded=true type=button class="clean-btn menu__caret"></button></div><ul class=menu__list><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/basic_serialization><span title="Basic Serialization" class=linkLabel_WmDU>Basic Serialization</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/xlang_serialization><span title="Xlang Serialization" class=linkLabel_WmDU>Xlang Serialization</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/native_serialization><span title="Native Serialization" class=linkLabel_WmDU>Native Serialization</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/configuration><span title=Configuration class=linkLabel_WmDU>Configuration</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/type_registration><span title="Type Registration" class=linkLabel_WmDU>Type Registration</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/schema_evolution><span title="Schema Evolution" class=linkLabel_WmDU>Schema Evolution</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/schema_metadata><span title="Schema Metadata" class=linkLabel_WmDU>Schema Metadata</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link menu__link--active" aria-current=page tabindex=0 href=/docs/guide/java/static_generated_serializers><span title="Static Generated Serializers" class=linkLabel_WmDU>Static Generated Serializers</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/object_copy><span title="Object Copy" class=linkLabel_WmDU>Object Copy</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/compression><span title=Compression class=linkLabel_WmDU>Compression</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/custom_serializers><span title="Custom Serializers" class=linkLabel_WmDU>Custom Serializers</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/row_format><span title="Row Format" class=linkLabel_WmDU>Row Format</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/virtual_threads><span title="Virtual Threads" class=linkLabel_WmDU>Virtual Threads</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/graalvm_support><span title="GraalVM Support" class=linkLabel_WmDU>GraalVM Support</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/android_support><span title="Android Support" class=linkLabel_WmDU>Android Support</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/advanced_features><span title="Advanced Features" class=linkLabel_WmDU>Advanced Features</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/grpc_support><span title="gRPC Support" class=linkLabel_WmDU>gRPC Support</span></a><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class=menu__link tabindex=0 href=/docs/guide/java/troubleshooting><span title=Troubleshooting class=linkLabel_WmDU>Troubleshooting</span></a></ul><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/python/><span title=Python class=categoryLinkLabel_W154>Python</span></a><button aria-label="Expand sidebar category 'Python'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/rust/><span title=Rust class=categoryLinkLabel_W154>Rust</span></a><button aria-label="Expand sidebar category 'Rust'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/cpp/><span title=C++ class=categoryLinkLabel_W154>C++</span></a><button aria-label="Expand sidebar category 'C++'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/go/><span title=Go class=categoryLinkLabel_W154>Go</span></a><button aria-label="Expand sidebar category 'Go'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/javascript/><span title=JavaScript class=categoryLinkLabel_W154>JavaScript</span></a><button aria-label="Expand sidebar category 'JavaScript'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/csharp/><span title=C# class=categoryLinkLabel_W154>C#</span></a><button aria-label="Expand sidebar category 'C#'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/swift/><span title=Swift class=categoryLinkLabel_W154>Swift</span></a><button aria-label="Expand sidebar category 'Swift'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/dart/><span title=Dart class=categoryLinkLabel_W154>Dart</span></a><button aria-label="Expand sidebar category 'Dart'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/scala/><span title=Scala class=categoryLinkLabel_W154>Scala</span></a><button aria-label="Expand sidebar category 'Scala'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/kotlin/><span title=Kotlin class=categoryLinkLabel_W154>Kotlin</span></a><button aria-label="Expand sidebar category 'Kotlin'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class=menu__list-item-collapsible><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex=0 href=/docs/guide/xlang/><span title="Cross Language" class=categoryLinkLabel_W154>Cross Language</span></a><button aria-label="Expand sidebar category 'Cross Language'" aria-expanded=false type=button class="clean-btn menu__caret"></button></div></ul></ul></nav></div></div></aside><main class=docMainContainer_TBSr><div class="container padding-top--md padding-bottom--lg"><div class=row><div class="col docItemCol_VOVn"><div class=docItemContainer_Djhp><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label=Breadcrumbs><ul class=breadcrumbs><li class=breadcrumbs__item><a aria-label="Home page" class=breadcrumbs__link href=/><svg viewBox="0 0 24 24" class=breadcrumbHomeIcon_YNFT><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill=currentColor /></svg></a><li class=breadcrumbs__item><span class=breadcrumbs__link>Guide</span><li class=breadcrumbs__item><a class=breadcrumbs__link href=/docs/guide/java/><span>Java</span></a><li class="breadcrumbs__item breadcrumbs__item--active"><span class=breadcrumbs__link>Static Generated Serializers</span></ul></nav><span class="theme-doc-version-badge badge badge--secondary">Version: 1.3.0</span><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type=button class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Static Generated Serializers</h1></header><p>Static generated serializers are Java serializers generated by javac during your application build.
They are useful when runtime code generation is disabled or unavailable.</p>
<p>Use them when:</p>
<ul>
<li class="">you run on Android.</li>
<li class="">you run an ordinary JVM with <code>ForyBuilder#withCodegen(false)</code> and want generated serializers.</li>
<li class="">your Android model classes use Fory type-use annotations such as <code>@Ref</code>, <code>@UInt8Type</code>, or
<code>@Float16Type</code>.</li>
</ul>
<p>For GraalVM native images, follow <a class="" href=/docs/guide/java/graalvm_support>GraalVM Support</a> instead.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=install-the-annotation-processor>Install The Annotation Processor<a href=#install-the-annotation-processor class=hash-link aria-label="Direct link to Install The Annotation Processor" title="Direct link to Install The Annotation Processor" translate=no></a></h2>
<p>Add <code>fory-annotation-processor</code> to the annotation processor path of the module that compiles your
serializable classes:</p>
<div class="language-xml codeBlockContainer_Ckt0 theme-code-block" style=--prism-color:#393A34;--prism-background-color:#f6f8fa><div class=codeBlockContent_QJqH><pre tabindex=0 class="prism-code language-xml codeBlock_bY9V thin-scrollbar" style=color:#393A34;background-color:#f6f8fa><code class=codeBlockLines_e6Vv><div class=token-line style=color:#393A34><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>build</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>plugins</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>plugin</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>groupId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain">org.apache.maven.plugins</span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>groupId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>artifactId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain">maven-compiler-plugin</span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>artifactId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>configuration</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>annotationProcessorPaths</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>path</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>groupId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain">org.apache.fory</span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>groupId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>artifactId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain">fory-annotation-processor</span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>artifactId</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;</span><span class="token tag" style=color:#00009f>version</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain">${fory.version}</span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>version</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>path</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>annotationProcessorPaths</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>configuration</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>plugin</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>plugins</span><span class="token tag punctuation" style=color:#393A34>></span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token tag punctuation" style=color:#393A34>&lt;/</span><span class="token tag" style=color:#00009f>build</span><span class="token tag punctuation" style=color:#393A34>></span><br/></div></code></pre></div></div>
<p>The generated serializers depend on <code>fory-core</code> at runtime. Applications opt in by adding the
annotation processor; <code>fory-core</code> does not depend on it.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=annotate-classes>Annotate Classes<a href=#annotate-classes class=hash-link aria-label="Direct link to Annotate Classes" title="Direct link to Annotate Classes" translate=no></a></h2>
<p>Annotate each serializable class with <code>@ForyStruct</code>:</p>
<div class="language-java codeBlockContainer_Ckt0 theme-code-block" style=--prism-color:#393A34;--prism-background-color:#f6f8fa><div class=codeBlockContent_QJqH><pre tabindex=0 class="prism-code language-java codeBlock_bY9V thin-scrollbar" style=color:#393A34;background-color:#f6f8fa><code class=codeBlockLines_e6Vv><div class=token-line style=color:#393A34><span class="token keyword" style=color:#00009f>import</span><span class="token plain"> </span><span class="token import namespace" style=opacity:0.7>org</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>apache</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>fory</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>annotation</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import class-name">ForyStruct</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain" style=display:inline-block></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token annotation punctuation" style=color:#393A34>@ForyStruct</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token keyword" style=color:#00009f>class</span><span class="token plain"> </span><span class="token class-name">Order</span><span class="token plain"> </span><span class="token punctuation" style=color:#393A34>{</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token keyword" style=color:#00009f>long</span><span class="token plain"> id</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token class-name">String</span><span class="token plain"> note</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain" style=display:inline-block></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token class-name">Order</span><span class="token punctuation" style=color:#393A34>(</span><span class="token punctuation" style=color:#393A34>)</span><span class="token plain"> </span><span class="token punctuation" style=color:#393A34>{</span><span class="token punctuation" style=color:#393A34>}</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token punctuation" style=color:#393A34>}</span><br/></div></code></pre></div></div>
<p>The processor generates serializer classes in the same Java package as the annotated class. For
<code>Order</code>, the generated classes are:</p>
<ul>
<li class=""><code>Order_ForySerializer</code> for xlang mode.</li>
<li class=""><code>Order_ForyNativeSerializer</code> for Java native mode.</li>
</ul>
<p>For a static nested type such as <code>Outer.Inner</code>, the generated top-level classes are
<code>Outer_Inner_ForySerializer</code> and <code>Outer_Inner_ForyNativeSerializer</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=field-debug-tracing>Field Debug Tracing<a href=#field-debug-tracing class=hash-link aria-label="Direct link to Field Debug Tracing" title="Direct link to Field Debug Tracing" translate=no></a></h2>
<p>Add <code>@ForyDebug</code> next to <code>@ForyStruct</code> when you need generated serializers to include field-level
debug tracing hooks. The generated code prints those traces only when
<code>ENABLE_FORY_DEBUG_OUTPUT=1</code>.</p>
<div class="language-java codeBlockContainer_Ckt0 theme-code-block" style=--prism-color:#393A34;--prism-background-color:#f6f8fa><div class=codeBlockContent_QJqH><pre tabindex=0 class="prism-code language-java codeBlock_bY9V thin-scrollbar" style=color:#393A34;background-color:#f6f8fa><code class=codeBlockLines_e6Vv><div class=token-line style=color:#393A34><span class="token keyword" style=color:#00009f>import</span><span class="token plain"> </span><span class="token import namespace" style=opacity:0.7>org</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>apache</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>fory</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>annotation</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import class-name">ForyDebug</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token keyword" style=color:#00009f>import</span><span class="token plain"> </span><span class="token import namespace" style=opacity:0.7>org</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>apache</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>fory</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>annotation</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import class-name">ForyStruct</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain" style=display:inline-block></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token annotation punctuation" style=color:#393A34>@ForyStruct</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token annotation punctuation" style=color:#393A34>@ForyDebug</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token keyword" style=color:#00009f>class</span><span class="token plain"> </span><span class="token class-name">DebugOrder</span><span class="token plain"> </span><span class="token punctuation" style=color:#393A34>{</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token keyword" style=color:#00009f>long</span><span class="token plain"> id</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token class-name">String</span><span class="token plain"> note</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain" style=display:inline-block></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token class-name">DebugOrder</span><span class="token punctuation" style=color:#393A34>(</span><span class="token punctuation" style=color:#393A34>)</span><span class="token plain"> </span><span class="token punctuation" style=color:#393A34>{</span><span class="token punctuation" style=color:#393A34>}</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token punctuation" style=color:#393A34>}</span><br/></div></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=runtime-use>Runtime Use<a href=#runtime-use class=hash-link aria-label="Direct link to Runtime Use" title="Direct link to Runtime Use" translate=no></a></h2>
<p>Fory uses static generated serializers when they are available on:</p>
<ul>
<li class="">Android.</li>
<li class="">ordinary JVMs with <code>ForyBuilder#withCodegen(false)</code>.</li>
<li class="">compatible-mode reads when the target struct has a generated serializer.</li>
</ul>
<p>On an ordinary JVM with <code>codegen=true</code>, Fory continues to prefer runtime-generated serializers.</p>
<p>Fory resolves generated serializers from the registered target class name. Application code
should not reference generated serializer classes directly.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=field-access-rules>Field Access Rules<a href=#field-access-rules class=hash-link aria-label="Direct link to Field Access Rules" title="Direct link to Field Access Rules" translate=no></a></h2>
<p>Generated serializers must be able to access serialized fields or their accessors at compile time.</p>
<ul>
<li class="">Public, protected, and package-private fields can be accessed directly when Java package access
allows same-package generated serializers to use them.</li>
<li class="">Private serialized fields must have accessible non-private getter and setter methods, or be
excluded with <code>transient</code> or Fory <code>@Ignore</code>.</li>
<li class="">Public, protected, and package-private getter/setter methods are accepted when they are accessible
from the generated serializer package.</li>
<li class="">Final fields are not supported for normal mutable classes because generated read and copy methods
must assign fields. Use records for constructor-based immutable values.</li>
</ul>
<p>For records, generated serializers use public record accessors and construct values through the
canonical record constructor. Ignored record components are skipped by serialization and copy, and
their constructor arguments use Java default values during generated read/copy.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=type-use-annotations-on-android>Type-Use Annotations On Android<a href=#type-use-annotations-on-android class=hash-link aria-label="Direct link to Type-Use Annotations On Android" title="Direct link to Type-Use Annotations On Android" translate=no></a></h2>
<p>On Android, static generated serializers are required when a class uses Fory type-use annotations on
nested types:</p>
<div class="language-java codeBlockContainer_Ckt0 theme-code-block" style=--prism-color:#393A34;--prism-background-color:#f6f8fa><div class=codeBlockContent_QJqH><pre tabindex=0 class="prism-code language-java codeBlock_bY9V thin-scrollbar" style=color:#393A34;background-color:#f6f8fa><code class=codeBlockLines_e6Vv><div class=token-line style=color:#393A34><span class="token keyword" style=color:#00009f>import</span><span class="token plain"> </span><span class="token import namespace" style=opacity:0.7>java</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>util</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import class-name">List</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token keyword" style=color:#00009f>import</span><span class="token plain"> </span><span class="token import namespace" style=opacity:0.7>org</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>apache</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>fory</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>annotation</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import class-name">ForyStruct</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token keyword" style=color:#00009f>import</span><span class="token plain"> </span><span class="token import namespace" style=opacity:0.7>org</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>apache</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>fory</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import namespace" style=opacity:0.7>annotation</span><span class="token import namespace punctuation" style=opacity:0.7;color:#393A34>.</span><span class="token import class-name">UInt8Type</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain" style=display:inline-block></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token annotation punctuation" style=color:#393A34>@ForyStruct</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token keyword" style=color:#00009f>class</span><span class="token plain"> </span><span class="token class-name">ImageBlock</span><span class="token plain"> </span><span class="token punctuation" style=color:#393A34>{</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"> </span><span class="token keyword" style=color:#00009f>public</span><span class="token plain"> </span><span class="token class-name">List</span><span class="token operator" style=color:#393A34>&lt;</span><span class="token annotation punctuation" style=color:#393A34>@UInt8Type</span><span class="token plain"> </span><span class="token class-name">Integer</span><span class="token operator" style=color:#393A34>></span><span class="token plain"> pixels</span><span class="token punctuation" style=color:#393A34>;</span><span class="token plain"></span><br/></div><div class=token-line style=color:#393A34><span class="token plain"></span><span class="token punctuation" style=color:#393A34>}</span><br/></div></code></pre></div></div>
<p>Without the generated serializer metadata, Android may not expose enough nested type information for
Fory to preserve annotations such as <code>@Ref</code>, <code>@Int8Type</code>, <code>@UInt8Type</code>, <code>@Float16Type</code>, or
<code>@BFloat16Type</code>.</p>
<p>The annotation processor emits generated consumer R8/ProGuard rules under <code>META-INF/proguard/</code> for
the exact serializer constructors used by Fory. Android applications should not add broad generated
serializer keep rules by hand.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id=compatible-reads>Compatible Reads<a href=#compatible-reads class=hash-link aria-label="Direct link to Compatible Reads" title="Direct link to Compatible Reads" translate=no></a></h2>
<p>Static generated serializers support both normal serialization and compatible-mode reads. Compatible
reads match remote fields to local fields, skip fields that no longer exist locally, and keep Java
default values for fields that are missing from the remote payload.</div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="row margin-top--sm theme-doc-footer-edit-meta-row"><div class="col noPrint_WFHX"><a href=https://github.com/apache/fory-site/tree/main/docs/guide/java/static-generated-serializers.md target=_blank rel="noopener noreferrer" class=theme-edit-this-page><svg fill=currentColor height=20 width=20 viewBox="0 0 40 40" class=iconEdit_Z9Sw aria-hidden=true><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"/></g></svg>Edit this page</a></div><div class="col lastUpdated_JAkA"></div></div></footer></article><nav class="docusaurus-mt-lg pagination-nav" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href=/docs/guide/java/schema_metadata><div class=pagination-nav__sublabel>Previous</div><div class=pagination-nav__label>Schema Metadata</div></a><a class="pagination-nav__link pagination-nav__link--next" href=/docs/guide/java/object_copy><div class=pagination-nav__sublabel>Next</div><div class=pagination-nav__label>Object Copy</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href=#install-the-annotation-processor class="table-of-contents__link toc-highlight">Install The Annotation Processor</a><li><a href=#annotate-classes class="table-of-contents__link toc-highlight">Annotate Classes</a><li><a href=#field-debug-tracing class="table-of-contents__link toc-highlight">Field Debug Tracing</a><li><a href=#runtime-use class="table-of-contents__link toc-highlight">Runtime Use</a><li><a href=#field-access-rules class="table-of-contents__link toc-highlight">Field Access Rules</a><li><a href=#type-use-annotations-on-android class="table-of-contents__link toc-highlight">Type-Use Annotations On Android</a><li><a href=#compatible-reads class="table-of-contents__link toc-highlight">Compatible Reads</a></ul></div></div></div></div></main></div></div></div><footer class="theme-layout-footer footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Community</div><ul class="footer__items clean-list"><li class=footer__item><a href=https://lists.apache.org/list.html?dev@fory.apache.org target=_blank rel="noopener noreferrer" class=footer__link-item>Mailing list<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://join.slack.com/t/fory-project/shared_invite/zt-1u8soj4qc-ieYEu7ciHOqA2mo47llS8A target=_blank rel="noopener noreferrer" class=footer__link-item>Slack<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://twitter.com/ApacheFory target=_blank rel="noopener noreferrer" class=footer__link-item>Twitter<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Docs</div><ul class="footer__items clean-list"><li class=footer__item><a class=footer__link-item href=/docs/start/install>Install</a><li class=footer__item><a class=footer__link-item href=/docs/start/usage>Usage</a><li class=footer__item><a class=footer__link-item href=/docs/introduction/benchmark>Benchmark</a></ul></div><div class="theme-layout-footer-column col footer__col"><div class=footer__title>Repositories</div><ul class="footer__items clean-list"><li class=footer__item><a href=https://github.com/apache/fory target=_blank rel="noopener noreferrer" class=footer__link-item>Apache Fory™<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a><li class=footer__item><a href=https://github.com/apache/fory-site target=_blank rel="noopener noreferrer" class=footer__link-item>Website<svg width=13.5 height=13.5 aria-label="(opens in new tab)" class=iconExternalLink_nPIU><use href=#theme-svg-external-link /></svg></a></ul></div></div><div class="footer__bottom text--center"><div class=margin-bottom--sm><a href=https://apache.org/ rel="noopener noreferrer" class=footerLogoLink_BH7S><img src=/img/asf_logo.svg alt="ASF Logo" class="footer__logo themedComponent_mlkZ themedComponent--light_NVdE" width=200 /><img src=/img/asf_logo.svg alt="ASF Logo" class="footer__logo themedComponent_mlkZ themedComponent--dark_xIcU" width=200 /></a></div><div class=footer__copyright><div>
<p>
Copyright © 2026 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. <br/>
Apache Fory, Fory, Apache, the Apache Logo and the Apache Fory logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.
</p>
</div></div></div></div></footer></div></body>