470,848 Members | 1,189 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

[Constructor] inexplicable contructor behaviour

Hi all,

This question involves the construction of instances with abstract
classes as parent.

Situation:
Eclipse 2.1.1 as IDE with SDK 1.4.2

I'm using c=Class.forName(...) and the obj = c.newInstance methods to
create instances of the classes.

public abstract class BaseClass1 {
BaseClass1() {
super();
...
}
...
}

public abstract class BaseClass2 extends BaseClass1 implements ISomething {
BaseClass2() {
super();
...
}
...
}

public class ChildClass1 extends BaseClass1 {
ChildClass1() {
super();
...
}
...
}

public class ChildClass2 extends BaseClass2 {
ChildClass2() {
super();
...
}
...
}
Problem definition:
Creating ChildClass1 is no problem.
After creation the debugger shows me an object (obj) like ChildClass1@0.
This basiaclly implies (to me) that the object is there and I can do
'stuff' with it.

Creating ChildClass2 however is *very* strange.
1. It *seems* to be created without erors but the result in the debugger
is *not* ChildClass2@0 as expected but null.
2. This would imply to me that obj does *not* exist! However, the
abstract superclass contains a UUID generator and if I do obj.getUUID()
I get a normal result as if obj is *not* equal to null (whilst the
debugger tells me it is).
3. IF Eclipse is erroneous in its null display (which the getUUID()
suggests) it should be possible to do 'stuff' with obj. This is correct
for setters only. Using obj for insertion into a collection thows the
null into the story again.
Personal findings:
I'm no guru but no newbie either.
Changed the inheritance structures on classes going right and classes
going wrong but I keep on coming up with the same result.
I've already burned 4 full (12h) days on this and I still don't get it.

If somebody has any experience with the above or any other suggestions I
would truly appreciate that.
Tried to be explicit in describing the problem & the environment but if
more info is required plz let me know.

TIA,
Fermin DCG
Jul 17 '05 #1
0 1787

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by giles | last post: by
3 posts views Thread by al | last post: by
45 posts views Thread by Ben Blank | last post: by
14 posts views Thread by Klaus Löffelmann | last post: by
7 posts views Thread by Wu Shaohua | last post: by
40 posts views Thread by Sek | last post: by
1 post views Thread by petro | last post: by
5 posts views Thread by Dave | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.