Coder Social home page Coder Social logo

Comments (7)

gsmet avatar gsmet commented on June 1, 2024 1

https://quarkus.io/guides/update-quarkus can help if you want to do a quick update/test on newer versions.

from quarkus.

mkouba avatar mkouba commented on June 1, 2024 1

@mkouba - Thank you for trying this out! Yes if I change the signature to match (I've tried Strings to ensure not confusing ints and longs again..) the tests pass on both 3.2 and 3.8 versions.

👍

I'm still running into the issue with the 2.16 version my company uses, but I'll just use the workaround of calling a wrapper method on a non-cdi bean.

Unfortunately, we do not plan to backport any qute-related fixes into 2.16. But your workaround seems reasonable.

@TemplateExtension(namespace = "obj")
public class ObjectExtensionMethods {
    public static Object[] varargs(Object... args) {
        return args;
    }
}

(Not knowing the workflow on this repo I'm fine with this ticket being closed)

Yes, I will close this issue and create a new one to implement "Widening Primitive Conversion" in templates.

from quarkus.

quarkus-bot avatar quarkus-bot commented on June 1, 2024

/cc @mkouba (qute)

from quarkus.

mkouba avatar mkouba commented on June 1, 2024

@markus-lehr-dedalus Have you tried with some newer version, i.e. Quarkus 3.2 or 3.8? I do remember that some problems with varargs parameters were fixed.

from quarkus.

markus-lehr-dedalus avatar markus-lehr-dedalus commented on June 1, 2024

Have you tried with some newer version, i.e. Quarkus 3.2 or 3.8?

I created a small reproducer project with both Quarkus 3.8.3 and 3.2.11.Final and indeed the varargs issue persists for CDI beans.
If you look at the test: QuteVarargsTest.java
You can see that varargs work with static namespaced extension methods (first few tests with obj:varargs) but not with the cdi bean's method (i.e. the last 3 tests fail). (Just to prove that the cdi bean is being called and works for non-varargs methods, I created an identity method which just returns whatever int is being haded to it).

from quarkus.

mkouba avatar mkouba commented on June 1, 2024

@markus-lehr-dedalus So I've tried to reproduce the problem locally and found an error in the test. The first parameter of the method declared on the CdiExtension is long but you pass an integer literal in the template. If you change the type of the param to int or modify the template like {cdi:varargsTemplateExtension.varargs(5l, foo)} then the test passes.

That said, I understand that Java does convert the type automatically (Widening Primitive Conversion) but templates don't support this feature yet.

from quarkus.

markus-lehr-dedalus avatar markus-lehr-dedalus commented on June 1, 2024

@mkouba - Thank you for trying this out! Yes if I change the signature to match (I've tried Strings to ensure not confusing ints and longs again..) the tests pass on both 3.2 and 3.8 versions.

I'm still running into the issue with the 2.16 version my company uses, but I'll just use the workaround of calling a wrapper method on a non-cdi bean.

@TemplateExtension(namespace = "obj")
public class ObjectExtensionMethods {
    public static Object[] varargs(Object... args) {
        return args;
    }
}

(Not knowing the workflow on this repo I'm fine with this ticket being closed)

from quarkus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.