102 } 103 104 /** 105 * Construct a compiler instance. 106 * @param name the name of this tool 107 */ 108 public Main(String name) { 109 this.ownName = name; 110 } 111 112 /** 113 * Construct a compiler instance. 114 * @param name the name of this tool 115 * @param out a stream to which to write messages 116 */ 117 public Main(String name, PrintWriter out) { 118 this.ownName = name; 119 this.stdOut = this.stdErr = out; 120 } 121 122 /** Report a usage error. 123 */ 124 void error(String key, Object... args) { 125 if (apiMode) { 126 String msg = log.localize(PrefixKind.JAVAC, key, args); 127 throw new PropagatedException(new IllegalStateException(msg)); 128 } 129 warning(key, args); 130 log.printLines(PrefixKind.JAVAC, "msg.usage", ownName); 131 } 132 133 /** Report a warning. 134 */ 135 void warning(String key, Object... args) { 136 log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args)); 137 } 138 139 140 /** 141 * Programmatic interface for main function. | 102 } 103 104 /** 105 * Construct a compiler instance. 106 * @param name the name of this tool 107 */ 108 public Main(String name) { 109 this.ownName = name; 110 } 111 112 /** 113 * Construct a compiler instance. 114 * @param name the name of this tool 115 * @param out a stream to which to write messages 116 */ 117 public Main(String name, PrintWriter out) { 118 this.ownName = name; 119 this.stdOut = this.stdErr = out; 120 } 121 122 /** 123 * Construct a compiler instance. 124 * @param name the name of this tool 125 * @param out a stream to which to write expected output 126 * @param err a stream to which to write diagnostic output 127 */ 128 public Main(String name, PrintWriter out, PrintWriter err) { 129 this.ownName = name; 130 this.stdOut = out; 131 this.stdErr = err; 132 } 133 134 /** Report a usage error. 135 */ 136 void error(String key, Object... args) { 137 if (apiMode) { 138 String msg = log.localize(PrefixKind.JAVAC, key, args); 139 throw new PropagatedException(new IllegalStateException(msg)); 140 } 141 warning(key, args); 142 log.printLines(PrefixKind.JAVAC, "msg.usage", ownName); 143 } 144 145 /** Report a warning. 146 */ 147 void warning(String key, Object... args) { 148 log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args)); 149 } 150 151 152 /** 153 * Programmatic interface for main function. |