Skip to content

Is the use of getClass in a final class an instance of LCK02J? #40

@reprogrammer

Description

@reprogrammer

Since final classes cannot be subclassed, the use of the return value of getClass as a lock object inside a final class is safe. Anonymous classes are a special kind of final classes. So, the use of getClass inside an anonymous class is safe. If our detector reports too many false positives in these cases, we can have the detector check for these corner cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions