Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #633

Re: Why can one invoke setters and getters from a (class) constructor?

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.help
Subject Re: Why can one invoke setters and getters from a (class) constructor?
Date 2011-04-23 22:37 -0400
Organization albasani.net
Message-ID <ip02ct$imj$1@news.albasani.net> (permalink)
References <87bozwkgz8.fsf@merciadriluca-station.MERCIADRILUCA> <iovrb4$e2t$1@dont-email.me>

Show all headers | View raw


Joshua Cranmer wrote:
> Longer answer:
> So, the initialization of memory happens pretty much at the point you type in
> "new" (or the equivalent newInstance statement when doing reflection). This
> causes all of the local variables to be default-initialized to 0. Immediately
                     ^^^^^
This causes all of the instance member variables to be default-initialized to 
0-equivalent values.

> thereafter (unless someone is playing with bytecode), the appropriate
> constructor is called, which then immediately (again, unless someone is  playing with bytecode)
  calls any 'this()' constructor invocations, if they exist, until it hits a 
constructor that does not start with a 'this()' invocation, then it
> calls the superclass's constructor, etc., until it
> reaches Object. At that point, the calls start to unwind. Note that subclasses
> do not get a chance to really run until after their superclass does, so
> although it is possible to call overridable instance methods, it is not
> recommended to do so because said instance method might expect more
> initialization than is the case. If you do do this, make sure that you
> emphasize this in documentation so implementors at least know that they need
> to be prepared for this case.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Why can one invoke setters and getters from a (class) constructor? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 19:36 +0200
  Re: Why can one invoke setters and getters from a (class) constructor? Lew <noone@lewscanon.com> - 2011-04-23 13:58 -0400
  Re: Why can one invoke setters and getters from a (class) constructor? markspace <-@.> - 2011-04-23 11:00 -0700
    Re: Why can one invoke setters and getters from a (class) constructor? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 23:53 +0200
  Re: Why can one invoke setters and getters from a (class) constructor? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-04-23 20:36 -0400
    Re: Why can one invoke setters and getters from a (class) constructor? Lew <noone@lewscanon.com> - 2011-04-23 22:37 -0400
  Re: Why can one invoke setters and getters from a (class) constructor? Roedy Green <see_website@mindprod.com.invalid> - 2011-04-24 06:53 -0700
    Re: Why can one invoke setters and getters from a (class) constructor? Fred <fred.l.kleinschmidt@boeing.com> - 2011-04-25 11:06 -0700
      Re: Why can one invoke setters and getters from a (class) constructor? Lew <noone@lewscanon.com> - 2011-04-25 15:14 -0400

csiph-web