users@jersey.java.net

Re: [Jersey] Annotation inheritance & covariant return types?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 01 Oct 2008 17:38:27 +0100

Hi Tim,

Can you try the latest, 1.0-ea-SNAPSHOT, and see if you get the same
behaviour. I tried using the latest and i cannot reproduce it.

BTW not sure if you are aware: Jersey does not have built in support
for the conversion of an instance of Number to a sequence of bytes. If
you have not already done so, you will need to add a message body
writer for instances of Number.

Paul.

On Oct 1, 2008, at 4:55 PM, Tim Pesce wrote:

> I've run into a situation that looks like a potential defect. I've
> also searched the mailing lists and issue tracker, but haven't been
> able to find anything related. I'm happy to create a new issue, but
> I'd like to make sure this isn't a case of user error first.
>
> I have two simple classes that use annotation inheritance on a
> method with covariant return types:
>
> public abstract class RandomNumber {
> protected static Random r = new Random(System.currentTimeMillis());
>
> @GET
> @Produces("text/plain")
> public abstract Number get();
> }
>
> @Path("integer")
> public class RandomInteger extends RandomNumber {
> public Integer get() {
> return r.nextInt();
> }
> }
>
> At init time Jersey produces this:
>
> Oct 1, 2008 9:10:59 AM
> com.sun.jersey.impl.application.WebApplicationImpl newResourceClass
> SEVERE: A resource, class test.resources.RandomInteger, has
> ambiguous resource method for HTTP method GET and output mime-type:
> text/plain. The problematic mime-type sets (as defined by @Produces
> annotation at Java methods get and get) are [text/plain] and [text/
> plain]
>
> I think the validator may not be accounting for bridge methods:
>
> Method[] methods = RandomInteger.class.getMethods();
> for (Method m : methods) {
> System.out.printf("%s (bridge=%b)\n", m, m.isBridge());
> }
>
> public java.lang.Integer test.resources.RandomInteger.get()
> (bridge=false)
> public java.lang.Number test.resources.RandomInteger.get()
> (bridge=true)
> [...]
>
> I'm using 0.11 and java version "1.6.0_07" (Mac)
>
> Thanks,
>
> Tim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>