DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Java
  4. Looking into Java's Future: Empty Value Types

Looking into Java's Future: Empty Value Types

Have you ever wondered about using Java's value types? Read more here about what Java programmers have to say about the empty value type.

Dustin Marx user avatar by
Dustin Marx
·
Jul. 02, 18 · Presentation
Like (2)
Save
Tweet
Share
8.03K Views

Join the DZone community and get the full member experience.

Join For Free

Although the promising Java value types are not imminent, I still enjoy nosing around occasionally in the OpenJDK Valhalla-dev mailing list to see how things are progressing and to get an idea of what is to come. Admittedly, there are some discussions that are beyond my understanding, given my limited exposure to the terms used and the low-level specifics of some messages. However, occasionally, there are messages and threads that I understand and find interesting. A recent example of this is the "Empty value type ?" thread.

Rémi Forax starts the thread by asking "Is empty value type targeted for LW1?" The example error message included with that question shows as a LinkageError and a ClassFormatError with the message "Value Types do not support zero instance size yet." The response to this question from Tobias Hartmann says, "No, empty value types are not planned to be supported for LW1."

Before moving onto the rest of the thread (which is the part that interested me the most), I'll quickly discuss "LW1." In a message on that same OpenJDK mailing list called "[lworld] LW1 - 'Minimal LWorld'," David Simms states, "we are approaching something 'usable' in terms of 'minimal L World' (LW1)" and "we will be moving of prototyping to milestone stabilization." That same message states that the "label" is "lw1." Along with that, the affected-version and fixed-version are both "repo-valhalla". In other words, "LW1" is the label used to track bugs and issues related to work on the "minimal L world" implementation. You can reference John Rose's 19 November 2017 message, "abandon all U-types, welcome to L-world (or, what I learned in Burlington)" for an introduction to the "L World" term and what it means in terms of value types.

Returning to the "Empty value type?" thread, Kirk Pepperdine asked a question that also occurred to me, "How can a value type be empty?" He added, "What is an empty integer? An empty string?" He said he was "just curious" and now I am too. Here is a summary of the informative responses:

  • Rémi Forax: "type [that] represents the absence of value like unit, void, or bottom"
    • To which John Rose provided this informative link.
  • Rémi Forax: "type that represents the result of a throw"
  • Rémi Forax: "type that allows HashSet<E> to be defined as HashMap<E,Empty>"
    • Brian Goetz's message elaborates on the value of this, "Zero-length values can be quite useful, just not directly. Look at the current implementations of Set that delegate to HashMap; all that wasted space. When we have specialized generics, they can specialize to HashMap<T, empty>, and that space gets squeezed away to zero."
  • Rémi Forax: "transformative type like a marker type that separate arguments" (see the message for example of this one)

I also liked the final (as of this writing) Kirk Pepperdine message on that thread where he summarizes, "Feels like a value type version of null."

Incidentally, there are some other interesting messages and threads in the June 2018 Archives of the Valhalla-dev mailing list. Here are some of them:

  • Karen Kinnears posted: "Valhalla VM notes Wed Jun 6."
    • I don't understand every detail documented here, but it is interesting to see some of the potential timeframes associated with potential features.
  • Rémi Forax posted: "Integer vs IntBox benchmark"
    • Demonstrates results for IntBox (Forax describes this as "a value type that stores an int") contrasted with int and Integer and the results for IntBox are on par with int(and significantly better than Integer).
    • A link to the benchmark test on GitHub is also provided.
  • Sergey Kuksenko posted: "Valhalla LWorld microbenchmarks"
    • This message does not provide benchmark results but, instead, explains that the "initial set of Valhalla LWorld microbenchmarks" have been placed "in the Valhalla repository under test/benchmarks directory." It also explains how to build them.
  • Mandy Chung posted: "Library support for generating BSM for value type's hashCode/equals/toString"
    • Described as the "initial library support to generate BSM for hashCode/equals/toStringfor value types" based on John Rose's "Value type hash code."
    • "BSM" is the "bootstrap method." See the article, "Invokedynamic - Java’s Secret Weapon," for additional details.
  • John Rose posted: "Constant pool futures."

I look forward to one day being able to apply value types in my everyday Java code. Until then, it is interesting to think about and also to see how much work is going into making these value types.

Java (programming language)

Published at DZone with permission of Dustin Marx, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Utilize OpenAI API to Extract Information From PDF Files
  • AWS Cloud Migration: Best Practices and Pitfalls to Avoid
  • Event Driven 2.0
  • Building a Scalable Search Architecture

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: