简体   繁体   中英

JDK compiler fails for “open” module

Using current JDK build 9-ea+143 's javax.tools.JavaCompiler tool, I can compile the simple (empty) example module without an error:

module com.foo.bar { }

If I add open as in:

open module com.foo.bar { }

...the compiler error reads:

/module-info.java:1: error: class, interface, or enum expected
open module com.foo.bar {
^

Syntax based on http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html

Is the current JDK 9 build not up-to-date with this spec or am I missing an option to be passed to JavaCompiler ?

To get the newest Jigsaw features, you need to use the Jigsaw EA build (as opposed to the regular EA builds ). I created a GitHub repo exploring open packages and modules (to make reflection work) and also wrote about it - it definitely works on b146.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM