New Keywords in Java 9

后端 未结 5 1335
無奈伤痛
無奈伤痛 2021-01-31 07:53

One of Java 9\'s largest features will be a module system defined by Project Jigsaw. When reading slides from the Project Jigsaw: Under the Hood at JavaOne 2015, I noticed the f

5条回答
  •  青春惊慌失措
    2021-01-31 08:33

    The keywords added for module declarations in Java 9 are summarized in §3.9 of the Java Language Specification, Java SE 9 Edition:

    A further ten character sequences are restricted keywords: open, module, requires, transitive, exports, opens, to, uses, provides, and with. These character sequences are tokenized as keywords solely where they appear as terminals in the ModuleDeclaration and ModuleDirective productions (§7.7). They are tokenized as identifiers everywhere else, for compatibility with programs written prior to Java SE 9. There is one exception: immediately to the right of the character sequence requires in the ModuleDirective production, the character sequence transitive is tokenized as a keyword unless it is followed by a separator, in which case it is tokenized as an identifier.

    If you presently have a method named module, or any of the other keywords listed here, it will continue to compile.

    (view and permits were keywords in an early Jigsaw prototype, but they were simplified out of existence long ago.)

提交回复
热议问题