Skip to content

Do final variables in abstract classes really have to be initialized #28555

@bergwerf

Description

@bergwerf

I work with immutable classes quite a lot. This means I also put final variables in abstract base classes. Not using final there will make the analyzer warn about missing setters in class implementations. Adding a dummy constructor is useless because I don't use it anywhere (I implement the abstract class, I don't extend it, in this case that has to do with the limits of the rpc package which cannot print fields from super classes). This means I miss some code coverage which I try to get at 100% in important projects.
I can of course ignore the analyzer warning about an uninitialized final in the abstract class, but I was wondering if this is by design behavior. Abstract classes should not be instantiated directly anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions