Thứ Ba, 30 tháng 8, 2011

Java Posts of Interest - 30 August 2011

There has been another flurry of interesting posts related to Java in recent days and weeks that I want to capture brief references to in this post. I narrowed down the list for this post to JVM Language Summit 2011, NetBeans, Scala for the Impatient, Heroku for Java, detecting deadlocks with JCarder, Java NIO versus Java IO, unit testing, and the HotSpot JVM flag PrintCompilation.


JVM Language Summit 2011 Presentations

Video and presentation slides (PDF) from the JVM Language Summit 2011 are now available for download. This event was held July 18-20, 2011, on Oracle's Santa Clara campus.

The list of presentations available for viewing/download include Method Handles and Beyond..., Brian Goetz Java SE 8 topics From Lambdas to Bytecode and Virtual Extension Methods, and JSR 292 Cookbook.


NetBeans

I wasn't the only one blogging about NetBeans in recent days and weeks. NetBeans 7 seems to be generating a lot of buzz online right now.

Geertjan Wielenga posts on NetBeans on a daily basis. In fact, his short biographical paragraph currently states that the focus of his blog " is mostly on NetBeans, with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans." Geertjan has had several particularly interesting posts on NetBeans in recent days including Disable Error Warnings in NetBeans IDE (including editing of netbeans_default_options property in etc/netbeans.conf) and XML Schema Editor in NetBeans IDE 7.0.1 (which I referenced in my own post).

Javin's post How to view javadoc in Netbeans IDE 7.0 lists three ways to view Javadoc documentation in NetBeans and a feedback comment points out use of UMLGraph as well. Robert Hollencamp's post Netbeans Conditional Breakpoints does not list the version of NetBeans as far as I can tell, but does document extremely slow reproducible performance related to a conditional breakpoint in some sample code he provides.

Finally, there is a NetBeans IDE 7 Satisfaction Survey intended for developers who have used or are using NetBeans 7.0 or NetBeans 7.1.


PrintComplilation Flag

Stephen Colebourne has done a nice job of making significant portions Moazam Rajas's Sun post on the HotSpot JVM flag -XX:+PrintCompilation more easily accessible. Rémi Forax, in a response comment, points out the HotSpot Internals Wiki Home Page.

In the early days of the web, links went away all the time and some things were lost for good. It seems as if things have improved over the years in terms of longevity of links and book authors have even referenced links. However, events like the closing down of GeoCities, mergers and acquisitions of companies with their blogs, and developers simply removing their own blogs have made resources like the Internet Archive WayBack Machine invaluable.


Scala for the Impatient

In his post Scala for the Impatient—Free Chapters at typesafe.com, Cay Horstmann describes the book he is writing on Scala (Scala for the Impatient) and provides a link to a free (except for the cost of signing up for the Typesafe newsletter) electronic copy of portions of this book.


Heroku for Java

Heroku for Java has been really big news this week. Not surprisingly, Play! on Heroku has now been announced as well. However, not everyone is ready to throw their Java EE out.


Detecting Java Deadlocks with JCarder

Charith Dhanushka's post Understanding and Terminating the Enemy - Deadlocks describes the conditions under which deadlock can occur in Java. He then introduces use of the open source dynamic analysis tool JCarder to detect deadlocks.


Java NIO versus Java IO

Jakob Jenkov's post Java NIO vs. IO addresses the question, "When should I use IO and when should I use NIO?" There is also a Java NIO: Introduction available at this site.


Java Looking Good for a Dead Language

I have posted before on the exaggerated claims of Java's death and a seeming resurgence of renewed interest in Java in recent months. Several recent posts show this to be a continuing trend. Adam Bien highlights that Java is still the most searched for language (and has increased its month-to-month interest) according Tiobe's August 2011 index. In a separate post, Bien explains reasons that it is important to choose the #1 language for enterprise projects.


Breaking Away From The Unit Test Group Think

The Cedric Beust post Breaking Away From The Unit Test Group Think is excellent. I think that the vast majority of experienced Java developers (or developers in any language) would agree that unit tests are important. I may like Beust's post so well because he articulates precisely my thoughts on unit testing. As he emphasizes, unit testing is important, but it should not preclude other types of testing and TDD is not the only way to make effective use of unit tests. Beust can write these things with some established credibility as the creator of TestNG Java testing framework.


Conclusion

This post has referenced and briefly summarized a few Java-related posts that I have found interesting in recent days and weeks.

Thứ Hai, 29 tháng 8, 2011

Configuring SQE Plugins in NetBeans 7

