Skip to main content
Post Closed as "Opinion-based" by CommunityBot, Andreas, chrylis -cautiouslyoptimistic-, Am_I_Helpful, Kevin Brown-Silva
edited title
Link
Bax
  • 4.5k
  • 5
  • 47
  • 70

Why does Java static method hiding with weakerrestrict the access modifier of a hiding method

added 206 characters in body
Source Link
Bax
  • 4.5k
  • 5
  • 47
  • 70

TheWhen hiding a static field, there's no restriction on what access level does the field have in subclass, it can be even non-static and of other data type.

On the other side, when hiding a static method, the static method from subclass that hides the static method from superclass can allow more, but not less, access than the hidden method.

AFAIK, static method linking is anyway done at compile time, so why is there such a restriction ?

P.S. The question is just out of curiosity.

The static method from subclass that hides the static method from superclass can allow more, but not less, access than the hidden method.

AFAIK, static method linking is anyway done at compile time, so why is there such a restriction ?

P.S. The question is just out of curiosity.

When hiding a static field, there's no restriction on what access level does the field have in subclass, it can be even non-static and of other data type.

On the other side, when hiding a static method, the static method from subclass that hides the static method from superclass can allow more, but not less, access than the hidden method.

AFAIK, static method linking is anyway done at compile time, so why is there such a restriction ?

P.S. The question is just out of curiosity.

deleted 181 characters in body
Source Link
Bax
  • 4.5k
  • 5
  • 47
  • 70

When hiding a static field, there's no restriction on what access level does the field have in subclass, it can be even non-static and of other data type.

On the other side, when hiding a static method, theThe static method from subclass that hides the static method from superclass can allow more, but not less, access than the hidden method.

AFAIK, static method linking is anyway done at compile time, so why is there such a restriction ?

P.S. The question is just out of curiosity.

When hiding a static field, there's no restriction on what access level does the field have in subclass, it can be even non-static and of other data type.

On the other side, when hiding a static method, the static method from subclass that hides the static method from superclass can allow more, but not less, access than the hidden method.

AFAIK, static method linking is anyway done at compile time, so why is there such a restriction ?

P.S. The question is just out of curiosity.

The static method from subclass that hides the static method from superclass can allow more, but not less, access than the hidden method.

AFAIK, static method linking is anyway done at compile time, so why is there such a restriction ?

P.S. The question is just out of curiosity.

Source Link
Bax
  • 4.5k
  • 5
  • 47
  • 70
Loading