Could some one explain why this is not the option?
I am assuming myapp.jar and datalayer.jar are in the same folder and is that why com.abc is omitted?
Why is the application module called abc.myapp while the dependency is called datalayer not abc.datalayer?
Note: There are two possible ways for an automatic module to get its name:
1. When an Automatic-Module-Name entry is available in the manifest, its value is the name of the automatic module.
2. Otherwise, a name is derived from the JAR filename (see the ModuleFinder JavaDoc for the derivation algorithm) -
Basically, hyphens are converted into dots and the version number part is ignored.
So, for example, if you put mysql-connector-java-8.0.11.jar on module path, its module name would be mysql.connector.java
If I am modularizing my application and dependent on other jars i.e analytics and added in module path as automatic module..
1) Can I provide automatic module name programatically in module-info.java (using ModuleDescriptor.name() method ) of my app?
2) I will just use ModuleFinder to get the name and manually add the name in my appplication's module-info.java?
Sometimes, a provider may want to modularize their jar in near future but hasn't completed that task. In that case, they may add a Automatic-Module-Name entry in their jar's manifest. So, if you put that jar in your module-path, it will still be an automatic module (because there will be no module-info.class file in that jar), but the name of that automatic module will be the name that the provider specified in the Automatic-Module-Name entry.
If you are modularizing your application and are dependent on third party analytics jar, you can directly add it to module-path. You don't add module-info to that jar because it is not your jar.
Regarding Module finder, it is not on for the exam. You are overthinking.
If you like our products and services, please help us by posting your review here.
I am just thinking about the application of the concept regarding adding name in requires directive in my app's module-info(getting automatic module name of third party)
Yes this is not in exam coverage. Im just applying the theories in real project.
Name of an automatic module is always known at compile time. It is either the same as the jar file name (without the dashes and version number) or it is what is specified in Automatic-Module-Name entry in the jar's manifest.
If you like our products and services, please help us by posting your review here.
yes, automatic modules can access any class anywhere. But, of course, you don't want to put anything on module-path unless you really need to because you don't want anything to have access to everything else.
If you like our products and services, please help us by posting your review here.