import javax.tools.OptionChecker; 
import javax.tools.JavaCompiler; 
import javax.tools.ToolProvider; 

public class OptionCount { 
    private static void check(OptionChecker oc, String option, int expected) { 
        int count = oc.isSupportedOption(option); 
        System.out.printf("%20s: %2d (%2d expected) %s%n", 
                          option, count, expected, 
                          count == expected ? "PASS" : "FAIL"); 
    } 
    public static void main(String[] args) throws Exception { 
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 
        System.out.printf("Compiler: %s%n", compiler.getClass()); 
        check(compiler, "-profile", 1); 
        check(compiler, "-target", 1); 
        check(compiler, "-verbose", 0); 
        check(compiler, "-nowarn", 0); 
        check(compiler, "-g", 0); 
        check(compiler, "-deprecation", 0); 
        check(compiler, "-Xlint:unchecked", 0); 
        check(compiler, "-implicit:class", 0); 
        check(compiler, "-proc:none", 0); 
    } 
} 