Tue, 27 Aug 2013 11:58:53 -0700
8023826: Typo in warning about obsolete source / target values
Reviewed-by: jjg, wmdietl
1 /*
2 * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.javac.main;
28 import com.sun.tools.javac.util.Log;
29 import com.sun.tools.javac.util.Log.PrefixKind;
30 import java.io.File;
32 /**
33 * Helper object to be used by {@link Option#process}, providing access to
34 * the compilation environment.
35 *
36 * <p><b>This is NOT part of any supported API.
37 * If you write code that depends on this, you do so at your own
38 * risk. This code and its internal interfaces are subject to change
39 * or deletion without notice.</b></p>
40 */
42 public abstract class OptionHelper {
44 /** Get the current value of an option. */
45 public abstract String get(Option option);
47 /** Set the value of an option. */
48 public abstract void put(String name, String value);
50 /** Remove any prior value for an option. */
51 public abstract void remove(String name);
53 /** Get access to the Log for the compilation. */
54 public abstract Log getLog();
56 /** Get the name of the tool, such as "javac", to be used in info like -help. */
57 public abstract String getOwnName();
59 /** Report an error. */
60 abstract void error(String key, Object... args);
62 /** Record a file to be compiled. */
63 abstract void addFile(File f);
65 /** Record the name of a class for annotation processing. */
66 abstract void addClassName(String s);
68 /** An implementation of OptionHelper that mostly throws exceptions. */
69 public static class GrumpyHelper extends OptionHelper {
70 private final Log log;
72 public GrumpyHelper(Log log) {
73 this.log = log;
74 }
76 @Override
77 public Log getLog() {
78 return log;
79 }
81 @Override
82 public String getOwnName() {
83 throw new IllegalStateException();
84 }
86 @Override
87 public String get(Option option) {
88 throw new IllegalArgumentException();
89 }
91 @Override
92 public void put(String name, String value) {
93 throw new IllegalArgumentException();
94 }
96 @Override
97 public void remove(String name) {
98 throw new IllegalArgumentException();
99 }
101 @Override
102 void error(String key, Object... args) {
103 throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
104 }
106 @Override
107 public void addFile(File f) {
108 throw new IllegalArgumentException(f.getPath());
109 }
111 @Override
112 public void addClassName(String s) {
113 throw new IllegalArgumentException(s);
114 }
115 }
117 }