Oracle Drops Collection Literals in JDK 8

In a posting on the OpenJDK JEP 186 Oracle’s Brian Goetz informs that Oracle will not be pursuing collection literals as a language feature in JDK8.

Een collection literal is a syntactic expression form that evaluates to an aggregate type as an array, List or Map. Project Coin proposed collection literals, which also complements the library additions in Java SE8. The assumption was that collection literals would increase productivity, code readability, and code safety.

As an alternative Oracle suggests a library-based proposal based on the concept of static methods on interfaces. The Implementation would ideally be via new dedicated immutable classes.

Following are the major points behind this library-based approach.

  • The basic solution of this feature works only for Sets, Lists and Maps so it is not very satisfying or popular. The advanced solution to cover an extensible set of other collection types is open-ended, messy, and virtually guaranteed to way overrun its design budget.
  • The library-based changes would remove much of the requirement for the “collection literals” change discussed in Project Coin.
  • The library-based approach gives X% of the benefit for 1% of the cost, where X >> 1.
  • The value types are coming and the behavior of this new feature (collection literals) with the value types is not known. It is better not to try collection literal before the value types.
  • It is better off focusing Oracle’s language-design bandwidth on addressing foundational issues underlying a library-based version. This includes more efficient varargs, array constants in the constant pool, immutable arrays, en ondersteuning voor caching (en terugwinnen onder druk) tussenliggende onveranderlijke resultaten.

Volgens Oracle's Brian Goetz, de echte pijn is in Maps niet Lijsten, Sets of Arrays. De library-gebaseerde oplossingen zijn acceptabel voor lijsten, Sets en Arrays. Maar deze aanpak ontbreekt nog steeds een redelijke manier om pair letterlijke als kaarten beschrijven. De statische methoden in een interface maakt de library gebaseerde oplossing praktischer. De types waarde make-library gebaseerde oplossingen voor Kaart veel praktischer te. De proof of concept patch voor-library gebaseerde oplossing beschikbaar.

============================================= ============================================== Buy best TechAlpine Books on Amazon
============================================== ---------------------------------------------------------------- electrician ct chestnutelectric
error

Enjoy this blog? Please spread the word :)

Follow by Email
LinkedIn
LinkedIn
Share