Last active
August 29, 2015 14:15
-
-
Save RuedigerMoeller/7f31f246b0adb5c80a00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class ByteStream { .. } | |
class SomeClass { | |
void someMethod() { | |
this.getStream().writeByte(13); // call on interface or abstract class | |
} | |
ByteStream getStream() { .. } | |
} | |
// later in code | |
// does this avoid dynamic dispatch inside "SomeClass:someMethod" ? | |
SomeClass clsA = new SomeClass() { | |
ConcreteByteStream getStream() { .. } | |
}; | |
SomeClass clsB = new SomeClass() { | |
OtherConcreteByteStream getStream() { .. } | |
}; | |
:-) i will some day, thanks for your statement
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not very sure. It definitely does not work when you compile
SomeClass::someMethod
in isolation. It probably does not also work when you compileSomeClass_anonymous1::someMethod
, because the type profile is probably bound to the callsite inSomeClass::someMethod
. You just have to check it yourself :)