1 /*
2 * Copyright (c) 2011, 2017, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
133 task.analyze();
134 ise = null;
135 } catch (IllegalStateException e) {
136 ise = e;
137 }
138
139 // sadly, command line errors are not (yet?) reported to
140 // the diag listener
141 String out = sw.toString();
142 if (!out.isEmpty())
143 System.err.println(out.trim());
144
145 switch (t) {
146 case JDK1_8:
147 if (ise != null)
148 error("unexpected exception from compiler: " + ise);
149 break;
150 case JDK1_9:
151 case JDK1_10:
152 case JDK1_11:
153 if (p == Profile.DEFAULT)
154 break;
155 if (ise == null)
156 error("IllegalStateException not thrown as expected");
157 else if (!ise.getMessage().contains("option -profile " +
158 "not allowed with target " + t.name)) {
159 error("exception not thrown as expected: " + ise);
160 }
161 break;
162 default:
163 if (p == Profile.DEFAULT)
164 break;
165 if (ise == null)
166 error("IllegalStateException not thrown as expected");
167 else if (!ise.getMessage().contains("profile " + p.name
168 + " is not valid for target release " + t.name)) {
169 error("exception not thrown as expected: " + ise);
170 }
171 break;
172 }
|
1 /*
2 * Copyright (c) 2011, 2018, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
133 task.analyze();
134 ise = null;
135 } catch (IllegalStateException e) {
136 ise = e;
137 }
138
139 // sadly, command line errors are not (yet?) reported to
140 // the diag listener
141 String out = sw.toString();
142 if (!out.isEmpty())
143 System.err.println(out.trim());
144
145 switch (t) {
146 case JDK1_8:
147 if (ise != null)
148 error("unexpected exception from compiler: " + ise);
149 break;
150 case JDK1_9:
151 case JDK1_10:
152 case JDK1_11:
153 case JDK1_12:
154 if (p == Profile.DEFAULT)
155 break;
156 if (ise == null)
157 error("IllegalStateException not thrown as expected");
158 else if (!ise.getMessage().contains("option -profile " +
159 "not allowed with target " + t.name)) {
160 error("exception not thrown as expected: " + ise);
161 }
162 break;
163 default:
164 if (p == Profile.DEFAULT)
165 break;
166 if (ise == null)
167 error("IllegalStateException not thrown as expected");
168 else if (!ise.getMessage().contains("profile " + p.name
169 + " is not valid for target release " + t.name)) {
170 error("exception not thrown as expected: " + ise);
171 }
172 break;
173 }
|