modules and resources [ was: suggested document enhancement]

Bernard Amade bear.amade at gmail.com
Fri Mar 2 14:14:38 UTC 2018


thanks for replying

> Le 2 mars 2018 à 11:59, Alan Bateman <Alan.Bateman at oracle.com> a écrit :
>> 
> Resources aren't a first class concept in the module system so we of course recommend using services itself.

so you mean reconsider the resource handling as a spi (as it is done with ResourceBundle)
 explaining things to students will get pretty complicated since it should be split between resources located in the module and resources from external modules
BTW: another option may be that the "deployment programmer" updates the modular jar ( some signature problems?) or invoke with "patch-module" but is this politically correct ?

ok but why is the "old" way deprecated ? ( "first class" concept?)

> 
> If you are migrating existing code without doing any significant rearchitecture then modules can open packages to allow resources be located by code in other modules with the legacy ClassLoader.getResourceXXX APIs. There is also support in the ResourceBundle API to use resource bundles in other modules.
ClassLoader.getResource still works with resources located in other modules? the API doc says ...
 "this method will only find resources in packages of named modules when the package is opened <https://docs.oracle.com/javase/9/docs/api/java/lang/Module.html#isOpen-java.lang.String-> unconditionally"  for instance if I have a package with no code but resources only then IntelliJ does not want me to describe it in the module-info ... is this a spec or an IDE quirk?

> 
> . In particular, "Java 9 Modularity", by Sander Mak and Paul Bakker, is an excellent resource that will stand the test of time. That book has a section entitled "Resource Encapsulation" that should help you get going.
ok bought the book right now (but it will be shipped only in a fortnight ;-( )
> 
> I assume by "clickable jar" you mean executable JARs, as in `java -jar app.jar`. There is no support at this time for starting modular applications with the `java -jar`.
Hmm.

1) you should explicitly document that  so  poor guys like me will not spend hours trying to understand what is happening (java's man does not states that!)

2) then what is the simplest way to deploy jars if clicking on a jar does not work anymore with modules?
(scripts are platform dependent, so are Jlink images ,...and what happens with jars delivered through java webstart?  should we consider that  java webstart is going to be  deprecated?)

thanks

- Bear


More information about the jigsaw-dev mailing list