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

Support missing attributes for @TemplateData / @RegisterForReflection #631

Merged

Conversation

angelozerr
Copy link
Contributor

Support missing attributes for @templatedata / @RegisterForReflection

Signed-off-by: azerr azerr@redhat.com

@angelozerr angelozerr force-pushed the RegisterForReflection_targets branch 9 times, most recently from 15b242b to b6af6ba Compare May 6, 2022 17:01
@angelozerr
Copy link
Contributor Author

angelozerr commented May 6, 2022

@rgrunber @AlexXuChen you can play now with my PR which supports:

  • @TemplateData/target
  • @TemplateData/ignore
  • @TemplateData/properties
  • @RegisterForReflection/targets

See the following demo:

TargetDemo

@angelozerr angelozerr force-pushed the RegisterForReflection_targets branch 5 times, most recently from a78c566 to 00c44af Compare May 9, 2022 16:09
@angelozerr
Copy link
Contributor Author

I noticed that in native mode we have thos error with size of List:

image

Although size is avalable as value resolvers (with Map https://quarkus.io/guides/qute-reference#maps but with List too, see https://github.com/quarkusio/quarkus/blob/e24fec4e2c4bd10edbfefd96e59b3a6f3608aaa9/independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java#L389)

We need to declare size as default value resolvers. We can do that in an another PR.

@angelozerr angelozerr force-pushed the RegisterForReflection_targets branch 2 times, most recently from f8a7b51 to 8d19ebc Compare May 10, 2022 06:40
@angelozerr angelozerr marked this pull request as ready for review May 10, 2022 06:49
@angelozerr angelozerr force-pushed the RegisterForReflection_targets branch 6 times, most recently from 27db75f to 2314db7 Compare May 12, 2022 16:06
@rgrunber
Copy link
Member

In the process of understanding @TemplateData, I notice something odd. It's not related to this specifically, but might be something needing to be addressed :

According to https://quarkus.io/guides/qute-reference#native_executables, type-safe expressions are safe to use in a native image. So I defined a template through @Inject and added some data (eg. .data("person", new Person(...)) to it. I then made sure the data type was declared as a parameter in the template (eg. {@org.example.Person person}). Then I enabled qute.native.enabled and noticed that the template file usage of Person was marked as invalid. However, the binary works just fine, as confirmed by the reference guide.

@angelozerr angelozerr force-pushed the RegisterForReflection_targets branch 2 times, most recently from 34d6afb to 1480772 Compare May 17, 2022 13:59
Copy link
Contributor

@AlexXuChen AlexXuChen left a comment

Choose a reason for hiding this comment

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

Something I noticed in relation to the qute.native.enabled setting is that when enabled, although the resolver list isn't populated with the field/method, the definition and hover still works. For example, if we use java.lang.String.class in target:
Peek 2022-05-17 12-02
This also applies to ignore, where the ignored field still has definition/hover support:
Peek 2022-05-17 12-19

@angelozerr
Copy link
Contributor Author

Something I noticed in relation to the qute.native.enabled setting is that when enabled, although the resolver list isn't populated with the field/method, the definition and hover still works.

Indeed but I think it is nice to have that because navigation can be helpfull to go the Java class easily and it follows the same behavior of JDT Java when you try to open a private method:

StringDemo

@angelozerr angelozerr self-assigned this May 18, 2022
Copy link
Member

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Type-safe expressions don't cause warnings to be emitted on the type when the native image setting is enabled, and target attribute for @TemplateData seems to be working for me.

@angelozerr angelozerr force-pushed the RegisterForReflection_targets branch 4 times, most recently from f63fc82 to 7daa603 Compare June 3, 2022 12:44
@angelozerr angelozerr merged commit 4f7a13c into redhat-developer:master Jun 3, 2022
@angelozerr angelozerr added this to the v0.12.0 milestone Jun 3, 2022
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.

None yet

3 participants