public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Having trouble using JAX-RS annotation in Kawa Scheme class
@ 2023-02-28 17:01 Ross Merrifield
  2023-02-28 17:37 ` Arvydas Silanskas
  2023-02-28 19:26 ` Per Bothner
  0 siblings, 2 replies; 5+ messages in thread
From: Ross Merrifield @ 2023-02-28 17:01 UTC (permalink / raw)
  To: kawa

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

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Having trouble using JAX-RS annotation in Kawa Scheme class
  2023-02-28 17:01 Having trouble using JAX-RS annotation in Kawa Scheme class Ross Merrifield
@ 2023-02-28 17:37 ` Arvydas Silanskas
  2023-02-28 19:03   ` Ross Merrifield
  2023-02-28 19:26 ` Per Bothner
  1 sibling, 1 reply; 5+ messages in thread
From: Arvydas Silanskas @ 2023-02-28 17:37 UTC (permalink / raw)
  To: Ross Merrifield; +Cc: kawa

[-- 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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Having trouble using JAX-RS annotation in Kawa Scheme class
  2023-02-28 17:37 ` Arvydas Silanskas
@ 2023-02-28 19:03   ` Ross Merrifield
  0 siblings, 0 replies; 5+ messages in thread
From: Ross Merrifield @ 2023-02-28 19:03 UTC (permalink / raw)
  To: Arvydas Silanskas; +Cc: kawa

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

Arvydas,

Adding the explicit value: still results in the "annotation value must be a
constant" error. I tried building Kawa from a git clone with Ant, but that
too is failing. I errors out during build of srfi14.scm due to a missing
file: char-tables.iscm

I'm open to suggestions, but I'll just try to work around this issue for
the time being.

Thanks,

Ross

On Tue, Feb 28, 2023 at 9:37 AM Arvydas Silanskas <
nma.arvydas.silanskas@gmail.com> wrote:

> 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
>>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Having trouble using JAX-RS annotation in Kawa Scheme class
  2023-02-28 17:01 Having trouble using JAX-RS annotation in Kawa Scheme class Ross Merrifield
  2023-02-28 17:37 ` Arvydas Silanskas
@ 2023-02-28 19:26 ` Per Bothner
  2023-02-28 19:42   ` Ross Merrifield
  1 sibling, 1 reply; 5+ messages in thread
From: Per Bothner @ 2023-02-28 19:26 UTC (permalink / raw)
  To: Ross Merrifield, kawa

On 2/28/23 09:01, Ross Merrifield via Kawa wrote:
> 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[]:

I would try one or both of:

(@Produces ["text/plain"]) ; Most elegant
(@Produces (string[] "text/plain")) ; matches a test in testsuite/annotations1.scm

There is a subtle difference between:
    string[]
    String[]
    java.lang.String[]
-which I can't remember off-hand and don't feel like looking up.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Having trouble using JAX-RS annotation in Kawa Scheme class
  2023-02-28 19:26 ` Per Bothner
@ 2023-02-28 19:42   ` Ross Merrifield
  0 siblings, 0 replies; 5+ messages in thread
From: Ross Merrifield @ 2023-02-28 19:42 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

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

Per,

The (@Produces (string[] "text/plain")) syntax is working as expected now!
Unfortunately, the more elegant ["text/plain"] syntax still results in the
'annotation must be constant' error, but I can live with the more verbose
version.

Thanks,

Ross

On Tue, Feb 28, 2023 at 11:27 AM Per Bothner <per@bothner.com> wrote:

> On 2/28/23 09:01, Ross Merrifield via Kawa wrote:
> > 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[]:
>
> I would try one or both of:
>
> (@Produces ["text/plain"]) ; Most elegant
> (@Produces (string[] "text/plain")) ; matches a test in
> testsuite/annotations1.scm
>
> There is a subtle difference between:
>     string[]
>     String[]
>     java.lang.String[]
> -which I can't remember off-hand and don't feel like looking up.
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-28 19:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 17:01 Having trouble using JAX-RS annotation in Kawa Scheme class Ross Merrifield
2023-02-28 17:37 ` Arvydas Silanskas
2023-02-28 19:03   ` Ross Merrifield
2023-02-28 19:26 ` Per Bothner
2023-02-28 19:42   ` Ross Merrifield

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).