Re: Tool for inlining useless getter/setter call
On Feb 11, 11:53 pm, Jack <mls...@poqsd.com> wrote:
Owen Jacobson a =E9crit :
On Feb 11, 9:25 am, Jack <mls...@poqsd.com> wrote:
Hi,
is there a tool to inline "useless" getter call:
* simple getter (return field;) or setter (this.field = arg)
* called in the class that contain the field
* getter/setter is not overloaded, and does not overlead (in the curren=
t code)
I would like to inline these call automatically in all my java code.
Sun's Hotspot JVM (and presumably any other JITing JVM) is capable of
inlining these at runtime and will do so automatically unless JIT is
explicitly disabled.
Thanks, but i would like to remove them from the java source code. The rea=
son is that these accessors hide "what is going on", and i don't appreciate =
that.
Keeping setter who checking the argument is ok, but simple assignement set=
ters, or simple return getters are really useless, when called from the clas=
s which define them.
Eclipse can do this provided that all the places that you want to
inline it to are within the workspace and have inter-project
dependencies set up right. Go to the definition of the method you
want to inline and Refactor/Inline Method. Other IDEs presumably
offer a similar feature.
You may have to increase the accessibility of the relevant variables.
However, I fundamentally disagree with your premise. I hope I never
wind up maintaining code you've done this to: the number of things
that take advantage of accessor/mutator methods that have a hard time
with raw field access is pretty high, and, particularly for mutable
fields, allowing the world at large to simply stuff values into the
field makes maintaining invariants with respect to that field all but
impossible.
-o