8157519: Error messages when compiling a malformed module-info.java confusing

Reviewed-by: jjg
This commit is contained in:
Srikanth Adayapalam 2016-08-16 09:13:33 +05:30
parent 9208c82732
commit 8513d8d26f
5 changed files with 51 additions and 0 deletions
langtools
src/jdk.compiler/share/classes/com/sun/tools/javac
test/tools/javac
diags/examples/InvalidModuleDirective
modules/InvalidModuleDirective

@ -3238,6 +3238,8 @@ public class JavacParser implements Parser {
accept(SEMI);
defs.append(toP(F.at(pos).Uses(service)));
} else {
setErrorEndPos(pos);
reportSyntaxError(pos, "invalid.module.directive");
break;
}
}

@ -672,6 +672,9 @@ compiler.err.cannot.create.array.with.type.arguments=\
compiler.err.cannot.create.array.with.diamond=\
cannot create array with ''<>''
compiler.err.invalid.module.directive=\
module directive keyword or ''}'' expected
#
# limits. We don't give the limits in the diagnostic because we expect
# them to change, yet we want to use the same diagnostic. These are all

@ -0,0 +1,29 @@
/*
* Copyright (c) 2016, 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.invalid.module.directive
module java.transaction {
requires java.base;
resuires javax.interceptor.javax.interceptor.api;
}

@ -0,0 +1,15 @@
/*
* @test /nodynamiccopyright/
* @bug 8157519
* @summary Error messages when compiling a malformed module-info.java confusing
* @compile/fail/ref=moduleinfo.out -XDrawDiagnostics module-info.java
*/
module java.transaction {
requires java.base;
resuires javax.interceptor.javax.interceptor.api;
requires public javax.enterprise.cdi.api;
requires public java.sql;
requires public java.rmi;
export javax.transaction;
}

@ -0,0 +1,2 @@
module-info.java:10:3: compiler.err.invalid.module.directive
1 error