Skip to content

Add the ability to access type annotations for Java #3114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jrhee17
Copy link

@jrhee17 jrhee17 commented Mar 24, 2025

#2553 had added the ability to access field annotations in java.

In our use-case, we would like to annotate arbitrary types and re-use it without explicitly re-annotating each field.

e.g.

struct should_mask {
} (a = "b")

struct struct_1 {
  1: should_mask field;
}

struct struct_2 {
  1: should_mask field;
}

instead of

struct should_mask {
}

struct struct_1 {
  1: should_mask field (a = "b")
}

struct struct_2 {
  1: should_mask field (a = "b")
}

I would like to propose that FieldMetaData#getFieldAnnotations returns annotations on types as well to achieve this.

Misc1) If it feels safer to hide this change behind an option (i.e. type_annotations_as_metadata_), then I can also make this change

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@jrhee17 jrhee17 changed the title Add type annotations for java Add the ability to access type annotations for Java Mar 24, 2025
@Jens-G Jens-G added the java Pull requests that update Java code label Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Pull requests that update Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants