open-policy-agent / open-policy-agent/java-opa-sdk
Simplify the AnnotationIntrospector SPI: return a ClassInfo instead of many per-element queries
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 16
- Forks
- 24
- Avg merge
- 8h 17m
- Merged PRs (30d)
- 15
Description
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 theopa-jacksonimplementation, plus the mapper call sites. - Worth confirming the one-pass model still supports lazy/partial resolution where the mapper only needs a subset.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading AnnotationIntrospector and DefaultAnnotationIntrospector in opa-evaluator, then inspect the opa-jackson implementation and mapper call sites. Confirm whether a ClassInfo-style descriptor can carry the listed metadata while preserving lazy or partial resolution. Done means the SPI and affected implementations and call sites use the agreed one-entry-point contract, with tests covering the supported metadata and null-argument behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100