You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by sebb <se...@gmail.com> on 2009/03/18 04:10:12 UTC

JCIP annotations

I've done most (perhaps all) of the HttpClient immutable classes, and
a few of the ones that are thread-safe (e.g. because access to mutable
objects is synchronized).

[Findbugs seems to work reasonably well with @Immutable, but AFAIK it
does not process @GuardedBy (yet).]

Ideally, each class should have one of @Immutable, @ThreadSafe or
@NotThreadSafe eventually.

The class annotations are themselves tagged as @Documented, so they
appear in the class Javadoc, which is very useful.

@GuardedBy is not tagged as @Documented, but is mainly for internal use.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: JCIP annotations

Posted by sebb <se...@gmail.com>.
On 18/03/2009, Mike Dillon <mi...@embody.org> wrote:
> begin sebb quotation:
>
> > It didn't work when I tried it last. Admittedly that was a few months
>  > ago, and there has just been a new release. But I just tried again
>  > with the following code:
>  >
>  > import net.jcip.annotations.GuardedBy;
>  > public class GuardedByTest {
>  >      @GuardedBy("this")
>  >      public int count;
>  >      public synchronized void incCount(){
>  >          count++;
>  >      }
>  >      public int getCount(){
>  >          return count;
>  >      }
>  > }
>  >
>  > Which I would have expected to report some problems. I even tried
>  > @GuardedBy("that") which IMO should also have triggered a warning.
>  >
>  > This was using the Eclipse plugin, 1.3.8.20090315.
>  >
>  > But perhaps I've missed something.
>
>
> I agree this should trigger a warning. I've forwarded your message to
>  the Findbugs folks to find out what the deal is.
>

Thanks.

I tried one of the findbugs project annotations from near the top of
the page, and it worked OK. It might be nice to use some of those, but
it looks like the licence is LGPL so we can't have a non-optional
dependency on the jar.

[I also tried using the javax version of GuardedBy, but that did not help]

>  -md
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>  For additional commands, e-mail: dev-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: JCIP annotations

Posted by Mike Dillon <mi...@embody.org>.
begin sebb quotation:
> It didn't work when I tried it last. Admittedly that was a few months
> ago, and there has just been a new release. But I just tried again
> with the following code:
> 
> import net.jcip.annotations.GuardedBy;
> public class GuardedByTest {
>      @GuardedBy("this")
>      public int count;
>      public synchronized void incCount(){
>          count++;
>      }
>      public int getCount(){
>          return count;
>      }
> }
> 
> Which I would have expected to report some problems. I even tried
> @GuardedBy("that") which IMO should also have triggered a warning.
> 
> This was using the Eclipse plugin, 1.3.8.20090315.
> 
> But perhaps I've missed something.

I agree this should trigger a warning. I've forwarded your message to
the Findbugs folks to find out what the deal is.

-md

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: JCIP annotations

Posted by sebb <se...@gmail.com>.
On 18/03/2009, Mike Dillon <mi...@embody.org> wrote:
> begin sebb quotation:
>
> > I've done most (perhaps all) of the HttpClient immutable classes, and
>  > a few of the ones that are thread-safe (e.g. because access to mutable
>  > objects is synchronized).

Only just committed them - I'd not noticed that the previous attempt
failed with a clash...

>  > [Findbugs seems to work reasonably well with @Immutable, but AFAIK it
>  > does not process @GuardedBy (yet).]
>  >
>  > Ideally, each class should have one of @Immutable, @ThreadSafe or
>  > @NotThreadSafe eventually.
>  >
>  > The class annotations are themselves tagged as @Documented, so they
>  > appear in the class Javadoc, which is very useful.
>  >
>  > @GuardedBy is not tagged as @Documented, but is mainly for internal use.
>
>
> The Annotations section of the Findbugs Manual lists @GuardedBy. Are you
>  sure it doesn't work?
>
>     http://findbugs.sourceforge.net/manual/annotations.html

It didn't work when I tried it last. Admittedly that was a few months
ago, and there has just been a new release. But I just tried again
with the following code:

import net.jcip.annotations.GuardedBy;
public class GuardedByTest {
     @GuardedBy("this")
     public int count;
     public synchronized void incCount(){
         count++;
     }
     public int getCount(){
         return count;
     }
}

Which I would have expected to report some problems. I even tried
@GuardedBy("that") which IMO should also have triggered a warning.

This was using the Eclipse plugin, 1.3.8.20090315.

But perhaps I've missed something.

>  -md
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>  For additional commands, e-mail: dev-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: JCIP annotations

Posted by Mike Dillon <mi...@embody.org>.
begin sebb quotation:
> I've done most (perhaps all) of the HttpClient immutable classes, and
> a few of the ones that are thread-safe (e.g. because access to mutable
> objects is synchronized).
> 
> [Findbugs seems to work reasonably well with @Immutable, but AFAIK it
> does not process @GuardedBy (yet).]
> 
> Ideally, each class should have one of @Immutable, @ThreadSafe or
> @NotThreadSafe eventually.
> 
> The class annotations are themselves tagged as @Documented, so they
> appear in the class Javadoc, which is very useful.
> 
> @GuardedBy is not tagged as @Documented, but is mainly for internal use.

The Annotations section of the Findbugs Manual lists @GuardedBy. Are you
sure it doesn't work?

    http://findbugs.sourceforge.net/manual/annotations.html

-md

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org