Android suitability: fix AnimalSniffer violations in ReflectionUtil, ObjectLayoutBuilder, UIText clipboard

Đang mở
#84 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, java
Lĩnh vực
backend, mobile-dev

Hướng nghiên cứu

Read the Technical Notes and inspect UIText's clipboard methods, its private AwtClipboard class, and the nui-libgdx integration. Design a pluggable clipboard strategy that keeps the AWT behavior on desktop and uses Gdx.app.getClipboard() on Android; verify copy and paste work on both platform types.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Type: Improvement

AI-assisted issue. Filed by agent driven by @soloturn via GDD.

Context

Wiring up the AnimalSniffer + gummy-bears-api-24 Android-suitability check (#83) surfaced 21 real violations across two modules — genuine gaps between NUI's API surface and what's available on Android, not signature-set false positives. Concrete motivation: DestinationSol's engine module depends directly on nui, nui-libgdx, nui-gestalt, and nui-reflect, and targets Android via libGDX.

Problem / Current State

  • nui-reflect: ReflectionUtil — 6 violations. resolvedMethodToString took a java.lang.reflect.Executable parameter and called getTypeParameters()/getName()/getDeclaringClass()/getGenericParameterTypes()/isVarArgs() on it directly. Executable itself isn't available before API 26, even though Method and Constructor each declare these same methods directly and have since long before API 24. typeToString also called Class.getTypeName() (API 26+).
  • nui: ObjectLayoutBuilder — 2 violations. Used Constructor.getParameters() (returns Parameter[]) and Parameter.getParameterizedType() to build the argument-type list. java.lang.reflect.Parameter itself isn't available before API 26.
  • nui: UIText clipboard — 13 violations. getClipboardContents()/setClipboardContents() use java.awt.Toolkit/Clipboard/DataFlavor/StringSelection/Transferable/UnsupportedFlavorException directly. Unlike the above two, this isn't fixable by calling a different method — AWT genuinely doesn't exist on Android at all.

Acceptance Criteria

  • ReflectionUtil violations fixed by calling through the concrete Method/Constructor type instead of the shared Executable supertype, and reimplementing Class.getTypeName()'s behavior — no public API change (#83)
  • ObjectLayoutBuilder violations fixed by using Constructor.getGenericParameterTypes() instead of going through Parameter — no public API change (#83)
  • UIText clipboard calls isolated into a private nested class (UIText.AwtClipboard) with LinkageError caught by the caller, so invoking copy/paste on a platform without java.awt degrades to a no-op with a logged warning instead of crashing (#83)
  • UIText actually has a working clipboard on platforms without AWT (e.g. Android via nui-libgdx, since libGDX's Gdx.app.getClipboard() is a cross-platform abstraction that works there), not just a graceful no-op — left open, see Technical Notes

Technical Notes

The last item is a real design decision, deliberately left out of #83 to keep that PR focused on the suitability check rather than a clipboard-abstraction redesign: likely a pluggable Clipboard strategy on UIText, defaulting to the current AWT-backed behavior on desktop, with nui-libgdx supplying a Gdx.app.getClipboard()-backed implementation for platforms (including Android) that have it.

Full violation reports (pre-fix, from #83's initial run): nui/build/reports/animalsniffer/main.text, nui-reflect/build/reports/animalsniffer/main.text.

Related

#83

Ngôn ngữ chính
Java
Star
4
Fork
11
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MovingBlocks/TeraNUI

Tất cả issue của MovingBlocks/TeraNUI

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.