DontImportSunRule.java
01 package net.sourceforge.pmd.lang.java.rule.controversial;
02 
03 import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
04 import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
05 
06 public class DontImportSunRule extends AbstractJavaRule {
07 
08     public Object visit(ASTImportDeclaration node, Object data) {
09         String img = node.jjtGetChild(0).getImage();
10         if (img.startsWith("sun."&& !img.startsWith("sun.misc.Signal")) {
11             addViolation(data, node);
12         }
13         return data;
14     }
15 
16 }