Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8351278

Support val in Java (Update on JEP-286 (Local Variable Type Inference))

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :

      For developers using Lombok, val has been one of the favorite features.

      Immutable programming is a great pattern that helps prevent errors. Many productive projects rely on this principle, using val as the default. Naturally, Lombok is widely used, but unfortunately, val is not natively supported in Java.

      I understand the arguments against val, but they don’t fully reflect reality. If you look at PMD’s Lombok-related issues, you’ll see that its usage is quite significant. Making a minor syntactic change—removing the need for final—would align with Java’s move toward functional programming, introduced with the Streams API. Fortunately, Java is heading in this direction.

      I no longer write for loops and have migrated to streams as part of embracing the functional approach. I strongly believe developers should have the freedom to choose between final var, lombok.val, or a native val. There’s no need to be overly opinionated when a large part of the community actively uses and benefits from val.

      It would be great to see a new initiative to replace lombok.val with a native alternative.





            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: