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