Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#526 "Require This" rule wrong on annotations

Jens-Uwe Gaspar

The "Require This" rule in checkstyle should not issue a warning on the following Java code, but which it does:


@Entity(name = "MessageEvent")
@Table(name = "message_event")
public class MessageEventEntity implements Serializable, EntityBase {
// Attributes

@Column(name = "name", unique = true, nullable = false, length = 255)
private String name;



Checkstyle informs the developer, that the "name" in the @Column-annotation needs a "this". This is alarmed, because there's a (private) attribute with the name "name". This doesn't occur, when the attribute is renamed for example.

The same-named token clashes with the name-directive within JPAs @Column-annotation. I have a strong feeling, that CheckStyle shouldn't alarm on that ;)

BTW, we are using: Java version 1.5.0_16, Eclipse-checkstyle-plugin v4.4.2 or same problem with maven checkstyle plugin v4.4

Can this be fixed ?


  • Nicolas  Dordet
    Nicolas Dordet

    It seems to work correctly with checkstyle5

  • Applied fix to trunk.

  • BTW. This was still a problem in CS 5. I have the unit tests to prove it :-)