Name: rmT116609 Date: 11/19/2003
A DESCRIPTION OF THE REQUEST :
While developing static methods within a class, I find that I often need a reference to the class object for that class. I find that I have two alternatives: 1) always use MyClass.class or 2) define a Class constant (I name it thisclass) that is equal to MyClass.class. The drawback to this approach is that if I rename the class, I will need to change this constant. If it is simply a matter of renaming, the compiler will catch the problem. What is usually the cause of my class renames is refactoring, where I rename the old class, create a new base class with the original name, and then distribute the code between the two class appropriately. In this case, I find that forget to update my constant, but this gaff will not be caught at compile time.
JUSTIFICATION :
It simplifies the referencing to the enclosing class within static methods in a manner that removes the maintenance responsibility from the developer and places it into the compiler.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
As with "this", when I refer to the keyword "thisclass", it evaluates to a reference to the owning Class.
ACTUAL -
This behavior is currently not available
(Incident Review ID: 218590)
======================================================================