
LOCK ELISION IN THE JVM 74 | JAVA 10 var KEYWORD 63 MAY/JUNE 2018 magazine By and for the Java community Design Patterns 15 27 38 50 COMMAND JPA AND PRODUCER-CONSUMER MAPPING DDD PATTERN HIBERNATE FOR HIGH-VOLUME TO JAVA EE IN DEPTH PATTERNS DATA IN JAVAFX ORACLE.COM/JAVAMAGAZINE Don’t let Java redeploys slow you down Would you rather be waiting... ...or coding Reload code changes instantly with JRebel TRY IT NOW! GET FREE TRIAL //table of contents / COVER FEATURES 27 38 50 DESIGN PATTERNS FOR PRODUCER-CONSUMER USING DOMAIN- JPA AND HIBERNATE IMPLEMENTATIONS IN DRIVEN DESIGN By Thorben Janssen JAVAFX WITH JAVA EE Best practices for an efcient By Sean M. Phillips By Sebastian Daschner and maintainable persistence Graphing high volumes of How to map DDD artifacts layer with JPA and Hibernate spiky data requires adaptations to Java EE code 15 to the traditional pattern. THE COMMAND PATTERN IN DEPTH By Ian F. Darwin Packaging commands as objects and sending them to a receiver enables a clean, loosely coupled design that’s easy to maintain. OTHER FEATURES DEPARTMENTS 63 87 05 10 var and Java 10’s Expanded Fix This From the Editor Events Type Inference By Simon Roberts and Mikalai Zaikin A completely new JVM codebase heralds Upcoming Java conferences and events By Raoul-Gabriel Urma and Our latest quiz with questions that a new generation of performance. 86 Richard Warburton test intermediate and advanced 07 User Groups Best practices for using local knowledge of the language Letters The Peru JUG variable type inference Java Web Start, containers, and 99 74 other reader concerns Contact Us Lock Elision in the JVM 09 Have a comment? Suggestion? Want to By Ben Evans and Chris Newland Java Books submit an article proposal? Here’s how. How the compiler’s escape analysis Review of Java by Comparison removes unnecessary locks COVER ART BY WES ROWELL 02 ORACLE.COM/JAVAMAGAZINE /////////////////////////////////////////////// MAY/JUNE 2018 EDITORIAL PUBLISHING Editor in Chief Group Publisher Andrew Binstock Karin Kinnear Managing Editor Audience Development Manager Claire Breen Jennifer Kurtz Interim Managing Editor Leslie Steere Certification ADVERTISING SALES Copy Editors Lea Anne Bantsari, Karen Perkins Sales Director Tom Cometa Contributing Editors Simon Roberts, Mikalai Zaikin Mailing-List Rentals Contact your sales representative. Technical Reviewer Stephen Chin MATTERS RESOURCES Oracle Products DESIGN +1.800.367.8674 (US/Canada) Senior Creative Director Francisco G Delgadillo Oracle Services +1.888.283.0591 (US) Design Director Richard Merchán Senior Designer Arianna Pucherelli Experienced a Greater Designer 1 Jaime Ferrand 72% Demand for Their Skills Senior Publication Designer Sheila Brennan Production Designer Kathy Cygnarowicz Said Certification was a 67% Key Factor in Recent Raise1 ARTICLE SUBMISSION If you are interested in submitting an article, please email the editors. Received Positive Impact 2 SUBSCRIPTION INFORMATION 64% on Professional Image Subscriptions are complimentary for qualified individuals who complete the subscription form. MAGAZINE CUSTOMER SERVICE [email protected] PRIVACY Oracle Publishing allows sharing of its mailing list with selected third parties. If you prefer that your mailing address or email address not be included in this program, contact Customer Service. Oracle University Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. No part of this publication may be reprinted or otherwise reproduced without permission from the editors. JAVA MAGAZINE IS PROVIDED ON AN “AS IS” BASIS. ORACLE EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY Differentiate Yourself to Attract Employers DAMAGES OF ANY KIND ARISING FROM YOUR USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. Opinions expressed by authors, editors, and interviewees—even if they are Oracle employees—do not necessarily reflect the views of Oracle. The information is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied Source: 1—Certification Magazine, Annual Salary Survey, January 2018 | 2—Pearson VUE, Value of IT Certification Survey, 2017. upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Oracle and Java are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Java Magazine is published bimonthly and made available at no cost to qualified subscribers by Oracle, 500 Oracle Parkway, MS OPL-3A, Redwood City, CA 94065-1600. 03 ORACLE.COM/JAVAMAGAZINE /////////////////////////////////////////////// MAY/JUNE 2018 //from the editor / Java in the Cloud The Vanguard of a New Generation of JVMs Oracle Cloud delivers Graal leads a new ecosystem of emerging JVM technologies that herald big benefts. high-performance and battle-tested platform and infrastructure services for the most demanding ntil the 2014 release of Java 8, a common guage (depending on whose statistics you’re look- Java apps. Ucomplaint you heard from outside the Java ing at), which shows how effective the new fea- community was that Java, the language, had tures have been in keeping the language relevant, stalled. The JVM, by comparison, was widely useful, and practical. Oracle Cloud. admired. But even though the JVM supported The many advances from the Java team Built for modern app dev. numerous languages (which we’ve covered indi- have made it easy to overlook other innovation Built for you. vidually in this magazine over the last four years), happening with the JVM. Notably, a small team Java was still its principal language and, well, within Oracle called Oracle Labs has spent the last that was getting long in the tooth. Many of us few years researching ways to improve the JVM’s knew this point of view was exaggerated. The Java performance and its ability to host other lan- team had widely and frequently communicated guages. In April, the group announced that a set the innovations it was working on and the wave of new technologies had reached version 1.0 and of innovations that would be coming after those. were now available for wider use. Among these Java 8 indeed disarmed critics who had claimed were GraalVM—a different take on the current Start here: that Java wasn’t keeping up with other languages. JVM—and the Truffle API, which facilitates port- developer.oracle.com And the changes in Java 9 and 10, as well as the ing languages to Graal. upcoming Java 11, are demonstrating the torrid GraalVM is designed with two goals in mind: pace at which new features will be delivered. Java performance and the ability to support many #developersrule remains either the #1 or #2 most widely used lan- languages. Let me start with the matter of lan- PHOTOGRAPH BY BOB ADLER/THE VERBATIM AGENCY 05 ORACLE.COM/JAVAMAGAZINE /////////////////////////////////////////////// MAY/JUNE 2018 //from the editor / guages. Out of the box, GraalVM JVM programs. They do this with tion is available for Java and the supports JavaScript, Python 3, R, ahead-of-time (AOT) compila- languages discussed earlier. and Ruby. In addition, it can run tion. AOT is a term that refers to GraalVM is an exciting proj- any code destined for the LLVM regular old compilation to native ect—not only because it contin- back end. Today, this includes C binaries (as C, C++, Go, and Rust ues to expand the possibilities and C++, among other languages. do). To run, the programs use of both Java and the JVM, but Looking just at the JavaScript some memory-management because it appears to have a support, you can swap out the V8 and thread-scheduling abilities genuine opportunity to deliver The Best virtual machine in Node.js and of the Substrate VM, which is a on the quest of many language replace it with GraalVM, and your JVM-like virtual machine that infrastructure developers: a vir- Resource programs will run unchanged. is itself compiled to native code. tual machine that runs all major However, thanks to GraalVM’s In this sense, the Substrate VM languages well. for Modern support for other languages, your can be viewed as simply a run- Because of its importance project can now run more than time library of functions needed in advancing the Java platform Cloud Dev JavaScript. For example, you can for execution. This native option and because it is inherently such define data structures in C or C++ removes the JVM’s long startup interesting technology, we’ll be The Oracle Developer and use them with JavaScript. time. In addition, the code is not covering GraalVM extensively in Gateway is the best place How cool is that? interpreted at any point, provid- future issues of the magazine. to jump-start your modern A framework called Truffle ing further performance benefit. But don’t wait for us: if you want cloud development skills is available to facilitate using Another path to reduced exe- to start working with the tech- with free trials, downloads, GraalVM for execution of other cution time is the use of more- nology now, go to the website, tutorials, documentation, languages. A tutorial, includ- aggressive optimizations. For download it, and try it out. and more. ing instructions for implement- example, GraalVM makes exten- ing a simplified language, is sive use of escape analysis—a Andrew Binstock, Editor in Chief Trials. Downloads. available here. type of analysis that recognizes [email protected] Tutorials. Start here: The second key aspect of certain data objects that can @platypusguy developer.oracle.com GraalVM is the performance be treated as if they were local improvement it delivers. Because variables, resulting in far fewer I have seen only a few bench- memory allocations.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages100 Page
-
File Size-