Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [CheckStyle] forbidding a particular method

Reply
Thread Tools

[CheckStyle] forbidding a particular method

 
 
oliviergir@gmail.com
Guest
Posts: n/a
 
      03-30-2006
Hello,
How can I implement a rule with checkstyle that would warn when the
code would call the method "receive()" on an instance of the class
"MessageConsumer" ?

I know that checkstyle might not be the appropriate tool for that, but
could I chek that the method "receive" is not called with a long
parameter superior with 5000 ?

thanks

 
Reply With Quote
 
 
 
 
Carl
Guest
Posts: n/a
 
      03-30-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hello,
> How can I implement a rule with checkstyle that would warn when the
> code would call the method "receive()" on an instance of the class
> "MessageConsumer" ?
>
> I know that checkstyle might not be the appropriate tool for that, but
> could I chek that the method "receive" is not called with a long
> parameter superior with 5000 ?
>
> thanks


Hello,

I Have no experience with checkstyle, but based on my understanding of
your question I think that java assertions may fit your requirements.

See
http://java.sun.com/j2se/1.4.2/docs/...ng/assert.html
for more details.

Alternatively, you could just have your method throw an
IllegalArgumentException if the argument was out of range.

Hope this helps,
Carl.

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      03-30-2006

"Carl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> (E-Mail Removed) wrote:
>> Hello,
>> How can I implement a rule with checkstyle that would warn when the
>> code would call the method "receive()" on an instance of the class
>> "MessageConsumer" ?
>>
>> I know that checkstyle might not be the appropriate tool for that, but
>> could I chek that the method "receive" is not called with a long
>> parameter superior with 5000 ?
>>
>> thanks

>
> Hello,
>
> I Have no experience with checkstyle, but based on my understanding of
> your question I think that java assertions may fit your requirements.
>
> See
> http://java.sun.com/j2se/1.4.2/docs/...ng/assert.html
> for more details.
>
> Alternatively, you could just have your method throw an
> IllegalArgumentException if the argument was out of range.


Presumably the OP wishes to check for these violations at compile time
(because they've got an ant script to automatically run checkstyle right
after compilation, for example), rather than runtime. I'm not familiar with
checkstyle, so I don't know how to solve this using CheckStyle either, but
it can be solved using AspectJ.

- Oliver

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Configure Update Panel to run a particular method only? John Kotuby ASP .Net 4 04-27-2009 02:10 PM
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
Forbidding itunes choowie Computer Security 24 02-06-2008 12:29 PM
How to find a whether a method is used by particular thread or not? sivasu.india@gmail.com Java 2 04-10-2007 12:57 PM
Forbidding template instantiation for specific type Marcin Kalicinski C++ 5 04-02-2004 06:07 PM



Advertisments