How to resolve module-info.java compile error in Jdk9/java-9

后端 未结 4 1280
傲寒
傲寒 2021-01-05 03:06

I am trying to run below code using jdk-9 but facing problem when compile using command

Command

 javac -d mods .\\module-info.java c         


        
4条回答
  •  礼貌的吻别
    2021-01-05 03:30

    As per JDK-8160181 it is not forbidden to use digits in module names, however they should not be related to versioning.

    Examples:

    • log4j - OK
    • java.compact3 - OK
    • guava19 - NOT OK - 19 is related to major guava version
    • module1 - OK IF 1 doesn't mean a version but one of many modules in a sample project (better name should be used in real projects)

    Since Lint can't figure out what the digit means it reports digits by default and you can suppress them in module file with:

    @SuppressWarnings("module") // 1 in module1 is module number, not version
    module module1 {
    ...
    }
    

    The comment is optional but explains "why" the warning was suppressed

提交回复
热议问题