View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.rule.controversial;
5   
6   import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
7   import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
8   
9   public class DontImportSunRule extends AbstractJavaRule {
10  
11      public Object visit(ASTImportDeclaration node, Object data) {
12          String img = node.jjtGetChild(0).getImage();
13          if (img.startsWith("sun.") && !img.startsWith("sun.misc.Signal")) {
14              addViolation(data, node);
15          }
16          return data;
17      }
18  
19  }