Eclipse / Java: how to discover and reorganize instance methods that should be static?

I want to reorganize the source code of a Java class (with Eclipse) encoded as a pure non-object language: there are only instance methods (public or private), but some of them must be static (without depending on the instance fields or other methods).

Can Eclipse detect it and reorganize the code, i.e. to reorganize some "public" methods to "private static"?

+4
source share
1 answer

According to the page on the Eclipse Java Compile Errors / Warnings Preferences, you can do this by turning on the option "The method may be static", which is ignored by default.

When this option is enabled, the compiler will generate an error or warning for private or final methods that apply only to static members.

After recompilation, you will get a list of instance methods in your code, which can be reorganized as static methods.

+4
source

Source: https://habr.com/ru/post/1568755/


All Articles