Paul Anilprem

Enthuware Software Support
+ Follow
since Sep 23, 2000
Merit badge: grant badges
Cows and Likes
Cows
Total received
52
In last 30 days
0
Total given
3
Likes
Total received
604
Received in last 30 days
8
Total given
174
Given in last 30 days
4
Forums and Threads

Recent posts by Paul Anilprem

There has been a change in the behavior of instanceof from Java 17 to Java 21. In Java 17, the type expression on the right hand side of the instanceof operator, when it is used for pattern matching (but not when it is used just for type comparison), must be a subtype of the type of the variable given on the left hand side. Java 21 does not impose this restriction.

Stephan van Hulst wrote:
Wouldn't it be strange if I could become a licensed dentist just by studying for an exam and never doing any practice? Why do people think the same doesn't apply to programming?


Indeed it would be strange. But so would be if you could become a dentist just by practicing without studying for and passing an exam.
Both have their utility, imho.
I don't understand when something can be called "bloated". Java lets one do a LOT of things right out of the box. Obviously, code for all that has to exist somewhere. I mean, a Hello World program is not bloated, I guess, but it doesn't do anything useful either.

Honestly, I haven't seen any stack that can achieve all that a real world non-trivial Java app can with less code + config + runtime.  I am curious to know if there are better alternatives.

JLS Section 12.1:

The Java Virtual Machine starts execution by invoking the method main of some specified class or interface, passing it a single argument which is an array of strings.

2 weeks ago

Simon Roberts wrote:

Paul Anilprem wrote:

Anil Philip wrote:

If, as Stefan said, you can have both -p and -cp together, then can code in the module moduleName access the non-modularized jars in jarFolderName ?


Yes, but only if it is an automatic module.



Except that the example here asks about "modularized jars in jarFolderName" -- and jarFolderName is on the classpath, *not* the module path, so they're not going to be automatic modules, and the above will not work.



You are right. I think I replied from my mobile and didn't check the actual command and posted the response based on just the world "jarFolderName". A jarFolderName has no business being on the classpath. You can only put a jarFolderName on the module path and the jars in that folder will become automatic modules (if they are not already explicitly named modules).

Now that I see the actual command in OP, I realize that the command is incorrect because putting a folder name containing a jar on the classpath doesn't make any sense. You need to put either a folder name containing exploded classes or put the jarFileName on the classpath.

You may go through release notes of each version. Skip the bugs fixes and focus on new features. Explore the features that interest you.
2 weeks ago
Hi Patrick,
I replied to you via purple mooseage (PM). Please check it.

thank you,
Paul.

Stephan van Hulst wrote:you only need to take two minutes to write a module descriptor to give your module a name and list its dependencies on other modules.


That's a red herring, imho. Time required to write/update a module description ignores the times required to "reload" the module knowledge base into your brain. Unlike regular java code that I write every day, module-info.java is used rarely and that makes me forget its operating parts.

It is like if I have to create an executable jar, I still have to look up whether it is Main-Class or Mainclass or something else that I need to add to meta-inf. Is it meta-inf.mf or something else?

It is the looking up part and not the writing part that dissuades programmers from using modules. Most projects are used internally anyway and rarely do teams care about modules, tbh. There is no time for them.

Having said that, I think the module functionality is pretty neat for what it is meant to achieve.

Anil Philip wrote:

But why not? if you left out the -p then wouldn't it regress to the old-style prehistoric invocation using classpath?


Already answered by Mikalai above:


1) When you have module options in the command line, the program runs as a modular


I would suggest you to use fresh tomcat setup, without any other webserver or anything sitting in front of it, and then test your web.xml on a the sample webapp. Access the sample webapp directly from the local broswer first. Once you get that working, add other stuff.
3 weeks ago
Another point that you might want to consider is that just creating multiple threads does not ensure parallel execution in real because parallel execution depends on the runtime environment of the JVM (specifically CPU cores).
So, using a copyOnWritearraylist.parallelStream.forEach({ dbConnectionAndCleanup() } )   (copied from your first post)  might be a better option than using any kind of thread pool because elements of a parallelStream will be processed by an optimum number of threads.

There are, of course, many unknowns in your example as others have pointed out, so it may not be possible to determine which approach will be better for sure unless you see the actual results.
Classes from a regular named module cannot access/read classes from classpath.
(fixed typo)

Anil Philip wrote:

If, as Stefan said, you can have both -p and -cp together, then can code in the module moduleName access the non-modularized jars in jarFolderName ?


Yes, but only if it is an automatic module.
Once you define your variable to be of type long, it doesn't matter what value you are assigning to it. It is going to take 64 bytes bits. Further, if an integer constant value is too large for an int variable, the compiler is going to complain anyway about the assignment.
So, I don't see a point in appending an L to a constant integral value if the value is larger than what an int can take. Why not append an I as well for a smaller value? The same reasoning applies.

Java is only syntactically based on C/C++. The whole point of having a limited number of primitives with exact size requirements irrespective of the underlying hardware was to avoid exposing hardware details.
4 weeks ago
Congratulations, Alex! Thank you for the detailed feedback.

Glad to know that our mock exams were helpful in your preparation