473,385 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[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 1898

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: giles | last post by:
Hi, Does a compiler generated constructor initialise the data members? Giles
3
by: al | last post by:
class Base { public: //Base() {} Base(int m) {} }; class Derive : public Base {
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
6
by: Henry | last post by:
I was trying to derive a class from System.Windows.Forms.ComboBox. My goal was to create a class that loaded its own data. I did not want to create too many objects, so I tried to share a Database...
14
by: Klaus Löffelmann | last post by:
Hi, does anybody know, why the second contructor isn't called in this example? Are you able to reproduce this bug? Thanks Klaus Public Class Something
1
by: Carl Fenley | last post by:
I've been programming exclusively in C# for the last few years but am now working on a project where I am required to write all code in VB.NET. I'm trying to create a class with multiple...
7
by: Wu Shaohua | last post by:
Hi Guys, 1. As we know usually we should not define a constructor as inline. I also learned if we define a member function inside the class this member function will be automatically be...
40
by: Sek | last post by:
Is it appropriate to throw exception from a constructor? Thats the only way i could think of to denote the failure of constructor, wherein i am invoking couple of other classes to initialise the...
1
by: petro | last post by:
I noticed in ASP.net 2.0 when a new class is created a contructor is not created as it was in ASP.net 1.1. Does any one know why the constructor is not there. Can I add a contructor? Also how is ...
5
by: Dave | last post by:
Hello, Suppose you have a class with a static property with only a get (read only). You also have code in a static constructor that sets these properties but takes 1 hour to run. Now suppose...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.