The Restriction: the son class must provide the no-parameter constructor

What can i do for the restriction : the son class must provide the no-parameter constructor? I have used the AOP or cglib or asm tools to add the constructor. There is a mistake when the constructor is private,please.
[238 byte] By [Stone.lia] at [2007-11-27 8:57:53]
# 1
You're gonna have to explain your design a lot better.Why does the child class have to provide a no-parameter constructor?
-Kayaman-a at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 2
huh, that is my purpose. I want to use the compiler to check whether the child class provide the no-parameter constructor or nor.
Stone.lia at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 3
Why? That sounds like fragile design.What are you trying to do? I mean in the big picture, why is the child class required to have a no-arg constructor?
-Kayaman-a at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 4

That is the scenario of the interface Vs. the abstract class

scenario 1: The third party implement the interface provided by me, then register it on my system.I would invoke it's method(s).

scenario 2: The third party implement the child class which extends the abstract class defined by me,

then i create the new child class instance. But how can i learn the child class constructor?

So i would restrict the child class constructor.

Thanks.

Stone.lia at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 5

Well, I think it's useless to try to force the class to have a no-arg constructor. You might write it in the specifications that they are required to provide one, but trying to use AOP to achieve that is a bad idea.

So what if they don't provide a no-arg constructor? Then their class won't work. If they want it to work, they provide the no-arg constructor.

That's it. You're not supposed to make things idiot proof.

-Kayaman-a at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 6
You can not have constructor restrictions on the language level with interfaces etc. You could use a factory pattern, but how do you construct a factory object? The same question arises again.
BIJ001a at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 7
huh, that's all. Thanks. I learn the result. As the lacuna of the java, I'm glad to learn some kungfu for that on the forum.^_^Thanks a lot.
Stone.lia at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 8

Yes, and factory method is out of the question since it would need to be static and you can't force a static method more than you can force a constructor.

But the bottom line is, provide the specs for the interface and that's it.

If your program does weird trickery to get malformed classes to work with the interface, that's not very good.

-Kayaman-a at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...
# 9
For BIJ001huh. The factory pattern or the abstract factory pattern is not all perfect for my application system. ^_^
Stone.lia at 2007-7-12 21:23:02 > top of Java-index,Java Essentials,Java Programming...