langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/OptionHelper.java
changeset 40308 274367a99f98
parent 36157 fdbf6c9be2ab
child 42260 2b4da2bf6660
equal deleted inserted replaced
40306:1a0fcaf3f2ed 40308:274367a99f98
    25 
    25 
    26 package com.sun.tools.javac.main;
    26 package com.sun.tools.javac.main;
    27 
    27 
    28 import java.nio.file.Path;
    28 import java.nio.file.Path;
    29 
    29 
       
    30 import com.sun.tools.javac.util.JCDiagnostic;
    30 import com.sun.tools.javac.util.Log;
    31 import com.sun.tools.javac.util.Log;
    31 import com.sun.tools.javac.util.Log.PrefixKind;
    32 import com.sun.tools.javac.util.Log.PrefixKind;
    32 
    33 
    33 /**
    34 /**
    34  * Helper object to be used by {@link Option#process}, providing access to
    35  * Helper object to be used by {@link Option#process}, providing access to
    60     /** Get the name of the tool, such as "javac", to be used in info like -help. */
    61     /** Get the name of the tool, such as "javac", to be used in info like -help. */
    61     public abstract String getOwnName();
    62     public abstract String getOwnName();
    62 
    63 
    63     /** Report an error. */
    64     /** Report an error. */
    64     abstract void error(String key, Object... args);
    65     abstract void error(String key, Object... args);
       
    66 
       
    67     /** Report an error. */
       
    68     abstract void error(JCDiagnostic.Error error);
    65 
    69 
    66     /** Record a file to be compiled. */
    70     /** Record a file to be compiled. */
    67     abstract void addFile(Path p);
    71     abstract void addFile(Path p);
    68 
    72 
    69     /** Record the name of a class for annotation processing. */
    73     /** Record the name of a class for annotation processing. */
   111         void error(String key, Object... args) {
   115         void error(String key, Object... args) {
   112             throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
   116             throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
   113         }
   117         }
   114 
   118 
   115         @Override
   119         @Override
       
   120         void error(JCDiagnostic.Error error) {
       
   121             throw new IllegalArgumentException(log.localize(error));
       
   122         }
       
   123 
       
   124         @Override
   116         public void addFile(Path p) {
   125         public void addFile(Path p) {
   117             throw new IllegalArgumentException(p.toString());
   126             throw new IllegalArgumentException(p.toString());
   118         }
   127         }
   119 
   128 
   120         @Override
   129         @Override