Gson Deserialization and the InaccessibleObjectException
Baeldung作者:Marcin Buczkowski發布:09-15 05:32
Gson Deserialization and the InaccessibleObjectException
Two main ways avoid the exception: open code to Gson, or switch to records and stay within JPMS rules.
重點摘要
Strong encapsulation in Java 9+ can block Gson reflection in modular projects.
POJOs may fail with InaccessibleObjectException, while records deserialize successfully out of the box.
Workarounds include public fields, opens, TypeAdapter, or --add-opens; date handling now supports nested java.time objects in Gson 2.14.0.
展開詳細摘要
Java 9+ strong encapsulation and JPMS can prevent Gson from using reflection on private fields, causing InaccessibleObjectException during deserialization in modular projects. The article shows that a POJO may fail on the module path, while a Java record works because Gson uses its canonical constructor. For POJOs, the article presents four approaches: make fields public, open the package to com.google.gson, write a custom TypeAdapter, or use the JVM --add-opens argument as a last resort. It also explains that Gson 2.14.0 restores support for nested java.time values through built-in adapters, while ISO-formatted date strings still require a custom adapter.
Gson 反序列化与 InaccessibleObjectException
避免该异常的两条主线:把代码开放给 Gson,或改用 records 并遵守 JPMS 规则。
重點摘要
Java 9 之后的强封装和 JPMS 会限制 Gson 通过反射访问私有字段。
模块化项目中的 POJO 可能失败,但 records 可以直接成功反序列化。
可用 public 字段、opens、TypeAdapter 或 --add-opens 处理;Gson 2.14.0 也支持嵌套的 java.time 对象。
Modularization Isn't Just Cleaner Code — It's a Build-Time Lever
A single-module Android app was split into core/feature modules with the same functionality and screens, then rebuilt to measure the difference.
重點摘要
Incremental build time dropped from 3.744s to 2.614s.
The comparison kept the same app behavior and screens.
Both versions are in the repo for reproducible testing.
展開詳細摘要
The author split a single-module Android app into a core/feature module structure while keeping the same functionality and screens, then compared incremental build times by touching one file and rebuilding. The monolith build took 3.744 seconds, while the modularized version took 2.614 seconds, about 30% faster. The repository includes both the main and monolith-baseline versions so others can reproduce the comparison. The stack used is Kotlin, Compose, Hilt, and Gradle version catalogs.
~40k LOC, Shared 90%: Building a Cross-Platform Shared E-bike Ops App
Dev.to Kotlin作者:Peter wang發布:09-15 05:32
~40k LOC, Shared 90%: Building a Cross-Platform Shared E-bike Ops App
The whole project is roughly 40,000 lines of Kotlin, with about 90% living in a shared layer used by both platforms.
重點摘要
~40 screens were split into business UI and a small set of native SDK touchpoints.
KMP handles business core and shared UI; host shells only inject platform capabilities.
Two migration rounds moved the app from 81% shared code to 95.8% shared code.
展開詳細摘要
This article explains how a shared e-bike operations app was built around a Kotlin Multiplatform core instead of duplicating the product for Android and iOS. The team first analyzed the app’s roughly 40 screens and found that most were stable business forms, while only a few areas truly needed native SDKs such as maps, Bluetooth, camera scanning, location, and uploads. Based on that split, they chose KMP for business logic, Compose Multiplatform for shared UI, H5 for dashboards, and thin host shells for platform-specific capabilities. Two migration rounds then moved map screens and the navigation shell out of Android host code, raising shared code from 81% to 95.8%. The article also covers i18n, platform contracts, and the repo’s current shipping scope.
Part 7 — Case Study: Building a Terminal UI with the Compose Runtime (Mosaic)
Medium Kotlin作者:Android Expert發布:09-15 02:57
Part 7 — Case Study: Building a Terminal UI with the Compose Runtime (Mosaic)
Part 7 of a 7-part series proving Jetpack Compose is a UI-agnostic runtime by rendering it straight to your terminal.
重點摘要
Final part of a seven-part series
Shows Compose running in a terminal UI
Argues Compose is UI-agnostic
展開詳細摘要
This final installment in the seven-part series presents a case study of rendering Jetpack Compose directly in a terminal using Mosaic. The article’s core point is that Compose can function as a UI-agnostic runtime, not just as a toolkit for traditional Android screens. By targeting the terminal, the series aims to demonstrate Compose’s flexibility across presentation layers while staying within the constraints described in the original post.
I Prepared for a Senior Android Interview at a Ride-Hailing Company.
Medium Kotlin作者:Saif Khan發布:09-15 06:33
I Prepared for a Senior Android Interview at a Ride-Hailing Company
Most Android interview prep lists are useless.
重點摘要
Common prep lists focus on basics like defining an Activity.
Real interviews test practical Android problems.
Battery drain is one example of the questions candidates should expect.
展開詳細摘要
The article argues that many Android interview prep lists are shallow and unhelpful because they focus on textbook definitions instead of real-world engineering concerns. In actual senior interviews, candidates are more likely to be asked about practical issues such as why an app drains the battery, rather than simply defining core Android components. The piece sets up a more realistic view of interview preparation for Android roles.
The article contains only an introduction and no substantive content.
Readers are directed to continue reading on Medium.
No technical details about Jetpack Navigation 3 are provided in the excerpt.
展開詳細摘要
The provided excerpt is extremely limited and includes only the heading, author, link, and a brief introduction note that says “Continue reading on Medium.” It does not contain any actual discussion of Jetpack Navigation 3, Compose changes, feature updates, previews, or implementation details. As a result, there is no substantive technical content to summarize beyond the fact that the full article is hosted on Medium.
Jetpack Navigation 3:Compose 有哪些新变化
引言
重點摘要
本文摘录只有引言,没有实质内容。
文中引导读者继续前往 Medium 阅读。
摘录中未提供 Jetpack Navigation 3 与 Compose 的技术细节。
展開詳細摘要
这段原文摘录非常有限,只包含标题、作者、链接,以及一句“Continue reading on Medium”。摘录中没有真正介绍 Jetpack Navigation 3 在 Compose 方面的更新、功能变化、预览状态或实现细节,因此无法从现有内容整理出具体技术重点;能够确认的信息只有完整文章需到 Medium 查看。
Jetpack Navigation 3:Compose 有哪些新變化
前言
重點摘要
本文摘錄僅有前言,未提供實質內容。
文中引導讀者前往 Medium 繼續閱讀。
摘錄中沒有 Jetpack Navigation 3 與 Compose 的技術細節。
展開詳細摘要
這段原文摘錄內容非常有限,只包含標題、作者、連結,以及一句「Continue reading on Medium」。截錄中沒有實際說明 Jetpack Navigation 3 在 Compose 上的更新、功能變動、預覽狀態或實作細節,因此無法從這份內文延伸出技術重點;可確認的資訊只有完整文章需前往 Medium 閱讀。