Skip to content

org.openrewrite.staticanalysis.FinalClass is wrong for nested sub classes #372

@Bananeweizen

Description

@Bananeweizen

org.openrewrite.staticanalysis.FinalClass works on wrong assumptions. A non-final class with no public constructor can have nested static sub classes, and in that case it cannot be made final.

What is the smallest, simplest way to reproduce the problem?

public class Reproducer {

    private Reproducer(final String name) {
        //...
    }

    public static final class Sub extends Reproducer {

        public Sub() {
            super("subclass");
        }
    }
}

What did you expect to see?

no change

What did you see instead?

final added to the top level class

Are you interested in contributing a fix to OpenRewrite?

Maybe. Have to look for how to get the information that there are nested sub classes.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions