Java 8 will bring a new mechanism
that allows you to write plug-ins for the Java compiler (javac). A compiler plug-in
lets you add new phases to javac without making changes to its code base. New
behavior can be encapsulated in a plug-in and distributed for other people to use. For example, javac plug-ins could be used to do the
following:
■Add extra compile-time checks.
■ Add code transformations.
■Perform customized analysis of source code.
Note: The API for creating javac plug-ins is still experimental for JDK
8; it is scheduled to ship in 2013.
In this Blog , we show how you can write a simple, customized source
code analysis tool so you can learn how to leverage the plug-in mechanisms for
your own applications.
We find code patterns that check whether the result of calling get() on an object that is a
subtype of Map is null. In other words we
are looking for patterns such as the following, where expr is a subtype of java.util.Map.
This pattern could be contained within a conditional expression, a
return statement, and so on. It should be reported in all cases.
Keep reading this blog continuously for further updates....
No comments:
Post a Comment