public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Arvydas Silanskas <nma.arvydas.silanskas@gmail.com>
To: Ross Merrifield <rosswmerrifield@gmail.com>
Cc: kawa@sourceware.org
Subject: Re: Having trouble using JAX-RS annotation in Kawa Scheme class
Date: Tue, 28 Feb 2023 19:37:14 +0200	[thread overview]
Message-ID: <CAPh7weCi8TjekWvzMp7q=_NegnBQYtbCjJbhjFO_r6Q2eV+fNA@mail.gmail.com> (raw)
In-Reply-To: <CAO1-sXhpnn-UfsJAsWmdRFfn1nBhcBToK9TKFeSB05ZSMys+8Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2225 bytes --]

Hi,

try specifying the annotation field explicitly, ie `(@Produces value:
(string[] "text/plain"))`. Test suite seems to have a test for this case
https://gitlab.com/kashell/Kawa/-/blob/master/testsuite/annotations1.scm#L33
. If this still doesn't work, perhaps try building and running the head
version from source.

Arvydas

2023-02-28, an, 19:02 Ross Merrifield via Kawa <kawa@sourceware.org> rašė:

> Kawa mailing list,
>
> I am attempting to translate a simple JAX-RS example from Java to Kawa
> Scheme. Overall, this has been successful, but I am having issues getting
> the @Produces method annotation to work in one of my classes.
>
> Here is my Kawa class:
>
> (import (class jakarta.ws.rs  GET
>                               Path
>                               Produces))
>
> (define-simple-class MyResource ()
>   (@Path "helloworld")                    ;;class annotations
>
>   ((getIt)                                ;;method (no args)
>     (@GET)                                ;;method annotations
>     (@Produces (String "text/plain"))
>     ::java.lang.String                    ;;return type
>     "Got it!")                            ;;method body
> )
>
> And here is the Java class I am translating it from:
>
> import jakarta.ws.rs.GET;
> import jakarta.ws.rs.Path;
> import jakarta.ws.rs.Produces;
>
> @Path("helloworld")
> public class MyResource {
>     @GET
>     @Produces("text/plain")
>     public String getHello() {
>         return "Hello World!";
>     }
> }
>
> The problem is, when I try to load the code, I get an error that "the type
> java.lang.String is incompatible with the required type
> java.lang.String[]".
> But when I change my Annotation to (@Produces (String[] "text/plain")) I
> get the error "annotation value must be constant". Checking the javadoc for
> @prodcues does indicate the expected type of the value is String[]:
>
>
> https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/latest/jakarta.ws.rs/jakarta/ws/rs/Produces.html
>
> Is there another syntax I should be trying here? As it stands now, it seems
> to me like it's impossible to use this annotation from Kawa.
>
> Thanks,
>
> Ross
>

  reply	other threads:[~2023-02-28 17:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 17:01 Ross Merrifield
2023-02-28 17:37 ` Arvydas Silanskas [this message]
2023-02-28 19:03   ` Ross Merrifield
2023-02-28 19:26 ` Per Bothner
2023-02-28 19:42   ` Ross Merrifield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPh7weCi8TjekWvzMp7q=_NegnBQYtbCjJbhjFO_r6Q2eV+fNA@mail.gmail.com' \
    --to=nma.arvydas.silanskas@gmail.com \
    --cc=kawa@sourceware.org \
    --cc=rosswmerrifield@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).