mpo's Blog
StevenN
TomK
Matthew
Kika | Mosh
Wiki (off-bridge)
acoliver
Carsten
Ovidiu
More Matthew...
Sam
Sylvain
Jeff
Simon
Bob
Werner
Marcus
Torsten
Bertrand
>Company Home<
[The Relevance]
[The References]
[The Blog-World]

Subscribe to "Marc, himself, his blogs, and you reading them" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.




...the eternal try-out.

Marc, himself, his blogs, and you reading them
 dinsdag 15 april 2003

She will. That is sure. This assurance should comfort you. Stop waiting, and start enjoying would be my advice: Delivery is not a process, it is a state of mind. You'll know it when you get there :-)All the best to you and Katleen... 11:55:10 AM    

Related.

Found Fishbowl through my Google Relevance link today and found well expressed shared neurons.

11:37:06 AM    

Two rights can make a wrong...

Careful considered subclassing combined with helpfull overloading can easily lead to this:

java.lang.StackOverflowError 
at java.lang.String.<init>(String.java:422)
at java.lang.StringBuffer.toString(StringBuffer.java:1225)
at test.TestSub.act(Main.java:23)
at test.TestBase.act(Main.java:36)
at test.TestSub.act(Main.java:27)
at test.TestSub.act(Main.java:23)
at test.TestBase.act(Main.java:36)
....

Code snippet to play this game at home:

 8 package test;
9
14 public class Main {
15
16 public static void main(String[] args) {
17 (new TestSub()).act(5);
18 }
19 }
20
21 class TestSub extends TestBase{
22 public void act(int i) {
23 act(""+i); //changing this to super.act(i) solves the problem!
24 }
25
26 public void act(String s) {
27 super.act(s);
28 }
29 }
30
31 class TestBase {
32 public void act(int i){
33 System.out.println(i);
34 }
35 public void act(String s){
36 act(Integer.parseInt(s));
37 }
38 }

Lesson to learn:

  • If you have overloaded methods in a class that is to be subclassed (not final) then you should make sure that the javadoc going with it clearly states how the internal overloading is done.
  • If you are overriding methods, always check the baseclass javadoc for overloaded side-effects like this. And delegate to super instead of to an overloaded version on the same level.

By the way I got to learn this the hard way making my own XMLFilter with overriden: XMLFilterImpl.parse(String SystemId) AND XMLFilterImpl.parse(InputSource input).
The resolution is snap, the insight is immediate, the bite was nevertheless unexpected.

11:21:42 AM    


April 2003
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Mar   May

Click here to visit the Radio UserLand website.
Click to see the XML version of this web page. Click here to send an email to the editor of this weblog.
© Copyright 2003 Marc Portier.
Last update: 27/11/2003; 11:29:55.