Re: abstract static methods (again)
- From: Tomas Mikula <tomas.mikula@xxxxxxxxx>
- Date: Tue, 20 Oct 2009 19:36:07 +0000 (UTC)
On Tue, 20 Oct 2009 12:12:31 -0700, Daniel Pitts wrote:
Why do you want to enforce a static method to exist in children? I can
think of no good reason for it.
And I also want to enforce constructors. I provided two use-cases.
1. serialization frameworks. It is already required that a Serializable
class has a no-arg constructor. But this is not required at compile time.
Other variant is to require some particular constructor or a creator
static method, such as MyClass.readObject(ObjectInputStream) (though this
method is non-static and not mandatory in Serializable).
2. For calling static methods on generics. My example was
abstract class Vector<V extends Vector<V>>{
/** returns a zero vector */
public abstract static V zero();
}
Then somewhere else I would like to use code as this:
MyClass<V implements Vector<V>> { // 'implements' is not valid here now
...
V v = V.zero(); // not possible now
...
}
.
- Follow-Ups:
- Re: abstract static methods (again)
- From: Lew
- Re: abstract static methods (again)
- From: Eric Sosman
- Re: abstract static methods (again)
- References:
- abstract static methods (again)
- From: Tomas Mikula
- Re: abstract static methods (again)
- From: Peter Duniho
- Re: abstract static methods (again)
- From: Tomas Mikula
- Re: abstract static methods (again)
- From: Daniel Pitts
- Re: abstract static methods (again)
- From: Tomas Mikula
- Re: abstract static methods (again)
- From: Daniel Pitts
- abstract static methods (again)
- Prev by Date: Re: abstract static methods (again)
- Next by Date: Re: abstract static methods (again)
- Previous by thread: Re: abstract static methods (again)
- Next by thread: Re: abstract static methods (again)
- Index(es):
Relevant Pages
|