Will Sherwood Will Sherwood - 9 months ago 54
Java Question

New Keywords in Java 9

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 following source code:

// src/java.sql/module-info.java
module java.sql {
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;

What is interesting here to me is that the file ends in
and seems to use two new keywords:
, and
. What other keywords will be introduced in Java 9? How will backwards compatibility be dealt with (i.e. functions or variables named


The proposed additions to the language (and VM) for the module system are described here:

module, requires, exports, to, uses, provides, and with are restricted keywords (i.e. they are keywords solely where they appear as terminals in ModuleDeclaration, and are identifiers everywhere else).

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

At this time there are no other new keywords, restricted or otherwise, slated for appearance in Java 9. (view and permits were keywords in an earlier Jigsaw prototype, but they've been simplified out of existence.)