Mon, 28 Feb 2011 11:48:53 +0000
7015430: Incorrect thrown type determined for unchecked invocations
Summary: Thrown types do not get updated after 15.12.2.8, and do not get erased as per 15.12.2.6
Reviewed-by: jjg, dlsmith
1 /*
2 * Copyright (c) 2001, 2010, 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.util;
28 import java.util.*;
29 import com.sun.tools.javac.main.OptionName;
30 import static com.sun.tools.javac.main.OptionName.*;
32 /** A table of all command-line options.
33 * If an option has an argument, the option name is mapped to the argument.
34 * If a set option has no argument, it is mapped to itself.
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 risk.
38 * This code and its internal interfaces are subject to change or
39 * deletion without notice.</b>
40 */
41 public class Options {
42 private static final long serialVersionUID = 0;
44 /** The context key for the options. */
45 public static final Context.Key<Options> optionsKey =
46 new Context.Key<Options>();
48 private LinkedHashMap<String,String> values;
50 /** Get the Options instance for this context. */
51 public static Options instance(Context context) {
52 Options instance = context.get(optionsKey);
53 if (instance == null)
54 instance = new Options(context);
55 return instance;
56 }
58 protected Options(Context context) {
59 // DEBUGGING -- Use LinkedHashMap for reproducability
60 values = new LinkedHashMap<String,String>();
61 context.put(optionsKey, this);
62 }
64 /**
65 * Get the value for an undocumented option.
66 */
67 public String get(String name) {
68 return values.get(name);
69 }
71 /**
72 * Get the value for an option.
73 */
74 public String get(OptionName name) {
75 return values.get(name.optionName);
76 }
78 /**
79 * Check if the value for an undocumented option has been set.
80 */
81 public boolean isSet(String name) {
82 return (values.get(name) != null);
83 }
85 /**
86 * Check if the value for an option has been set.
87 */
88 public boolean isSet(OptionName name) {
89 return (values.get(name.optionName) != null);
90 }
92 /**
93 * Check if the value for a choice option has been set to a specific value.
94 */
95 public boolean isSet(OptionName name, String value) {
96 return (values.get(name.optionName + value) != null);
97 }
99 /**
100 * Check if the value for an undocumented option has not been set.
101 */
102 public boolean isUnset(String name) {
103 return (values.get(name) == null);
104 }
106 /**
107 * Check if the value for an option has not been set.
108 */
109 public boolean isUnset(OptionName name) {
110 return (values.get(name.optionName) == null);
111 }
113 /**
114 * Check if the value for a choice option has not been set to a specific value.
115 */
116 public boolean isUnset(OptionName name, String value) {
117 return (values.get(name.optionName + value) == null);
118 }
120 public void put(String name, String value) {
121 values.put(name, value);
122 }
124 public void put(OptionName name, String value) {
125 values.put(name.optionName, value);
126 }
128 public void putAll(Options options) {
129 values.putAll(options.values);
130 }
132 public void remove(String name) {
133 values.remove(name);
134 }
136 public Set<String> keySet() {
137 return values.keySet();
138 }
140 public int size() {
141 return values.size();
142 }
144 /** Check for a lint suboption. */
145 public boolean lint(String s) {
146 // return true if either the specific option is enabled, or
147 // they are all enabled without the specific one being
148 // disabled
149 return
150 isSet(XLINT_CUSTOM, s) ||
151 (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) &&
152 isUnset(XLINT_CUSTOM, "-" + s);
153 }
154 }