Author: Vipin Sharma

Vipin Sharma

I help professional Java developers to learn language features so they can work on the best Java projects, software developer, speaker, OpenJDK contributor.

  • Avoid Multithreading Bugs Using Immutable Java Records

    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.

    V. Sharma
    Read more
  • Java Records: Data Carrier Classes

    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.

    V. Sharma
    Read more
  • JCStress: Eliminate the Nightmare of Debugging Java Concurrency Bugs

    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.

    V. Sharma
    Read more
  • What are Hidden Classes in Java 15?

    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.

    V. Sharma
    Read more

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard