NOTES This approach works for high level and embedded classes. But doesn't for an anonymous classes. Private class members are accessible as well. REQUIREMENTS You must have xdoclet 1.2.1 or later. INTRODUCTION First you add a javadoc tag to your source file at class level to enable code generation for this class. /** * @dbc */ public class Foo { .... } Second, you add tags to method calls keeping in mind about three points: 1.method parameters are accessible as they are. 2.instance variables are available via $this keyword. 3.the return value is available via $return keyword, if any. The tag @dbc.pre is used to add preconditions The tag @dbc.post - to execute verification at return statement. /** * @dbc.pre arg!=null */ String test(String arg){ return arg; } The last thing you have to do is to run your ANT build file. TAG REFERENCE At class level. @dbc - enable code generation for the class. The tag may have an optional attribute "extends" which you will want to use when you derive the aspect from an existing class or aspect. An aspect may not implement Serializable, thus it may not derive from a class implementing Serializable! Example: /** *@dbc *extends "your.package.YourAspect" *this means that genarated aspect will extends your.package.YourAspect. */ public class MyClass{ /** *@dbc.pre $this.mycondition() */ ... } At method level. There are two tags. @dbc.pre your_boolean_expression @dbc.post your_boolean_expression where "your_boolean_expression" will be an assert statement. You may use many @dbc.pre or @dbc.post tags for a given method. /** *@dbc.pre a>0 *@dbc.pre b!=null *@dbc.post $result!=null */ Integer yourMethod(int a, Integer b){ ... }
Download page
SourceForge.net Logo