Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / May 2005

Tip: Looking for answers? Try searching our database.

tool to check that System.out.println() is only called from Log.java

Thread view: 
Meetlint - 20 May 2005 23:21 GMT
Hi,

What is the best tool if I want to check that a method like
System.out.println() is only called from a certain class?

I would like to enforce certain programming conventions by adding these
checks to the nightly Ant build process.

regards,
Peter
Robert Klemme - 21 May 2005 20:51 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> I would like to enforce certain programming conventions by adding these
> checks to the nightly Ant build process.

What about grep?  AFAIR ant can search through files also.

   robert
Meetlint - 21 May 2005 21:28 GMT
> What about grep?  AFAIR ant can search through files also.

I gave a simple example but in the future I would like to write more
specific rules, which get very close to Java parsing...

I will be looking at http://classycle.sourceforge.net/ which says:
Classycle's Dependency Checker searchs for unwanted class dependencies
described in a dependency definition file. Dependency checking helps to
monitor whether certain architectural constrains (e.g. in a layered
architecture) are fulfilled or not.

thanks,
Peter
Dale King - 26 May 2005 05:25 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> I would like to enforce certain programming conventions by adding these
> checks to the nightly Ant build process.

It could be fairly easily done in Checkstyle. They show an example
GenericIllegalRegexp that checks for System.out.println here:

<http://checkstyle.sourceforge.net/config_misc.html#GenericIllegalRegexp>

The only other thing to do is supress the error for the class where you
allow it.

Another similar tool that could do it is PMD. If you know your way
around XPATH this may be a better choice. They have the rule for finding
the println statements here:

<http://pmd.sourceforge.net/rules/logging-java.html>

You would only have to modify the XPATH instruction to only look when
the it is inside a class whose name does not match your class.

Checkstyle and PMD both have ant tasks BTW.

Signature

 Dale King



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.