Remastering Legacy Java
Total Page:16
File Type:pdf, Size:1020Kb
Remastering Legacy Java 2019.5.15 Kenji Kazumura 0 Copyright 2019 FUJITSU LIMITED Fujitsu and Java One of the oldest Java related products vendor Including Java for mainframe Interstage Application Server since 1998 Java EE certified GlassFish base application server Interstage Studio Eclipse base classic GUI library for client desktop 1 Copyright 2019 FUJITSU LIMITED History of Client Java Client & Server Web Server Server Server Server JSP/JSF Applet/Flash HTML5・SPA Clinet Browser Browser Browser Reduce Reduce Reduce Client Rich GUI Server Load Security Risk Maintenance Increase Client Increase Improve Poor GUI Maintenance Security Risk pc performance Cost W3C HTML5 recomendation 2 Copyright 2019 FUJITSU LIMITED Applet Technology Bundle with Netscape Navigator WebStart 2001 1998 1996 2013 1995 J2SE 1.2/Java Plugin 2015 Java BundleApplet runs on withHotJava browserNetscape Navigator 2017 2001 Applet 1998 WebStart 1996 Java Virtual Machine 1995 J2SE 1.2/Java Plugin Plugin Java Applet runs on HotJava browser NPAPI Web browser ※NPAPI:Netscape Plugin Application Programming Interface 3 Copyright 2019 FUJITSU LIMITED Applet Technology US DHS recomendation Bundle with Netscape Navigator WebStart (disable Plugin) 2001 1998 1996 2013 Google Chrome 1995 J2SE 1.2/Java Plugin 2015 disable NPAPI Java Applet runs on HotJava browser Edge quit NPAPI 2017 Applet support Java Virtual Machine FireFox quit NPAPI except Flash Plugin Oracle Java 9 deprecate Applet NPAPI Oracle Java 6/7 Web browser remove Plugin ※NPAPI:Netscape Plugin Application Programming Interface 4 Copyright 2019 FUJITSU LIMITED Applet Resources How much are there Applet ? Fujitsu Customers # of client pc A Company 90,000 B Company 70,000 C Company 54,000 D Company 21,000 E Company 5,000 F Company 3,500 G Company 3,000 H Company 3,000 Total 249,500 5 Copyright 2019 FUJITSU LIMITED Migration Plans 1 Use Applet until end of IE11 2 Use JSP/JSF JavaServer Faces Not so much used ? 3 use HTML5/JavaScript favorite!? 6 Copyright 2019 FUJITSU LIMITED Jakarta EE survey (used API) Java Persistence API (JPA) 76.23% Java API for Restful Web Services (JAX-RS) 75.73% Servlet 59.39% Enterprise JavaBeans (EJB) 51.14% Java Transition API 47.31% (JTA) JavaServer Pages 39.39% (JSP) JavaServer Faces 33.63% (JSF) ※https://jakarta.ee/news/2018/04/24/jakarta-ee-community-survey/ JSP/JSF are not used so much 7 Copyright 2019 FUJITSU LIMITED Migration Technologies Java app runs on browser without Plugin DukeScript https://dukescript.com/ JavaFX app runs on browser jpro https://www.jpro.io Transpiler from Java to JavaScript JSweet http://www.jsweet.org/ 8 Copyright 2019 FUJITSU LIMITED Transpiler Change source code in a language to same code in a different language Difference between transpiler and compiler COBOL source C source transpiler Machine code 9 Copyright 2019 FUJITSU LIMITED Examples of transpiler Legacy language • Fortran → C (f2c) • C++ → C (cfront) JavaScript (altJS) • TypeScript → JavaScript • CoffeeScript → JavaScript Legacy to JavaScript • Java → JavaScript (GWT, JSweet) • Haskell → JavaScript (GHCJS) 10 Copyright 2019 FUJITSU LIMITED Java→JavaScript transpiler pros • Need not know JavaScript • Easy to migration of legacy Java app • IDE support cons • Rapid frontend technology • API mismatch 11 Copyright 2019 FUJITSU LIMITED JSweet Java → TypeScript(JavaScript) transpiler • http://jsweet.org Syntax Mapper • Only Syntax conversion • Use JavaScript API in Java code Resolve existing problems of transpiler Application Java source JavaScript API(Candy) separation JavaScript impl 12 Copyright 2019 FUJITSU LIMITED Existing transpiler (API conversion) Input Java source Button button = new Button(); button.setLabel(“click me”); transpile Need not modify Java source Output JavaScript var button = document.createElement(”button”); button.innerText = “click me”; 13 Copyright 2019 FUJITSU LIMITED JSweet transpiler (Syntax Mapper) Input Java source Button button = new Button(); button.setLabel(“click me”); Modify Java source API conversion Modified Java source HTMLButtonElement button = document.createElement(StringTypes.button); button.innerText = “click me”; transpile Syntax Mapper Output TypeScript let button : HTMLButtonElement= document.createElement(”button”) button.innerText = “click me”; 14 Copyright 2019 FUJITSU LIMITED New problem Need source modification before transpilation Resolve by Candy No modification Application Common Library(Candy) Java Modified code source JavaScript API(Candy) separation JavaScript impl Good for systems using common library/framework 15 Copyright 2019 FUJITSU LIMITED JSweet (practical way) Input Java source public class Button extends JButton { Button button = new Button(); public void setLabel(String label) { button.setLabel(“click me”); this.label = label; } No Modify only library modification ( ) for app API conversion public class Button { public Button { button = document.createElement(StringTypes.button); } Button button = new Button(); public void setLable(String label); button.innerText = label; button.setLabel(“click me”); } transpile Syntax Mapper 16 Copyright 2019 FUJITSU LIMITED Candy (JSweet library) Bridge between Java and JavaScript • There are 1744 Candy registered (as of 2018/5) http://www.jsweet.org/candies-releases/ • Can create your own Candy types • Java Candy: Application common Java library can be used Common Library(Candy) by JSweet • JavaScript Candy: JavaScript API(Candy) bridge to existing JavaScript impl JavaScript 17 Copyright 2019 FUJITSU LIMITED System of Company A Summary of system Requirements 22K LoC Applet Migrate to JavaScript Created more than with less cost and time 10years ago Must be same as Use Fujitsu GUI before for Looks and product operation 18 Copyright 2019 FUJITSU LIMITED Fujitsu product for Client provide button,label,frame and dialog for Java GUI application Application(Java) JBKGUI SpreadBean Spread functions similar to Excel JRE(AWT/coreAPI) for Java application Java Virtual Machine JBK Plugin Web browser Run applet on Web browser *JBK: J Business Kit 19 Copyright 2019 FUJITSU LIMITED Applet transformation before after Applet(Java) Application(JavaScript) JBKGUI Spread JBKGUI SpreadBean (JavaScript)(JavaScript) Java base core JavaScript spread API JRE(AWT/coreAPI) AWT framework library JBK Plugin JavaScript engine Java Virtual Machine jQuery AngularJS SlickGrid … Wijmo Web browser Web browser … 20 Copyright 2019 FUJITSU LIMITED Demo POC 21 Copyright 2019 FUJITSU LIMITED Result LoC of two windows LoC %auto total manual auto A window 6,102 63 6,039 99.0% B window 4,764 44 4,720 99.1% common 11,789 849 10,940 92.8% total 22,655 956 21,699 95.8% manual: need to modify for transpiler High auto transformation by Candy of Fujitsu product 22 Copyright 2019 FUJITSU LIMITED Copyright 2019 FUJITSU LIMITED.