Re: acces of members of subclass



Lew wrote:

From the JLS:
If a constructor body does not begin with an explicit constructor invocation and the
constructor being declared is not part of the primordial class Object, then the
constructor body is implicitly assumed by the compiler to begin with a superclass
constructor invocation "super();", an invocation of the constructor of its direct
superclass that takes no arguments.

The call to super() is *always* present. Any given class, in the
general case, can rely on the presence of super() call. Daniel and
you are not correct.

Ah, I see what you mean. Yes, there is an implicit call to super() if no explicit call is present. What I mean was that this call might fail as there is no zero-argument constructor present in the super class. Which is what I think Daniel meant also.
.



Relevant Pages

  • Re: instrumenting a constructor
    ... derived class's constructor must, upon entry, immediately call its ... I wish to insert bytecode into a set of java class constructors at load ... "An explicit constructor invocation statement in a constructor body may ...
    (comp.lang.java.programmer)
  • Re: acces of members of subclass
    ... the compiler inserts a call to the no-argument 'super' for you. ... Er, lots of classes have no zero-argument constructor, so Daniel is ... constructor invocation "super;", an invocation of the constructor of its direct ... The call to super() is *always* present. ...
    (comp.lang.java.help)