What’s the difference between –add-exports and –add-opens in Java 9?

  • With --add-exports the package is exported, meaning all public types and members therein are accessible at compile and run time.
  • With --add-opens the package is opened, meaning all types and members (not only public ones!) therein are accessible at run time.

So the main difference at run time is that --add-opens allows “deep reflection”, meaning access of non-public members. You can typically identify this kind of access by the reflecting code making calls to setAccessible(true).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)