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

Qute can't find all fields defined on parent interfaces with strict rendering enabled #19564

Closed
wjglerum opened this issue Aug 22, 2021 · 7 comments · Fixed by #19722
Closed
Assignees
Labels
area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@wjglerum
Copy link
Contributor

wjglerum commented Aug 22, 2021

Describe the bug

Looks like Qute can't find certain fields when you use a nested class hierarchy.

For example, in our project we extensively use Immutables for our domain objects. And we use wrappers around primitives, see https://immutables.github.io/immutable.html#wrapper-types

When we use this in combination with checked templates and strict rendering it does not work and Qute complains about incorrect expressions. See the example below:

public interface Wrapper<T> {
    T value();
}

public interface Count extends Wrapper<Integer> {
}

public interface Metrics {

    Count requests();

    Count responses();
}
[1] Incorrect expression found: {metrics.responses.value.?:(0)}
	- property/method [value] not found on class [nl.wjglerum.Count] nor handled by an extension method
	- at MetricResource/strict.qute.html:4
	at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:196)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:829)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
	Suppressed: io.quarkus.qute.TemplateException: Incorrect expression found: {metrics.responses.value.?:(0)}
	- property/method [value] not found on class [nl.wjglerum.Count] nor handled by an extension method
	- at MetricResource/strict.qute.html:4
		at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:176)
		... 11 more

However when we don't use checked templating or disable the strict rendering it does work as expected.

If I provide an extra method on Wrapper.class it does work again:

default T getValue() {
    return value();
}

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

Provided a reproducer here https://github.com/wjglerum/quarkus-qute-strict

Output of uname -a or ver

Darwin Willems-MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

Output of java -version

openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Maven home: /Users/wjglerum/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1
Java version: 11.0.11, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Default locale: en_NL, platform encoding: UTF-8
OS name: "mac os x", version: "11.5", arch: "x86_64", family: "mac"

Additional information

No response

@wjglerum wjglerum added the kind/bug Something isn't working label Aug 22, 2021
@quarkus-bot quarkus-bot bot added the area/qute The template engine label Aug 22, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 22, 2021

/cc @mkouba

@wjglerum
Copy link
Contributor Author

I noticed this especially after trying the 2.2.0.CR1 release, where expressions in includes and user tags are also checked, see #18930

@mkouba
Copy link
Contributor

mkouba commented Aug 26, 2021

Thanks for reporting! The problem is that we only consider interface default methods. I'm not sure why exactly. I'll take a deeper look tomorrow.

@mkouba
Copy link
Contributor

mkouba commented Aug 27, 2021

Hm, I didn't find a reason why only default methods, so here's the PR: #19722

@mkouba mkouba added this to the 2.3 - main milestone Aug 27, 2021
@wjglerum
Copy link
Contributor Author

Thanks a lot! Already had a look at the processor the other day myself, but wasn't sure if and what to change.

Any chance we could still include this for the 2.2 release of next week?

@mkouba
Copy link
Contributor

mkouba commented Aug 27, 2021

I've marked the PR with the triage/backport? label so hopefully it will be included ;-).

@wjglerum
Copy link
Contributor Author

wjglerum commented Aug 27, 2021

Cool 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants