T
Tomas Mikula
Isn't that a violation of the fundamental semantic of 'static' as
"class-wide, does not use an instance to resolve"?
(Yes, it is.)
This is not a compile-time vs. run-time matter, despite your attempt at
misdirection. The semantic of 'static' applies at run time and compile
time, both. It means "class level". You suggest using an
instance-level semantic to resolve the meaning of a 'static' construct.
That is too fundamental a change.
I will just note that it would be using an instance of a different class
than whose static method is called. This instance would be used to obtain
the class. After that, the invocation of it's static method would not use
any instance-level semantics. The code
class MyClass<V extends Vector<V>> {
void doSomething(){
V v = V.zero();
}
}
could be translated to something like
class MyClass<V extends Vector<V>> {
void doSomething(){
// get the class (uses an instance of MyClass, namely 'this')
Class<V> clazz = Class.getTypeParameterClass(this, "V");
// invoke the static method (no instance of V used)
V v = clazz.getMethod("zero").invoke(null);
}
}