I help professional Java developers to learn language features so they can work on the best Java projects, software developer, speaker, OpenJDK contributor.
When your application has some problem, the first thing to check is running processes on the machine.
For Linux OS we generally use ps -ef. ps is one of the most used Linux troubleshooting commands. The JDK provides similar functionality for Java processes through jps. The jps command-line utility provides a list of all running Java processes on a machine for which the user has access rights. The access rights are determined by access-control mechanisms specific to the operating system.Vipin Sharma
Some bugs are hard to replicate on your personal computer but easily replicated on production or test machines. It is a common situation that professional Java developers deal with frequently. To debug such problems, OpenJDK provides two tools, remote debugging and jdb.
This article focuses on jdb.
For Java applications, typical production and test machines are Linux servers without display managers, so that only command line tools are available. Here we cannot use professional IDEs like IntelliJ IDEA, Eclipse, or Apache NetBeans IDE.
In such scenarios, we can use jdb. jdb is a command line debugger and it is part of the OpenJDK.Vipin Sharma
In a multi-threaded Java application, any thread can change the state of an object.
The Java memory model in Java language specification specifies when exactly updates made by one thread are going to be visible to other threads.
This is one of the biggest problems professional Java developers deal with every day.
Java records are immutable. An object is considered immutable if its state cannot change after it is constructed. The immutable nature of records eliminates problems of its usage in a multithreaded environment.Vipin Sharma
Professional Java developers need immutable data carrier-classes for communication with databases and web Services. We need to write a lot of boilerplate code to create a simple data carrier-class, we typically implement constructor, accessors, equals(), hashCode(), and toString(). This process is repetitive and error-prone. Developers also complain “Java is too verbose”.
Record classes provide a way to model data in Java. An example of data is a row in a database table. This feature simplifies coding, makes Java code more concise and readable, increasing productivity for professional Java developers. Java14 introduced Records as a preview feature, Java15 brings in some updates as a second preview, and Java16 makes it a final feature, no changes will be needed for Records after this.Vipin Sharma
Writing concurrent programs is hard, testing concurrent programs is harder, and debugging concurrent programs is a nightmare.
The incorrect concurrent program can run for years, tricking us to believe it is stable code, and it fails when we least expect.
JCStress is a concurrency stress test tool used by JVM developers to test the correctness of the JVM itself. The OpenJDK provides this amazing tool to test the correctness of your concurrent programs.Vipin Sharma
As we know, sun.misc.Unsafe APIs are not recommended to use outside the JDK, with a slight mistake it may result in a JVM crash. In some cases, code may not be portable across different platforms and many other problems that may occur.
Classes that cannot be used directly by the bytecode of other classes are hidden classes. Hidden classes allow frameworks/JVM languages to define classes as non-discoverable implementation details, so that they cannot be linked against by other classes.Vipin Sharma