Posts Tagged ‘DefaultMethods’
[DevoxxBE2012] On the Road to JDK 8: Lambda, Parallel Libraries, and More
Joseph Darcy, a key figure in Oracle’s JDK engineering team, presented an insightful overview of JDK 8 developments. With extensive experience in language evolution, including leading Project Coin for JDK 7, Joseph outlined the platform’s future directions, balancing innovation with compatibility.
He began by contextualizing JDK 8’s major features, particularly lambda expressions and default methods, set for release in September 2013. Joseph polled the audience on JDK usage, noting the impending end of public updates for JDK 6 and urging transitions to newer versions.
Emphasizing a quantitative approach to compatibility, Joseph described experiments analyzing millions of lines of code to inform decisions, such as lambda conversions from inner classes.
Evolving the Language with Compatibility in Mind
Joseph elaborated on the JDK’s evolution policy, prioritizing binary compatibility while allowing measured source and behavioral changes. He illustrated this with diagrams showing compatibility spaces for different release types, from updates to full platforms.
A core challenge, he explained, is evolving interfaces compatibly. Unlike classes, interfaces cannot add methods without breaking implementations. To address this, JDK 8 introduces default methods, enabling API evolution without user burden.
This ties into lambda support, where functional interfaces facilitate closures. Joseph contrasted this with past changes like generics, which preserved migration compatibility through erasure, avoiding VM modifications.
Lambda Expressions and Implementation Techniques
Diving into lambdas, Joseph defined them as anonymous methods capturing enclosing scope values. He traced their long journey into Java, noting their ubiquity in modern languages.
For implementation, Joseph rejected simple inner class translations due to class explosion and performance overhead. Instead, JDK 8 leverages invokedynamic from JDK 7, allowing runtime strategies like class spinning or method handles.
This indirection decouples binary representation from implementation, enabling optimizations. Joseph shared benchmarks showing non-capturing lambdas outperforming inner classes, especially multithreaded.
Serialization posed challenges, resolved via indirection to reconstruct lambdas independently of runtime details.
Parallel Libraries and Bulk Operations
Joseph highlighted how lambdas enable powerful libraries, abstracting behavior as generics abstract types. Streams introduce pipeline operations—filter, map, reduce—with laziness and fork-join parallelism.
Using the Fork/Join Framework from JDK 7, these libraries handle load balancing implicitly, encapsulating complexity. Joseph demonstrated conversions from collections to streams, facilitating scalable concurrent applications.
Broader JDK 8 Features and Future Considerations
Beyond lambdas, Joseph mentioned annotations on types and repeating annotations, enhancing expressiveness. He stressed deferring decisions to avoid constraining future evolutions, like potential method reference enhancements.
In summary, Joseph portrayed JDK 8 as a coordinated update across language, libraries, and VM, inviting community evaluation through available builds.