Java-specific issues Static import The static import construct was introduced in J2SE 5.0 in order to allow unqualified access to static members of a class. Beginning with version 7.2, Rational Rhapsody is capable of modeling static imports and generating appropriate code. In addition, the reverse engineering feature can handle static imports in Java code, and the roundtripping feature can handle changes to static import statements. Rational Rhapsody allows you to model both static import of individual class members ( import static java.lang.Math.PI ) and static import of all static members of a class ( import static java.lang.Math.* ).
Modeling of static imports is based on use of the StaticImport stereotype in the PredefinedTypesJava package. The StaticImport stereotype inherits from the Usage stereotype. Adding static imports to a model To add a static import to your model: 1. Create a dependency in the browser or by drawing a dependency in an object model diagram. The dependency can be from a class to a class or from a class to an individual static attribute or operation. 2. Open the Features window for the dependency you created, and apply the StaticImport stereotype to it. When you next generate code, the code for the dependant class will contain the appropriate static import statement.
Reverse engineering/roundtripping and static import statements If you reverse engineer code that contains static import statements, Rational Rhapsody will create dependencies that have the StaticImport stereotype applied to them. The roundtripping feature can handle the addition of static import statements to your code, as well as changes to static import statements, including switching regular import statements to static import statements, and vise versa. If you delete static import statements from your code, the roundtripping behavior will depend upon the value of the property JAVA_Roundtrip::Update::AcceptChanges . 1212 User Guide