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) 2009, 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 */
25 package com.sun.tools.javac.util;
27 import java.util.Set;
28 import java.util.Locale;
29 import javax.tools.Diagnostic;
31 import com.sun.tools.javac.api.DiagnosticFormatter;
32 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration;
33 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart;
34 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit;
35 import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind;
37 /**
38 * A delegated diagnostic formatter delegates all formatting
39 * actions to an underlying formatter (aka the delegated formatter).
40 *
41 * <p><b>This is NOT part of any supported API.
42 * If you write code that depends on this, you do so at your own risk.
43 * This code and its internal interfaces are subject to change or
44 * deletion without notice.</b>
45 */
46 public class ForwardingDiagnosticFormatter<D extends Diagnostic<?>, F extends DiagnosticFormatter<D>>
47 implements DiagnosticFormatter<D> {
49 /**
50 * The delegated formatter
51 */
52 protected F formatter;
54 /*
55 * configuration object used by this formatter
56 */
57 protected ForwardingConfiguration configuration;
59 public ForwardingDiagnosticFormatter(F formatter) {
60 this.formatter = formatter;
61 this.configuration = new ForwardingConfiguration(formatter.getConfiguration());
62 }
64 /**
65 * Returns the underlying delegated formatter
66 * @return delegate formatter
67 */
68 public F getDelegatedFormatter() {
69 return formatter;
70 }
72 public Configuration getConfiguration() {
73 return configuration;
74 }
76 public boolean displaySource(D diag) {
77 return formatter.displaySource(diag);
78 }
80 public String format(D diag, Locale l) {
81 return formatter.format(diag, l);
82 }
84 public String formatKind(D diag, Locale l) {
85 return formatter.formatKind(diag, l);
86 }
88 public String formatMessage(D diag, Locale l) {
89 return formatter.formatMessage(diag, l);
90 }
92 public String formatPosition(D diag, PositionKind pk, Locale l) {
93 return formatter.formatPosition(diag, pk, l);
94 }
96 public String formatSource(D diag, boolean fullname, Locale l) {
97 return formatter.formatSource(diag, fullname, l);
98 }
100 /**
101 * A delegated formatter configuration delegates all configurations settings
102 * to an underlying configuration object (aka the delegated configuration).
103 */
104 public static class ForwardingConfiguration implements DiagnosticFormatter.Configuration {
106 /** The configurationr object to which the forwarding configuration delegates some settings */
107 protected Configuration configuration;
109 public ForwardingConfiguration(Configuration configuration) {
110 this.configuration = configuration;
111 }
113 /**
114 * Returns the underlying delegated configuration.
115 * @return delegated configuration
116 */
117 public Configuration getDelegatedConfiguration() {
118 return configuration;
119 }
121 public int getMultilineLimit(MultilineLimit limit) {
122 return configuration.getMultilineLimit(limit);
123 }
125 public Set<DiagnosticPart> getVisible() {
126 return configuration.getVisible();
127 }
129 public void setMultilineLimit(MultilineLimit limit, int value) {
130 configuration.setMultilineLimit(limit, value);
131 }
133 public void setVisible(Set<DiagnosticPart> diagParts) {
134 configuration.setVisible(diagParts);
135 }
136 }
137 }