Hacker News new | ask | show | jobs
by _old_dude_ 3278 days ago
It already exist something along that line.

If the classes that Spring, Jackson, etc want to access are in the classpath, it works by default in 9 (will not in 10, you will have to use the --add-opens on the command line). If the classes are enclosed inside a module, it's simpler, either you declare the package as open or the whole module as open. (when you declare a package open you also can specify the module for which it will be 'open', by example, open com.foo.mylib to org.jackson.core)

2 comments

> If the classes that Spring, Jackson, etc want to access are in the classpath, it works by default in 9 (will not in 10, you will have to use the --add-opens on the command line).

AFAIK "classpath-mode" is not affected by Jigsaw. All of classpath is one big module so "anything goes". As long as all of your code is on the classpath or a custom class loader created from the classpath anything should continue to work with 9 and even in 10. Things only start to break if you:

- reflect on JDK internals

- you put your code or frameworks or libraries in the modulepath

Having not really looked into the Java 9 features much yet can you expand on that last point? It sounds like that's more or less what I'm looking for though. Is it possible to declare a package to be open to multiple modules? I.E. could I do something like:

  open com.foo.mylib to com.fasterxml.jackson.core
  open com.foo.mylib to org.springframework.core