diff -r 000000000000 -r 9a66ca7c79fa src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java Sat Dec 01 00:00:00 2007 +0000 @@ -0,0 +1,615 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package com.sun.tools.javac.main; + +import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.jvm.Target; +import com.sun.tools.javac.main.JavacOption.HiddenOption; +import com.sun.tools.javac.main.JavacOption.Option; +import com.sun.tools.javac.main.JavacOption.XOption; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Options; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.util.EnumSet; +import java.util.Set; +import java.util.StringTokenizer; +import javax.lang.model.SourceVersion; + +import static com.sun.tools.javac.main.OptionName.*; + +/** + * TODO: describe com.sun.tools.javac.main.RecognizedOptions + * + *

This is NOT part of any API supported by Sun Microsystems. + * If you write code that depends on this, you do so at your own + * risk. This code and its internal interfaces are subject to change + * or deletion without notice.

+ */ +public class RecognizedOptions { + + private RecognizedOptions() {} + + public interface OptionHelper { + + void setOut(PrintWriter out); + + void error(String key, Object... args); + + void printVersion(); + + void printFullVersion(); + + void printHelp(); + + void printXhelp(); + + void addFile(File f); + + void addClassName(String s); + + } + + public static class GrumpyHelper implements OptionHelper { + + public void setOut(PrintWriter out) { + throw new IllegalArgumentException(); + } + + public void error(String key, Object... args) { + throw new IllegalArgumentException(Main.getLocalizedString(key, args)); + } + + public void printVersion() { + throw new IllegalArgumentException(); + } + + public void printFullVersion() { + throw new IllegalArgumentException(); + } + + public void printHelp() { + throw new IllegalArgumentException(); + } + + public void printXhelp() { + throw new IllegalArgumentException(); + } + + public void addFile(File f) { + throw new IllegalArgumentException(f.getPath()); + } + + public void addClassName(String s) { + throw new IllegalArgumentException(s); + } + + } + + static Set javacOptions = EnumSet.of( + G, + G_NONE, + G_CUSTOM, + XLINT, + XLINT_CUSTOM, + NOWARN, + VERBOSE, + DEPRECATION, + CLASSPATH, + CP, + SOURCEPATH, + BOOTCLASSPATH, + XBOOTCLASSPATH_PREPEND, + XBOOTCLASSPATH_APPEND, + XBOOTCLASSPATH, + EXTDIRS, + DJAVA_EXT_DIRS, + ENDORSEDDIRS, + DJAVA_ENDORSED_DIRS, + PROC_CUSTOM, + PROCESSOR, + PROCESSORPATH, + D, + S, + IMPLICIT, + ENCODING, + SOURCE, + TARGET, + VERSION, + FULLVERSION, + HELP, + A, + X, + J, + MOREINFO, + WERROR, + // COMPLEXINFERENCE, + PROMPT, + DOE, + PRINTSOURCE, + WARNUNCHECKED, + XMAXERRS, + XMAXWARNS, + XSTDOUT, + XPRINT, + XPRINTROUNDS, + XPRINTPROCESSORINFO, + XPREFER, + O, + XJCOV, + XD, + SOURCEFILE); + + static Set javacFileManagerOptions = EnumSet.of( + CLASSPATH, + CP, + SOURCEPATH, + BOOTCLASSPATH, + XBOOTCLASSPATH_PREPEND, + XBOOTCLASSPATH_APPEND, + XBOOTCLASSPATH, + EXTDIRS, + DJAVA_EXT_DIRS, + ENDORSEDDIRS, + DJAVA_ENDORSED_DIRS, + PROCESSORPATH, + D, + S, + ENCODING, + SOURCE); + + static Set javacToolOptions = EnumSet.of( + G, + G_NONE, + G_CUSTOM, + XLINT, + XLINT_CUSTOM, + NOWARN, + VERBOSE, + DEPRECATION, + PROC_CUSTOM, + PROCESSOR, + IMPLICIT, + SOURCE, + TARGET, + // VERSION, + // FULLVERSION, + // HELP, + A, + // X, + // J, + MOREINFO, + WERROR, + // COMPLEXINFERENCE, + PROMPT, + DOE, + PRINTSOURCE, + WARNUNCHECKED, + XMAXERRS, + XMAXWARNS, + // XSTDOUT, + XPRINT, + XPRINTROUNDS, + XPRINTPROCESSORINFO, + XPREFER, + O, + XJCOV, + XD); + + static Option[] getJavaCompilerOptions(OptionHelper helper) { + return getOptions(helper, javacOptions); + } + + public static Option[] getJavacFileManagerOptions(OptionHelper helper) { + return getOptions(helper, javacFileManagerOptions); + } + + public static Option[] getJavacToolOptions(OptionHelper helper) { + return getOptions(helper, javacToolOptions); + } + + static Option[] getOptions(OptionHelper helper, Set desired) { + ListBuffer