Java Magazine, November/December 2017
Total Page:16
File Type:pdf, Size:1020Kb
DYNAMIC METHOD INVOCATION 67 | INSIDE JAVA CARD 77 | JAVA QUIZ 91 NOVEMBER/DECEMBER 2017 magazine By and for the Java community JAVA EE 8 WHAT YOU NEED TO KNOW 13 23 43 56 SERVLET 4.0 CDI 2.0 JPA 2.2 MICROPROFILE ORACLE.COM/JAVAMAGAZINE //table of contents / COVER FEATURES 23 43 56 CDI 2.0: MAKING WHAT’S NEW IN JPA 2.2 ECLIPSE MICROPROFILE: DEPENDENCY INJECTION By Josh Juneau THE LIGHT ENTERPRISE A LOT EASIER Streaming results, better date JAVA OPTION By Arjan Tijms conversions, and new annotations By Mert Çalişkan A new spec, new features, are just a few of the many handy Examining a Java EE architecture 13 and new annotations. What’s improvements. designed for microservices and SERVLET 4.0: DOING MORE FASTER not to like? distributed applications By Alex Theedom A major new release of the Servlet API embraces the HTTP/2 protocol and anticipates resource requirements. OTHER FEATURES DEPARTMENTS 67 91 05 11 Understanding Java Method Fix This From the Editor Java Proposals of Interest Invocation with Invokedynamic By Simon Roberts Java EE 8 development goes JEP 295: Ahead-of-Time Compilation By Ben Evans Our latest quiz with questions that test open source. to Native Binaries The instruction added in Java 7 makes intermediate and advanced knowledge 07 42 it possible to resolve method calls dynam- of the language ically at runtime. Java Books User Groups Review of Ken Kousen’s Modern The Netherlands JUG 77 Java Recipes 101 An Introduction to Java Card 09 By Nicolas Ponsini and Florian Tournier Contact Us The smallest Java platform is one of the Events Have a comment? Suggestion? Want to most widely distributed. See how pro- Upcoming Java conferences and events submit an article proposal? Here’s how. gramming it is different from developing conventional apps. COVER ART BY WES ROWELL 02 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2017 EDITORIAL PUBLISHING Editor in Chief Publisher and Audience Development Andrew Binstock Director Managing Editor Karin Kinnear Claire Breen Audience Development Manager Copy Editors Jennifer Kurtz Karen Perkins, Jim Donahue Technical Reviewer ADVERTISING SALES Stephen Chin Sales Director Tom Cometa DESIGN Account Manager Senior Creative Director Mark Makinney Francisco G Delgadillo Mailing-List Rentals Design Director Contact your sales representative. Richard Merchán Senior Designer RESOURCES Arianna Pucherelli Oracle Products Designer +1.800.367.8674 (US/Canada) Jaime Ferrand Oracle Services Senior Publication Designer +1.888.283.0591 (US) Sheila Brennan Production Designer Kathy Cygnarowicz ARTICLE SUBMISSION If you are interested in submitting an article, please email the editors. SUBSCRIPTION INFORMATION Subscriptions are complimentary for qualified individuals who complete the subscription form. You’ve Earned It MAGAZINE CUSTOMER SERVICE [email protected] Display Your Oracle Certification Digital Badge 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. Copyright © 2017, 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 DAMAGES OF ANY KIND ARISING FROM YOUR USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. Opinions ASSOCIATE PROFESSIONAL EXPERT MASTER SPECIALIST 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 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 Claim your certification badge and validate affiliates. Other names may be trademarks of their respective owners. your skills across all online platforms. 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 /////////////////////////////// NOVEMBER/DECEMBER 2017 iText Developers Pla�orm Build on proven technology The iText Developers Pla�orm is a revenue sharing partnership that takes your crea�ve iText 7 add-on applica�on and leverages our experience in sales and marke�ng, by selling the product as part of the iText 7 Suite. Interested? Here is what it takes: Idea Build POC Apply Create Go to Market Learn more at: www.itextpdf.com/itext-developer-pla�orm //from the editor / Get a Free Trial to Java EE 8 Goes Open Source Oracle Cloud The new release is moving to the Eclipse Foundation. Experience modern, open cloud development with a free trial to Oracle n an unexpected move, Oracle announced just by companies no longer interested in support- Cloud platform and Ibefore the JavaOne conference this year that it ing them—a phenomenon known as “abandon- infrastructure services. would be turning over control of Java EE 8 to the ware.” Rather, Oracle has pledged to move its open source community. This action, effectively commercial Java EE offering, Oracle WebLogic, to Get your free trial: unthinkable a few years ago, is being realized by conformance with Java EE 8 and to continue con- developer.oracle.com giving control of the technology to the Eclipse tributing to the development and evolution of the Foundation. Included in this transition are the full standards, along with other contributors such as source code and the test suites that ensure confor- Red Hat and IBM as well as the large community mance and compliance with Java EE specificationFPO textof developers. requirements. The latter items are particularly The Eclipse Foundation was chosen in part important because they will enable new imple- due to its experience with enterprise Java tech- mentations of Java EE to be developed and dem- nologies. For example, it currently hosts the com- onstrate their bona fides. plementary MicroProfile project, which is exam- Ceding control of the certification aspect ined in detail on page 56 in this issue. In addition, shows emphatically that Oracle is giving the the foundation has the resources to assist in the developer.oracle.com technology to the community. This move should transition process. Conversations with Eclipse not be confused with the occasional dump- officials revealed that they expected the transi- ing of technologies to open source foundations tion to take roughly a year. Why so long? Not only #developersrule PHOTOGRAPH BY BOB ADLER/THE VERBATIM AGENCY 05 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2017 //from the editor / do dozens of code repositories, other projects transferred to open numerous change logs, and many source, Java EE benefits from a supporting documents need to be very active community that con- migrated to Eclipse servers, but tinues to push forward the mul- Push a Button a substantial amount of policy tiple constituent technologies. For needs to be formulated. Not only example, in this issue we look at straightforward items will need how those communities, along Move Your Java Apps to be addressed, such as staffing with Oracle, have updated Servlet, the individual projects—who gets CDI, and JPA. We certainly could to the Oracle Cloud to commit, who reviews changes, have included other technologies and who runs the projects?—but too—many of which are driven also larger questions, such as by active expert groups donating how will conformance with Java their time and effort to the project. EE standards be validated? What This strong community guar- will the process be for determin- antees the success of this migra- ing a new release? AndFPO so on. As texttion. If all goes well, as I expect it David Delabassée of Oracle points will, the migration should make Same Java Runtime out, there are additional issues it possible to attract even more Same Dev Tools to resolve as well, such as brand- developers to grow and advance ing and the possible integration these technologies. Same Standards of MicroProfile. Same Architecture Branding got off to a bit of Andrew Binstock, Editor in Chief a rocky start at JavaOne, when [email protected] rumor had it that Java EE would be @platypusguy renamed EE4J (Eclipse Enterprise for Java). However, that was the proposed name of the project at the Eclipse Foundation, rather than of the technology itself. To what extent future releases will … or Back to Your Data Center use the Java EE brand has yet to be determined. Reaction to the move by Oracle has been uniformly sup- portive. And there’s good reason for that enthusiasm. Unlike many 06 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// NOVEMBER/DECEMBER 2017 // java books / MODERN JAVA RECIPES By Ken Kousen I love recipe books. Judging from knowledgeable developer who is tors; optionals; the java.time pack- the popularity of resources such equally expert at presenting the age; parallelism and concurrency; as StackOverflow, the thirst for information. There are 74 recipes in and a chapter on Java 9’s additions. working chunks of code that cor- 300 pages, which shows the level of A useful addendum is an rectly handle a discrete task is detail and background that accom- 18-page appendix that focuses on nearly insatiable. The big differ- panies every recipe. understanding the complexities of ence between most online sites A common limitation of recipe generics in recent releases of Java. that offer code solutions and a book books is that you don’t remember Surely, they are now as complex as such as Ken Kousen’s Modern Java them when you have a problem function declarations in C and C++.