The difference is that static methods are accessible beyond the scope of a class instance.
The only thing invoking instance methods are instances of that class, in a given run of a program, you can potentially create many instances at runtime (depending on what happens, user input etc.)… the fact that you can override these definitions is what allows for polymorphism. But for the override to happen it must be at run time.
Contrast with static things. They are at compile time (known before-hand, won’t change). You may make many instances of a class, but you have a contract that the static methods will not change (hence the name static, as in not moving). You can have a child class use the same static method name with hiding but you essentially have 2 separate static methods (again, because they cannot change at compile time and must be available in the program context).
This is common not just in java but in many other C-family languages.
You can also think of it like a public tool.
If tool X is publicly available and is only supposed to do Y, then someone comes and changes it to do Z without telling others, that would go against the point of it.
Don’t know if in example will help
public class Test {
public static void main(String[] args) {
// No instance necessary
MyClass.myStaticMethod(); // relevant besides the context of foo/bar/baz
foo = new MyClass();
bar = new MyClass();
foo.myInstanceMethod(); //only relevant for foo
bar.myInstanceMethod(); //only relevant for bar
// no instance of MyChildClass necessary for this call
MyChildClass.myStaticMethod(); //by hiding you can get this to have a different effect as original static method
baz = new MyChildClass();
baz.myInstanceMethod(); //only relevant for baz, you can override this ok
}
}
So it’s not so much that JVM prohibits it. It just goes against the definition of what it can do and how it does things. (if you say something won’t move, don’t move it, etc.). Do languages have to follow these paradigms? No. There are other families of languages with their own rules and so forth. And of course, we’re all free to dream and make our own languages with what should be the way ™.
and like I said before, you can get the same “effect” by the hiding technique. Except it won’t get overridden, you’ll just get an extra method (and there’s no ambiguity in which one will be invoked).