Вопрос

When I try to use an Eclipse automated push down refactoring on a static field, I get the error:

"To activate this refactoring, please select the name of a non-binary instance method or field."

When I remove the static keyword, the refactoring can go forward. What does eclipse mean by "binary field," and why does this restriction exist?

Это было полезно?

Решение

Since a static field/method only belong to the class, you cannot push down it to a subclass.

If A is a superclass of B, then for a static method in A called a, you can only use it as A.a, not as B.a. Pushing down this method will certainly change what the class is doing , and affect the meaning of the program.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top