My last post (NetBeans 7 and Software Quality Environment) focused on using the NetBeans 7 Plugins Manager to acquire Software Quality Environment (SQE) and install its four plugins for four software quality tools (Dependency Finder, PMD, FindBugsTM, and Checkstyle). That post also briefly covered how to use each of these in NetBeans. In this post, the focus shifts to configuring and customizing the quality tools plugins in NetBeans.

Code analysis tools such as PMD, Checkstyle, and FindBugsTM tend to provide methods for configuring and tailoring the types of code issues identified by the tool. This is a welcome feature because not all findings are created equal and some matter more than others. Indeed, some findings are very subjective and a particular individual, team, or project may decide to NOT apply certain recommendations provided by these tools. In these tools' traditional uses, this configuration enables fewer "findings" to be reported and increases the probability that any reported finding is one worth the time to investigate and fix.

When running these code analysis tools in NetBeans, this desire to only see warnings and findings of significance is just as beneficial as it is when running the tools standalone as part of build scripts or when manually run against the source code. I like to have my source code free of any of the yellow or red findings NetBeans produces for hints, warnings, and errors. Similarly, I like my code to be free of the findings identified by the code analysis tools. In most cases, this means fixing the finding, but sometimes I don't agree with the finding. The ability to configure what the tools report is useful for removing reporting of findings that I don't consider to be findings at all.

It is easy to configure the code analysis tools on a per-project basic. To do so, right click on the project of interest in the "Projects" window (accessible using CTRL+1). Right-clicking on the project of interest in the "Projects" window leads to a drop-down menu like that shown in the next screen snapshot. One clicks on the "Properties" at the bottom to configure various project properties, including code analysis tools properties.


The result of clicking on the "Properties" selection after right-clicking on the project of interest is shown in the next screen snapshot. Note that in this case, the "Project Properties" window has "Sources" highlighted under "Categories."


To configure the code analysis tools plugins provided by SQE, the apropos tool name must be selected in the "Project Properties" window's "Categories" area. Selecting the higher-level "Quality" is not very exciting. Instead, one of the specific tools' names should be selected. The next screen snapshot indicates what the Project Properties window looks like when PMD is selected.


As this screen snapshot indicates, disabling any type of finding ("rule") in the PMD plugin is as simple as unchecking the box under "Enabled" for that particular rule. For someone with great familiarity with the PMD tool, it is likely that the names of the rules will make it obvious what rules are represented. For those who lack that familiarity, clicking on the particular rule of interest leads to more details on that rule being displayed. The next screen snapshot demonstrates an example of this for the "SystemPrintln" rule.


As the screen snapshot demonstrates, the two previously empty fields are filled with more details on the PMD rule selected. The middle field provides a brief textual description of the rule and the bottom field shows a code sample of the particular code situation the rule is intended to identify. As with the NetBeans hints, one could learn a lot about what are generally good ideas and generally bad ideas in Java by simply clicking on each rule one-by-one and reading the descriptions and seeing the code examples of those issues.

Configuring the FindBugsTM plugin for the project is similar. The next screen snapshot demonstrates how this appears in NetBeans 7 when "FindBugs" is selected in the "Project Properties" window. Notice that the default tab opened for this is "Configure Detectors" and that, like the PMD "rules," no particular "Bug Detector" is selected initially. Clicking on any rule leads to a description of the detector being placed in the previously empty field. This is shown in the next screen snapshot. Hovering over the description leads to the extra information in the yellow highlighted area shown in the snapshot.


Descriptions and associated Categories for various findings that FindBugsTM identifies are listed in FindBugs Bug Descriptions. Also note that the "Speed" of the various detectors is listed.

Clicking on "Checkstyle" under "Quality" in the NetBeans Project Properties window leads to the screen shown in the next snapshot.


Whether using Checkstyle from the command line or from Ant, a configuration file and a properties file can be provided to customize the applied Checkstyle modules. Given this, it's not surprising that the NetBeans SQE-provided Checkstyle plugin accepts specification of a "Config File" and a "Properties File."


Conclusion

Although some coding practices are almost universally accepted as "good" or "bad," there are some findings identified by code analysis tools that may be unimportant or even disagreeable to a software development organization. Therefore, it is advantageous that these tools allow the findings that are searched for and reported to be customized. Fortunately, the NetBeans SQE plugin passes along this configuration ability to the NetBeans user. The most significant configurations that can be performed with these tools in a command line or Ant environment can be performed similarly in NetBeans 7 thanks to SQE.