diff -r 123f40b60a18 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 19 11:41:21 2017 +0200 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 27 14:11:18 2017 +0530 @@ -3184,7 +3184,7 @@ result = check(tree, owntype, pkind(), resultInfo); Symbol sym = TreeInfo.symbol(tree); if (sym != null && sym.kind.matches(KindSelector.TYP_PCK)) - log.error(tree.pos(), Errors.IllegalStartOfType); + log.error(tree.pos(), Errors.IllegalParenthesizedExpression); } public void visitAssign(JCAssign tree) { diff -r 123f40b60a18 src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Jun 19 11:41:21 2017 +0200 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Jun 27 14:11:18 2017 +0530 @@ -591,6 +591,9 @@ compiler.err.illegal.start.of.type=\ illegal start of type +compiler.err.illegal.parenthesized.expression=\ + illegal parenthesized expression + compiler.err.illegal.unicode.esc=\ illegal unicode escape diff -r 123f40b60a18 test/tools/javac/Parens1.out --- a/test/tools/javac/Parens1.out Mon Jun 19 11:41:21 2017 +0200 +++ b/test/tools/javac/Parens1.out Tue Jun 27 14:11:18 2017 +0530 @@ -1,2 +1,2 @@ -Parens1.java:12:20: compiler.err.illegal.start.of.type +Parens1.java:12:20: compiler.err.illegal.parenthesized.expression 1 error diff -r 123f40b60a18 test/tools/javac/Parens4.out --- a/test/tools/javac/Parens4.out Mon Jun 19 11:41:21 2017 +0200 +++ b/test/tools/javac/Parens4.out Tue Jun 27 14:11:18 2017 +0530 @@ -1,2 +1,2 @@ -Parens4.java:12:16: compiler.err.illegal.start.of.type +Parens4.java:12:16: compiler.err.illegal.parenthesized.expression 1 error diff -r 123f40b60a18 test/tools/javac/diags/examples/IllegalParenthesisExpression.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/IllegalParenthesisExpression.java Tue Jun 27 14:11:18 2017 +0530 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. 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. + * + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.illegal.parenthesized.expression + +class IllegalParenthesisExpression { + String s = (Integer).toString(123); +} diff -r 123f40b60a18 test/tools/javac/expression/IllegalParenthesis.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/expression/IllegalParenthesis.java Tue Jun 27 14:11:18 2017 +0530 @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8058408 + * @summary Test that illegal.parenthesized.expression error key is used for parenthesized expression used in cast + * + * @compile/fail/ref=IllegalParenthesis.out -XDrawDiagnostics IllegalParenthesis.java + */ + +import java.time.LocalDate; + +class IllegalParenthesis { + String s = (Integer).toString(123); + void f(){ + LocalDate date = (LocalDate).now(); + } +} \ No newline at end of file diff -r 123f40b60a18 test/tools/javac/expression/IllegalParenthesis.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/expression/IllegalParenthesis.out Tue Jun 27 14:11:18 2017 +0530 @@ -0,0 +1,3 @@ +IllegalParenthesis.java:12:16: compiler.err.illegal.parenthesized.expression +IllegalParenthesis.java:14:26: compiler.err.illegal.parenthesized.expression +2 errors \ No newline at end of file