About Question enthuware.ocpjp.v11.2.3427 :
Moderator: admin
-
- Posts: 13
- Joined: Tue Jul 21, 2020 1:39 pm
- Contact:
About Question enthuware.ocpjp.v11.2.3427 :
Please confirm if I understand this concept correctly. In the real world, I would employ the top-down migration strategy because I don't have access to mysql-connector-java.jar The datalayer.jar may belong to the same company but another team could own that project.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
That is correct.
-
- Posts: 4
- Joined: Sun Jan 23, 2022 9:03 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
What if I modularize only the myapp.jar and leave data-layer and mysql-connector-java on the classpath. Will it work?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
No, classes in explicitly named modules cannot access classes from jars on classpath. Only automatic modules (which are implicitly named modules) can do that. So, you need to use automatic modules. Please go through a good book to understand this concept. We recommend the modules chapter of Hanumant Deshmukh OCP Java 17/21 Fundamentals study guide.
-
- Posts: 4
- Joined: Sun Jan 23, 2022 9:03 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
Thanks for the info.
-
- Posts: 17
- Joined: Fri Aug 12, 2022 10:19 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
Does the question mean: how can you make myapp modularized with as few steps as possible, starting at the bottom? Would leaving mysql as it is, making datalayer automatic and myapp modularized be a good answer to that? Or is the premise of the question that mysql and datalayer should be modularized (either automatic or regular)?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
The problem statement says that you have to use the bottom-up approach to modularize your app. If you use automatic modules then you are not using bottom-up approach (you are using top-down approach). The concept of automatic modules is created solely for the top-down approach.
-
- Posts: 2
- Joined: Sat Sep 21, 2024 1:42 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
@admin
Scott and Jeanne's book directly states, and I quote: "Unnamed modules do not export any packages to named or automatic modules" and in table 17.3 write "An unnamed module is readable by other modules on the module path?: NO"
This is in direct conflict with what you state about the alternative to this question, using a top-down migration where you for some reason leave the mysql package on the classpath.
According to the book's definition of a top-down migration, the first step is to migrate *all* modules to the module path, making them automatic modules, and then one at a time giving them module-info files. How come you suggest leaving one on the classpath? Are Scott and Jeanne just dead wrong on the entire Modules chapter?
I will also say that most resources I can find on the internet clearly specify that any module on the module path *cannot* see modules on the classpath.
Scott and Jeanne's book directly states, and I quote: "Unnamed modules do not export any packages to named or automatic modules" and in table 17.3 write "An unnamed module is readable by other modules on the module path?: NO"
This is in direct conflict with what you state about the alternative to this question, using a top-down migration where you for some reason leave the mysql package on the classpath.
According to the book's definition of a top-down migration, the first step is to migrate *all* modules to the module path, making them automatic modules, and then one at a time giving them module-info files. How come you suggest leaving one on the classpath? Are Scott and Jeanne just dead wrong on the entire Modules chapter?
I will also say that most resources I can find on the internet clearly specify that any module on the module path *cannot* see modules on the classpath.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
That book is wrong. Not only the part that you have quoted is incorrect several other points in that book are incorrect. Please check with the authors of that book or check their errata page.
Our explanation is correct. You may confirm from the source: https://openjdk.org/jeps/261
Our explanation is correct. You may confirm from the source: https://openjdk.org/jeps/261
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
>I will also say that most resources I can find on the internet clearly specify that any module on the module path *cannot* see modules on the classpath.
If you read that, then you are reading unreliable material. Because this rule does not apply to automatic modules. They can read everything including classes in the unnamed module. That is the whole point of having automatic modules.
If you read that, then you are reading unreliable material. Because this rule does not apply to automatic modules. They can read everything including classes in the unnamed module. That is the whole point of having automatic modules.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
Suggest you to go through the modules chapter of Hanumant Deshmukh OCP Java 17/21 Fundamentals study guide. Costs only $2.99 but explains these (and several other) points correctly.
-
- Posts: 3
- Joined: Tue Oct 01, 2024 12:59 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
why option 3 "The mysql jar must first be converted into modular jar. The datalayer.jar need not be converted." is not the correct answer?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3427 :
You do not own mysql.jar . How will you make it modular? It is a third party jar.
Please go through the responses above.
Please go through the responses above.
Who is online
Users browsing this forum: Bing [Bot] and 14 guests