Simplify the AnnotationIntrospector SPI: return a ClassInfo instead of many per-element queries

オープン
#178 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
静か
技術スタック
java
領域
backend

調査の方向性

まず opa-evaluator の AnnotationIntrospector と DefaultAnnotationIntrospector を読み、次に opa-jackson の実装と mapper の呼び出し箇所を調査します。ClassInfo 型のディスクリプタで、遅延解決または部分解決を維持しながら、一覧にあるメタデータを保持できるか確認します。SPI と影響を受ける実装および呼び出し箇所が合意された単一エントリポイントの契約を使用し、サポート対象のメタデータと null 引数の動作をテストでカバーできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement

Follow-up from PR #110 review: https://github.com/open-policy-agent/java-opa-sdk/pull/110#discussion_r3644681150 (johanfylling).

Context

AnnotationIntrospector (in opa-evaluator, io.github.open_policy_agent.opa.mapper) is the SPI the mapper consults to resolve annotation-driven property metadata without binding the evaluator to a specific JSON library. Today it exposes many fine-grained "ask a question" methods:

String findPropertyName(Method getter, Field backingField);
boolean isIgnored(Method getter, Field backingField);
boolean isNonNullInclude(Method getter, Field backingField);
String findCreatorParamName(Parameter param);
boolean isJsonCreator(Constructor<?> ctor);
boolean isJsonCreator(Method method);
Visibility findFieldVisibility(Class<?> clazz);
boolean isJsonValue(Method method);
Proposal

As suggested in review, consider inverting the shape: instead of the mapper asking the introspector a series of questions per element, give the introspector a Class<?> and have it hand back a resolved descriptor (e.g. ClassInfo) that carries the property names, ignored set, null-inclusion, creator info, visibility, and JSON-value method in one pass.

Potential benefits:

  • Simpler SPI surface (one entry point instead of eight).
  • Implementations can resolve a class once rather than being re-queried per getter/field/parameter.
  • Clearer contract for the null-argument combinations that the current per-element methods have to document.
Scope / notes
  • Not blocking; raised on PR #110 as out of scope for that change.
  • Affects opa-evaluator (the SPI + DefaultAnnotationIntrospector) and the opa-jackson implementation, plus the mapper call sites.
  • Worth confirming the one-pass model still supports lazy/partial resolution where the mapper only needs a subset.
主要言語
Java
スター
20
フォーク
30
平均マージ
1日 10時間
マージ済み PR(30日)
34

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

open-policy-agent/java-opa-sdk のほかの issue

open-policy-agent/java-opa-sdk の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。