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

Consider providing thymeleaf reflect-config.json for GraalVM Native Image #334

Open
sdelamo opened this issue Dec 17, 2021 · 4 comments
Open

Comments

@sdelamo
Copy link
Contributor

sdelamo commented Dec 17, 2021

Issue description

Executing the micronaut-live-newsletter app with the agent generates at latest the following config:

[
{
  "name":"org.thymeleaf.context.AbstractEngineContext",
  "queryAllDeclaredMethods":true,
  "queryAllPublicMethods":true}
,
{
  "name":"org.thymeleaf.context.IContext",
  "queryAllDeclaredMethods":true}
,
{
  "name":"org.thymeleaf.context.IEngineContext",
  "queryAllDeclaredMethods":true}
,
{
  "name":"org.thymeleaf.context.IExpressionContext",
  "queryAllDeclaredMethods":true}
,
{
  "name":"org.thymeleaf.context.ITemplateContext",
  "queryAllDeclaredMethods":true}
,
{
  "name":"org.thymeleaf.standard.expression.AdditionExpression",
  "methods":[{"name":"<init>","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression","org.thymeleaf.standard.expression.IStandardExpression"] }]}
,
{
  "name":"org.thymeleaf.standard.expression.AdditionSubtractionExpression",
  "methods":[
    {"name":"isLeftAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }, 
    {"name":"isRightAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }
  ]}
,
{
  "name":"org.thymeleaf.standard.expression.AndExpression",
  "queriedMethods":[
    {"name":"isLeftAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }, 
    {"name":"isRightAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }
  ]}
,
{
  "name":"org.thymeleaf.standard.expression.EqualsNotEqualsExpression",
  "queriedMethods":[
    {"name":"isLeftAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }, 
    {"name":"isRightAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }
  ]}
,
{
  "name":"org.thymeleaf.standard.expression.GreaterLesserExpression",
  "queriedMethods":[
    {"name":"isLeftAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }, 
    {"name":"isRightAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }
  ]}
,
{
  "name":"org.thymeleaf.standard.expression.MultiplicationDivisionRemainderExpression",
  "queriedMethods":[
    {"name":"isLeftAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }, 
    {"name":"isRightAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }
  ]}
,
{
  "name":"org.thymeleaf.standard.expression.OrExpression",
  "queriedMethods":[
    {"name":"isLeftAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }, 
    {"name":"isRightAllowed","parameterTypes":["org.thymeleaf.standard.expression.IStandardExpression"] }
  ]}
]

see #302

@ilopmar
Copy link
Contributor

ilopmar commented Dec 17, 2021

As discussed with Sergio we should review all the "*Expression" and related classes and configure them in the module. The tracing agent only generates config for what's used in the test application but not for everything, so we need to do it so anything that a user uses works.

@gijsleussink
Copy link

gijsleussink commented Dec 19, 2023

As I'm working with Thymeleaf now and creating native-image, I could take a look. What was meant by "configure them in the module"?

There are many classes that are easily traced by the GraalVM Tracing Agent. I have some difficulties with OGNLShortcutExpression and OGNLVariableExpressionEvaluator and did not get traced. They do some more trickery with reflection.
Perhaps @danielfernandez could help us here? In the end, using Thymeleaf from within a GraalVM native image is really a cool feature.

@sdelamo
Copy link
Contributor Author

sdelamo commented Dec 20, 2023

Yes, I like Thymeleaf and use it with native image. However, It is difficult to say what belongs in the module and what belongs in the user application. Yesterday, for example, we had to add this commit setting some classes accessed by Thymeleaf as reflective and providing some config as well.

@gijsleussink
Copy link

I added the application specific classes (by using the native-image-agent and running the application) and my application now works as a native image. With that, I agree that it's difficult to say what needs to be added from Thymeleaf or Views and from the user application 🤔

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

No branches or pull requests

3 participants