Skip to content

fix: Use field getters/setters when available, enforce getters/setters are public#2072

Draft
Christopher-Chianelli wants to merge 2 commits intoTimefoldAI:mainfrom
Christopher-Chianelli:fix/1862
Draft

fix: Use field getters/setters when available, enforce getters/setters are public#2072
Christopher-Chianelli wants to merge 2 commits intoTimefoldAI:mainfrom
Christopher-Chianelli:fix/1862

Conversation

@Christopher-Chianelli
Copy link
Contributor

@Christopher-Chianelli Christopher-Chianelli commented Feb 4, 2026

Before, this is how domain accessors were created:

  • Annotation on the field? Make that field accessible and read/write directly to it.
  • Annotation on a getter method? Make that method accessible, and pair it with the corresponding setter (if available) and read/write using the method pair.

Now, domain accessors are created like this:

  • Annotation on the field? If the field has a getter, enforce that getter is public. If there is a setter but no getter, fail-fast. Use the field getter/setter for the MemberAccessor; only directly read/write the field if the field is public and there are no getters or setters for the field. Fail-fast otherwise.
  • Annotation on a getter method? Enforce the getter is public, and pair it with the corresponding setter (if available, fail if there a setter and not public), and read/write using the method pair.

Quarkus generated MemberAccessors will also follow these same rules and use getters/setters if available.

This is a breaking change. Do not merge until 2.0 is branched.

Fixes #1862 and #1710.

Copy link
Collaborator

@triceo triceo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this!

We need to figure out what to do with Gizmo. Personally, I'd just remove Gizmo from core, I don't see much point. It's not being used, and it complicates the codebase.

That said, I'm open to keeping Gizmo in core, if we can make it the default without changing any of the rules we just defined. In that case, it would only have benefits and therefore reflection-based access could be removed entirely.

Side note: there seem to be failing tests.

…s are public

Before, this is how domain accessors were created:

- Annotation on the field? Make that field accessible and read/write
  directly to it.
- Annotation on a getter method? Make that method accessible, and pair
  it with the corresponding setter (if available) and read/write using
  the method pair.

Now, domain accessors are created like this:

- Annotation on the field? If the field has a getter, enforce that
  getter is public. If that field is not final, also enforce there
  is a public setter for the field. If there is a setter but no
  getter, also fail. Use the field getter/setter for the MemberAccessor;
  only directly read/write the field if the field is public and there
  are no getters or setters for the field. Fail-fast otherwise.
- Annotation on a getter method? Enforce the getter is public, and
  pair it with the corresponding setter (if available, fail if there
  a setter and not public), and read/write using the method pair.

Quarkus generated MemberAccessors will also follow these same rules
and use getters/setters if available.

This is a breaking change.

Fixes TimefoldAI#1862 and TimefoldAI#1710.
Additionally, the code for GIZMO to use getters/setters is now
done in core.
@Christopher-Chianelli
Copy link
Contributor Author

Gizmo in core was modified to use getters/setters for fields if available.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No longer rely on deep reflection for field access

2 participants