diff -r b4e9df9d2f31 src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java Thu Jul 28 10:13:34 2016 +0530 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java Thu Jul 28 15:45:09 2016 +0530 @@ -176,6 +176,11 @@ FINALLY("finally"), /** + * Warn about module system related issues. + */ + MODULE("module"), + + /** * Warn about issues relating to use of command line options */ OPTIONS("options"), diff -r b4e9df9d2f31 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 Thu Jul 28 10:13:34 2016 +0530 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jul 28 15:45:09 2016 +0530 @@ -4414,6 +4414,7 @@ } public void visitModuleDef(JCModuleDecl tree) { + chk.checkModuleName(tree); tree.sym.completeUsesProvides(); } diff -r b4e9df9d2f31 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Jul 28 10:13:34 2016 +0530 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Jul 28 15:45:09 2016 +0530 @@ -35,6 +35,7 @@ import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; +import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; @@ -2090,6 +2091,23 @@ } } + public void checkModuleName (JCModuleDecl tree) { + Name moduleName = tree.sym.name; + Assert.checkNonNull(moduleName); + if (lint.isEnabled(LintCategory.MODULE)) { + if (moduleName.contentEquals("java.compact1") || + moduleName.contentEquals("java.compact2") || + moduleName.contentEquals("java.compact3") || + moduleName.contentEquals("jdk.pack200") || + moduleName.contentEquals("jdk.crypto.pkcs11")) + return; // white listed for now to allow JDK builds to finish even with -Xlint:all and -Werror + final String eman = new StringBuffer(moduleName.toString()).reverse().toString(); + if (eman.length() > 0 && !Character.isJavaIdentifierStart(eman.toCharArray()[0])) { + log.warning(Lint.LintCategory.MODULE, Warnings.PoorChoiceForModuleName(moduleName)); + } + } + } + private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) { ClashFilter cf = new ClashFilter(origin.type); return (cf.accepts(s1) && diff -r b4e9df9d2f31 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 Thu Jul 28 10:13:34 2016 +0530 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Jul 28 15:45:09 2016 +0530 @@ -1434,6 +1434,10 @@ compiler.warn.finally.cannot.complete=\ finally clause cannot complete normally +# 0: name +compiler.warn.poor.choice.for.module.name=\ + module name {0} should avoid terminal digits + # 0: symbol, 1: symbol compiler.warn.has.been.deprecated=\ {0} in {1} has been deprecated diff -r b4e9df9d2f31 src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties Thu Jul 28 10:13:34 2016 +0530 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties Thu Jul 28 15:45:09 2016 +0530 @@ -198,6 +198,9 @@ javac.opt.Xlint.desc.finally=\ Warn about finally clauses that do not terminate normally. +javac.opt.Xlint.desc.module=\ + Warn about module system related issues. + javac.opt.Xlint.desc.options=\ Warn about issues relating to use of command line options. diff -r b4e9df9d2f31 test/tools/javac/diags/examples/PoorChoiceForModuleName/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/PoorChoiceForModuleName/module-info.java Thu Jul 28 15:45:09 2016 +0530 @@ -0,0 +1,27 @@ +/* + * 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.warn.poor.choice.for.module.name +// options: -Xlint:module + +module guava19 {} diff -r b4e9df9d2f31 test/tools/javac/modules/T8160181/neg/lint.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/modules/T8160181/neg/lint.out Thu Jul 28 15:45:09 2016 +0530 @@ -0,0 +1,4 @@ +warning: [module] module name guava19 should avoid terminal digits +error: warnings found and -Werror specified +1 error +1 warning diff -r b4e9df9d2f31 test/tools/javac/modules/T8160181/neg/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/modules/T8160181/neg/module-info.java Thu Jul 28 15:45:09 2016 +0530 @@ -0,0 +1,16 @@ +/* + * @bug 5023177 + * @summary One can refer static, const static variables from instance initializers of enum + * @author gafter + * @compile/fail/ref=DA2.out -XDrawDiagnostics DA2.java + */ + +/* + * @test /nodynamiccopyright/ + * @bug 8160181 + * @summary Add lint warning for digits in module names + * @compile/fail/ref=lint.out -Xlint:module -Werror module-info.java + */ + +module guava19 { +} diff -r b4e9df9d2f31 test/tools/javac/modules/T8160181/pos/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/modules/T8160181/pos/module-info.java Thu Jul 28 15:45:09 2016 +0530 @@ -0,0 +1,33 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8160181 + * @summary Add lint warning for digits in module names + * @compile -Xlint:module -Werror module-info.java + */ + +module log4j { +} +