Check for classes that implement the TypeVisitor interface

In Java SE 7, a new method, visitUnion , was added to javax.lang.model.type.TypeVisitor interface. This rule detects and flags Java classes which implement this interface but do not implement the visitUnion (UnionType t, P p) method. Any class without the visitUnion method that directly implements this Java interfaces will fail to compile.

In this example, the class MyClass will be flagged.

public class MyClass implements javax.lang.model.type.TypeVisitor {
// more code
}

According to Java SE 7 and JDK 7 Compatibility documentation, extensions to this interface were foreseen and users were cautioned against directly implementing this interface. The recommended action is to extend one of the utility visitors instead of directly implementing the interface.

For additional information see: