Originally posted by: Thyme
See if this.<variable> resolves to it (instance) or if <classname>.<variable> resolves to it (static) or if neither (local)
That ought to tell you.
My IDE (eclipse) tells me where a variable is defined.
Why do you need this?
I'm a software engineering intern, and my boss wants me to write PMD (
http://pmd.sourceforge.net) rules for code formatting. One of the rules is:
The class name shall always be used when referring to class (static) variables or methods. Object names shall not be used even though the Java language allows them. Unqualified references to class (static) variables shall not be used. Examples:
SomeClass.mStaticVariable; // good
SomeClass.staticMethod(); // good
SomeClass myObj;
myObj.mStaticVariable; // bad
myObj.staticMethod(); // bad
and the rule has to be written in either Java or XPath. I hate XPath (and can't find a way to accomplish it in XPath anyway). So it's Java or bust
Also, I told him about "Checkstyle" another sourceforge project made specifically for this kind of thing, but he hasn't gotton back to me on that yet.