Party Ark
Party Ark

Reputation: 1159

Java Constructor Super parameters

Looking at the code for the abstract class ByteBuffer it's apparent it inherits from the base class Buffer.

ByteBuffer has a single constructor:

ByteBuffer(int capacity) {
    super(capacity);
}

And Buffer has a single constructor:

Buffer(int mark, int pos, int lim, int cap) { 
    ...
}

So my question is - When ByteBuffer calls it's parent constructor, how does this work, because the parameters don't match?

UPDATE: This is a non-question, but worth knowing that some online Java source repositories (docjar in this case) hold a mish-mash of Java source. Best to download the JDK **

Upvotes: 4

Views: 195

Answers (2)

Sean Landsman
Sean Landsman

Reputation: 7179

I'm afraid it looks like the Buffer class you're looking at is out of date - the current javadoc has:

ByteBuffer(int mark, int pos, int lim, int cap) {   // package-private
ByteBuffer(int mark, int pos, int lim, int cap,          // package-private
  byte[] hb, int offset)

Upvotes: 0

PermGenError
PermGenError

Reputation: 46398

Seems like a documentation mistake.

ByteBuffer source on GrepCode has it right.

  ByteBuffer(int mark, int pos, int lim, int cap,   // package-private
274                  byte[] hb, int offset)
275     {
276         super(mark, pos, lim, cap);
277         this.hb = hb;
278         this.offset = offset;
279     }
280 

Upvotes: 4

Related Questions