[34] in java-interest
abstract/native/overriding confusion
daemon@ATHENA.MIT.EDU (Steve_Kilbane)
Tue May 2 12:32:40 1995
Date: Tue, 2 May 1995 14:17:02 +0000
From: Steve_Kilbane@cegelecproj.co.uk (Steve_Kilbane)
To: java-interest@java.Eng.Sun.COM
I've just started reading about Java, and I'm a little baffled. Since
I'm new to both Java and OO programming, it seemed a good idea to
start at the bottom, and work up. But what I found in classsrc/java/io
has me confused.
Here's two fragments (minus comments) from OutputStream.java and
FilterOutputStream.java:
/* OutputStream.java */
package java.io;
public
class OutputStream {
public abstract void write(int b);
...
/* FilterOutputStream.java */
package java.io;
public
class FilterOutputStream extends OutputStream {
protected OutputStream out;
public FilterOutputStream(OutputStream out) {
this.out = out;
}
public void write(int b) {
out.write(b);
}
...
Which, as far as I can see, means that FilterOutputStream.write()
overrides OutputStream.write(), but I don't see what it actually
calls. I expected to see:
public native void write(int b);
in FilterOutputStream. So what *does* implement the writing?
I'm also confused about the semantics of "out.write(b)" -- which
is obviously allowed -- compared with "super.write(b)" -- which
shouldn't be allowed, according to the Language Spec, because
it's a direct invocation of an abstract method.
steve
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com