Skip to content
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

Remove allowWrite and allowUnsafeAccess from FieldHints #29047

Closed
jvalkeal opened this issue Aug 31, 2022 · 9 comments
Closed

Remove allowWrite and allowUnsafeAccess from FieldHints #29047

jvalkeal opened this issue Aug 31, 2022 · 9 comments
Assignees
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@jvalkeal
Copy link
Contributor

ReflectionHints with fields on default adds allowWrite while in graal its value is optional and should be set to true if write should be allowed. We should not write this field unless user explicitely defines it so that we can have whatever graal does when field is not present.

{
  "name": "org.example.Clazz",
  "fields": [
    {
      "name": "value",
      "allowWrite": true
    }
  ]
}

Though looking graal sources these fields allowWrite and allowUnsafeAccess has been deprecated since 21.1 meaning we could probably just remove both.

https://github.com/oracle/graal/blob/22a947877c1d1cff07186999d5b9365f09c2466f/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/hosted/RuntimeReflection.java#L120-L129

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 31, 2022
@sreenath-tm
Copy link
Contributor

I'm interested in contributing to this issue, so before I start working it, would you mind sparing your time pointing me to some resources to get started.

@snicoll snicoll changed the title Remove/deprecate or change allowWrite/allowUnsafeAccess Remove allowWrite and allowUnsafeAccess from FieldHints Sep 5, 2022
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 5, 2022
@snicoll snicoll added this to the 6.0.0-M6 milestone Sep 5, 2022
@snicoll
Copy link
Member

snicoll commented Sep 5, 2022

The issue is yours @sreenath-tm but please keep in mind that our next milestone is due in 10 days. If you don't get to it by then, just let us know and we'll take over.

The changes are to be done by removing FieldHint altogether and changing TypeHint.Builder to hold a Set of field names, to be translated to MemberHint in TypeHint's constructor. Further simplifications are due in the predicates but we can polish that as part of merging. Let me know if you have any question.

@sreenath-tm
Copy link
Contributor

The MemberHint does not have a Builder so for replacing the removed FieldHint where can we generate the set of field names that is referenced in the TypeHint class.

@snicoll
Copy link
Member

snicoll commented Sep 8, 2022

In TypeHint.Builder there is a private final Map<String, FieldHint.Builder> fields = new HashMap<>();. I am suggessting to replace that with a Set<String>. If the field is registered multiple times, the set will make sure to keep only one copy. MemberHint should no longer be abstract or we can maybe keep a FieldHint. Does that help?

@sreenath-tm
Copy link
Contributor

1 ) Is moving the code from our FieldHint to MemberHint recommended.

2 ) I replaced the FieldHint related references and replaced with Set fields but There are 2 usages of the FieldHint that I just require clarification on how we can handle that.
There are public Builder withField(String name, FieldMode mode) { return withField(name, FieldHint.builtWith(mode)); }
and public Builder withField(String name, Consumer<String> fieldHint) { FieldHint.Builder builder = this.fields.computeIfAbsent(name, FieldHint.Builder::new); fieldHint.accept(builder); return this; }

@snicoll
Copy link
Member

snicoll commented Sep 8, 2022

  1. No. FieldHint should only have a name attribute, which is what this issue is all about.
  2. They should go away completely and replaced by withField(String name) as the additional attributes should be removed.

@snicoll
Copy link
Member

snicoll commented Sep 10, 2022

@sreenath-tm how is it going? Sorry to say but we'd like this (and a few related changes) to get in earlier next week so that the team can adapt their code in preparation of the release Thursday. If you have some work in progress you'd like to share, you can submit a PR and I can complete it if necessary. Thanks!

@sreenath-tm
Copy link
Contributor

@snicoll I have changed the corresponding FieldHint and all the instances of FieldHint. I am still figuring out the usages of the FieldHint class and the impact the removal it can cause.Will raise a draft PR so that you can also take a look at it.

@snicoll
Copy link
Member

snicoll commented Sep 10, 2022

Closing in favor of PR #29130

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2022
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Sep 10, 2022
@snicoll snicoll removed this from the 6.0.0-M6 milestone Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants