FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Java is a new Language on the Mainframe Copenhagen, 8th January 2016 Michael Erichsen, Xact Consulting A/S, michael.erichsen@xact.dk
Agenda • Why Java on z? • Which kind of language is Java? • How is Java implemented on z? • How do I develop mixed language Java applications on z? • What is the security setup? • What do I need to learn?
Second Slot after Lunch? This is surely the Graveyard Shift! • What do you think System.exit() will do? • What do you think it will do in CICS?
Second Slot after Lunch? This is surely the Graveyard Shift! • Exactly the same as a COBOL STOP RUN in CICS!
System.exit() in CICS 13.16.28 STC00106 +DFHSJ0214 CICSTS51 019 13:16:28 CICSTS51 A class in a JVM Server has invoked System.exit(). CICS will shut down immediately. 13.16.28 STC00106 +DFHDU0201 CICSTS51 ABOUT TO TAKE SDUMP. DUMPCODE: ASJS , DUMPID: 1/0023 13.16.50 STC00106 +DFHTM1703 CICSTS51 CICS is being terminated by userid CICSUSER in transaction HT01 at netname SC0TCP29. 13.16.50 STC00106 +DFHMQ0410 I 01/05/2016 13:16:50 CICSTS51 CICS immediate shutdown detected. Adapter terminated. 13.16.52 STC00106 BPXP018I THREAD 1F8EBC0000000000, IN PROCESS 67174429, ENDED WITHOUT BEING UNDUBBED WITH COMPLETION CODE 0033E000, AND REASON CODE 00000000. … 13.17.03 STC00106 +DFHDU0303I CICSTS51 Transaction Dump Data set DFHDMPA closed. 13.17.03 STC00106 +DFHKE1799 CICSTS51 TERMINATION OF CICS IS COMPLETE. 13.17.12 STC00106 $HASP395 CICSTS51 ENDED
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Why Java on z?
Java on the Big Iron • Open the mainframe to a new generation of developers • Portability of applications • Wide choice of open and closed source packages • Typical use: Non-mixed, Java only – E.g. in WebSphere, batch, CICS, IMS, or DB2 Stored procedures
COBOL and PL/I are Native to the Mainframe
Java is also Native It was just born later
Old or New? • OO is just a way to do some categories of computing – Not something given to Moses on tablets • The first OO language, Simula, was formalized in 1962-1965 – Last version 1986 – Latest Java version 8: 2014 • COBOL was formalized in 1959-60 – Latest ISO standard: COBOL 2014 – Latest version 5.2: 2015 10
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization What Kind of Language is Java?
COBOL and other 3GL* Words • The Compiler creates an object from a source *) 3GL: Third Generation Language, like PL/I and COBOL
COBOL and other 3GL Words • A pseudo-assembler listing is produced on the way
COBOL and other 3GL Words • The Binder (Linker) binds the object into a program object or load module .0.............................................................................. 0F000000000000000000000000000000000000000000000000000000000000000000000000000000 30000000000000000000000000000000000000000000000000010000000000000000000000000000 ------------------------------------------------------------------------------ ...............................................................-........HELLOCOB 000000000000000000000000000000000000000000000000000000000000000600000000CCDDDCDC 30000001000000000000000000000000000000000000000000000000000000000000000885336362 ------------------------------------------------------------------------------ .........................................@.......................@......C_CEESG0 000000000000000000000000000000000000000008000000000000000000100008000000C6CCCECF 310100020001000000000000000000000000000010000000000000000000030A0030000A3D355270 ------------------------------------------------------------------------------ ...03........................................................................... 000FF000000000000000000000000000000000000000000000000000000000000000000000000000 32003000000000000000000000000000000000000000000000000000000000000000000000000000 ------------------------------------------------------------------------------ ...........................ì.............@..............................C_CODE.. 000000000000000000000000000500000000000008000000000000000000100000000000C6CDCC00 300100030001000000000000008800000000000010000000000000000000030A003000063D364500 ------------------------------------------------------------------------------ ........................................................................HELLOCOB 000000000000000000000000000000000000000000000000000000000000100000000000CCDDDCDC 31020004000300000000000000000000000000001000000000000000000000020300000A85336362
COBOL and other 3GL Words • The loader loads the program object into storage • Allocates static storage • Fixes up relocatable addresses • Passes over control IEWPLMH ...Ì......¢............Ì...........ð...........m...h................... CCEDDDC40007000000B0000000000007000100000008000000000009000800000001000200000004 9567348000083000000000080100000800040200000C00080300000400080400001C000405000010 ------------------------------------------------------------------------------ }00..CEE.......-}00.°Öå. .0.qÕ0................ð...q...*...q.......u...¦....ì0C. 4FF10CCC000000064FF09ED041F29EF30F000000000000080009000500090002000A000700005FC1 700413550028006070010C0C10048F047F0000000000007C0068000C00080004007400300000803C ------------------------------------------------------------------------------ æÈxÈ..j@æÈxd...Óx©..ìææ.ìææ.×õAàxd..×õæ.xd..çææ.vF..xó..xÈ..ìæ..ìææ.ìææ.ìæAàìææ. C7A70398C7A8021EAB025CC05CC0BCC4A801BCC0A8014CC2AC00AC00A7015C015CC05CC05CC45CC0 04740A1004740A2E740780008004FF14740FFF04740B800856007E01740380008000800480148004 ------------------------------------------------------------------------------ C_WSA ................................................................ C6EEC444444444440000000000000000000000000000000000000000000000000000000000000000 3D621000000000000000000000000000000000000000000000000000000000000000000000000000 ------------------------------------------------------------------------------ ...è..........çá<<!ä!â.ñâ(.ä!â!<...................ì.......ë.........ì.......ë.. 00050000000000444444440444244444223232300000000000050000000532320000052320000532 0024040000416185CCF3F2092D03F2FC005E1E10000B00000088000023D39849024048889083D398 ------------------------------------------------------------------------------ ...............LDLDM....@........@.....@.......@................................ 000000000000000DCDCD000080000000080000180010000800100000000000000000000000000000 000000000000000343441000000000400000007000E0000000D00000000000000000000000000000
Java Source • The Compiler compiles source into bytecode • There is no linking/binding for Java – Each class is loaded separately on demand
Java Bytecode • Java bytecode is the instruction set of the Java virtual machine • This is a symbolic representation Compiled from "Hello.java" public class dk.xact.michael.BatchHello.Hello { public dk.xact.michael.BatchHello.Hello(); Code: 0: aload_0 1: invokespecial #8 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #22 // String Hello from batch 5: invokevirtual #24 // Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return }
Java Bytecode • Each bytecode is composed by one (or two) bytes that represent the instruction –Along with zero or more bytes for passing parameters ca fe ba be-00 00 00 33-00 22 07 00-02 01 00 20 .......3 ."...... 64 6b 2f 78-61 63 74 2f-6d 69 63 68-61 65 6c 2f dk/xact/ michael/ 42 61 74 63-68 48 65 6c-6c 6f 2f 48-65 6c 6c 6f BatchHel lo/Hello 07 00 04 01-00 10 6a 61-76 61 2f 6c-61 6e 67 2f ......ja va/lang/ 4f 62 6a 65-63 74 01 00-06 3c 69 6e-69 74 3e 01 Object.. .<init>. 00 03 28 29-56 01 00 04-43 6f 64 65-0d 0a 00 03 ..()V... Code.... 00 09 0c 00-05 00 06 01-00 0f 4c 69-6e 65 4e 75 ........ ..LineNu 6d 62 65 72-54 61 62 6c-65 01 00 12-4c 6f 63 61 mberTabl e...Loca 6c 56 61 72-69 61 62 6c-65 54 61 62-6c 65 01 00 lVariabl eTable.. 04 74 68 69-73 01 00 22-4c 64 6b 2f-78 61 63 74 .this.." Ldk/xact 2f 6d 69 63-68 61 65 6c-2f 42 61 74-63 68 48 65 /michael /BatchHe 6c 6c 6f 2f-48 65 6c 6c-6f 3b 01 00-04 6d 61 69 llo/Hell o;...mai 6e 01 00 16-28 5b 4c 6a-61 76 61 2f-6c 61 6e 67 n...([Lj ava/lang 2f 53 74 72-69 6e 67 3b-29 56 09 00-11 00 13 07 /String; )V...... 00 12 01 00-10 6a 61 76-61 2f 6c 61-6e 67 2f 53 .....jav a/lang/S 79 73 74 65-6d 0c 00 14-00 15 01 00-03 6f 75 74 ystem... .....out 01 00 15 4c-6a 61 76 61-2f 69 6f 2f-50 72 69 6e ...Ljava /io/Prin 74 53 74 72-65 61 6d 3b-08 00 17 01-00 10 48 65 tStream; ......He 6c 6c 6f 20-66 72 6f 6d-20 62 61 74-63 68 0d 0a llo.from .batch.. 00 19 00 1b-07 00 1a 01-00 13 6a 61-76 61 2f 69 ........ ..java/i 6f 2f 50 72-69 6e 74 53-74 72 65 61-6d 0c 00 1c o/PrintS tream...
Java at Runtime • The Java Classloader executes these steps for each class: – Load • Loading brings the bytecode into the JVM – Link • Verification ensures the class/interface is structurally correct • Preparation involves allocating memory needed by the class/interface • Resolution resolves symbolic references – Initialize • Initialization gives the proper initial values to the class variables
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization How is Java implemented on z?
The JVM is a Set of C++ Programs in zFS
Java Native Interface (JNI) is the Bridge • JNI enables Java code running in a JVM to call and be called by native applications and libraries written in other languages • Functionality implemented in separate C or C++ files – Convert native arrays to/from Java arrays, native strings to/from Java strings, instantiate objects, throw exceptions, etc.
Sample COBOL JNI Program PROGRAM-ID. "DBBATCOB" RECURSIVE. REPOSITORY. Class DbBatchJava is "DbBatchJava" Class jstring is "jstring". WORKING-STORAGE SECTION. 01 parmString OBJECT REFERENCE jstring. LINKAGE SECTION. COPY JNI. PROCEDURE DIVISION. Set address of JNIEnv to JNIEnvPtr Set address of JNINativeInterface to JNIEnv CALL "NewStringPlatform” USING BY VALUE JNIEnvPtr ADDRESS OF input-string ADDRESS OF parmString 0 RETURNING RC. INVOKE DbBatchJava "sayHello” USING BY VALUE parmString RETURNING RC.
Sample called Java Program public class DbBatchJava { public static int sayHello(String inputString) { System.out.println("DB Batch Java received " + inputString); return 4711; } }
JDBC • JDBC (Java Data Base Connection) • Lower part implemented as C++ program objects • Upper part implemented as Java classes calling through JNI • Note that the jar files in the figure are really symbolic links to the program objects in the /IBM folder
Which Runtimes? • Batch – BPX – C:OZ – JZOS – BCD • CICS – JVMServer • JCICS • OSGi • JDBC Type 2 (Local) • SQLJ (Static) – Liberty • PHP • Mobile • Servlets • JSP • SAML • JDBC Type 4 (Over TCP/IP) • DB2 – Stored procedures • IMS – JMP – JDBC • MQ – WMQ API – jms • WAS – ”Classic” – Liberty • zLinux All of them!
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Challenges
Theory and Practice • Processor been optimized for the JVM • JVM has been optimized for the processor • You should be at the highest level of both – Z13 boxes – Java 8 • In theory performance comparable between Java and 3GL
Theory and Practice • In theory, there is no difference between theory and practice • But, in practice, there is
Theory and Practice • Theory – You understand everything – Nothing works • Practice – Everything works – Nobody knows why • Here we unite theory and practice – Nothing works – Nobody understands why
Mainframe Issues • Virtualization conflicts • JVM load and initalization CPU usage • Garbage Collection Policies • Heap size tunings
Virtualization Conflicts • Mainframe has excelled in virtual storage and virtual machines since the 1960’es – Based on a set of civilized traffic rules in a multi-tenant system • Java has its own Virtual Machine – Raised as a spoiled only child with no manners – Grabs all the storage it can immediately • Has been handled on z in different ways over time • JVM on top of Virtual Storage on top of z/OS perhaps on top of z/VM on top of PR/SM...?
JVM Load and Initialization • Can take a lot of MIPS – You should minimize loads – You should reuse JVM’s
Shared Class Cache • A shared class area for one or more JVM’s improves startup time – Lots of classes are already preloaded • Switch on shared classes with the -Xshareclasses command-line option – Virtual memory footprint reduction when using more than one JVM – Loading classes from a populated cache is faster than loading classes from disk – Improved startup – Classes are already in memory and partially verified – Benefits applications that regularly start new JVM instances doing similar tasks – Cost to populate an empty cache with a single JVM is minimal • Both relevant for CICS and batch
CICS OSGi middleware bundles • JVMProfile option OSGI_BUNDLES • Middleware bundles installed and activated in the OSGi framework when JVM is initialized • OSGI_BUNDLES=/u/example/pathToBundleDirectory/B1.jar, /u/example/pathToBundleDirectory/B2.jar
Storage Differences • Storage is static in COBOL, HLASM, PL/I etc. • Storage is dynamic in Java • You should not call from Java to COBOL with an area that has not yet been allocated by Java – Storage violations – Null pointer exceptions
COBOL Storage Allocation • WORKING-STORAGE normally allocated from LE heap storage – If you declare it, it is being allocated • LOCAL-STORAGE allocated from LE stack storage • External variables allocated from LE heap storage • LE stack storage is automatically created by LE and is used for routine linkage and automatic storage • LE heap storage is dynamically allocated at a routine's first request for storage that has a lifetime not related to the execution of the current routine
Java Storage Allocation from LE Heap • The Java heap that garbage collection manages is allocated during JVM startup as a contiguous area of memory – Its size is that of the maximum Java heap size parameter – Allocate for the maximum heap size to ensure that one contiguous area will be available should heap expansion occur • Explicit calls to malloc() by the JVM, or by any native JNI (Java Native Interface) code that is running under that Java process – This includes application JNI code, and vendor-supplied native libraries; for example, JDBC drivers
Garbage Collection • Java normally does not do explicit allocation and deallocation • Deallocation done as Garbage Collection (GC) – All active objects marked and copied away – All unused deleted by compacting storage – Done in different pools to handle short and long lived objects separately
Garbage Collection Issues • Pause time • Pause predictability • CPU usage • Memory footprint – Virtual footprint – GC interaction with paging and swapping • The unimaginable memory leaks – Unintended object retention
IBM JVM Garbage Collection Policies • -Xgcpolicy:optthruput – For “batch” type apps • -Xgcpolicy:optavgpause – For apps with responsiveness criteria • -Xgcpolicy:gencon – Highly transactional workloads • -Xgcpolicy:subpools – Large systems with allocation contention
Heap size tuning • Java heap size tuning is an art – Small heaps get filled up quickly • GC runs often – Large heaps hold a lot of objects • Each GC takes a long time (”Stop the World”) – Need tools, measurements, statistics and tuning • Java heaps lives on top of Language Environment heaps and z/OS virtual storage – LE heaps can be measured and tuned – Paging and swapping can be the result of overallocating heaps
Or you can just buy more Real Storage...
Health Center • An agent is included in the IBM JVM in recent versions, so you don’t have to install anything • A server is part of IBM Support Assistant Team Server – If you have the authority you can alternatively install it and run it on your own workstation • A client can run in a browser or in Eclipse
IBM Support Assistant
Health Center Summary
Health Center CPU Usage
Health Center Garbage Collection
Health Center File I/O
Health Center Profiler
Health Center Thread Analysis
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Development
Plain Java Development • All Java tools can be used • Rational Developer for z has support for special API’s like JCICS and for OSGi • The IBM JVM is 100% compatible with Sun/Oracle from the development side – Differences only in JVM implementation and in toolbox
Addressing Modes • COBOL runs in 31 bit mode • Java can run in 31 or 64 bit mode • Calling between 31 and 64 bit programs can yield interesting results
Java in Batch • BPX – Unix batch launcher • Co:Z – Executes the Unix program or shell in the same address space, which simplifies job accounting and allows for the use of resources such as DD statements by the Unix program • JZOS – Java batch launcher • BCD – Managed environment for Java – Allows interoperability with COBOL and PL/I
BPXBATCH and BPXBATSL • USS batch launcher facilities – Can launch a JVM in a batch job • BPXBATCH Limitations – No flexible configuration of the USS environment for each job – No condition codes passed – Separate address space – No use of DD statements – Stderr and stdout not written before the step has finished • BPXBATSL supports DD statements • C:OZ is an improved solution, supplied as Freeware from Dovetailed Technologies
JZOS • Java batch launcher – Written in Java by Dovetailed Technologies and acquired by IBM • Call the JZOS batch launcher load module from JCL to create a JVM under UNIX System Services • DD statements – Java main class – Java version that is needed for this job – Classpath – Libpath – Additional JVM arguments, also from a PDSE member – JVM Encoding
JZOS Advantages • Launcher and JVM run in the same address space • Makes job accounting easier • Allows the use of DD statements • System.out.println() and System.err.println() redirected to SYSOUT and SYSERR • Easier to integrate in a scheduling environment
z/OS Batch Runtime (BCD) • Java-focused, platform-neutral programming model • Managed environment for Java – Allows interoperability with COBOL and PL/I – Supports DB2 hybrid applications • Initialization – Set up the job step under a Resource Recovery Services (RRS) managed global transaction – Call the primary COBOL or Java application after initialization of the environment
z/OS Batch Runtime (BCD) • Mixed COBOL/PL/I and Java batch application with a shared DB2 connection – Coexistence of SQL, JDBC and SQLJ – Updates to DB2 are committed in the same unit of work • Consistent with IBM WebSphere-based batch • Must run in 31 bit mode, because COBOL and PL/I are 31 bit • JZOS launches the Java program com.ibm.zos.batch.container.BCDBatchContainer that invokes your Java, COBOL and PL/I programs
Seamless Debug in CICS • COBOL & PL/I – Connect to DTCN in Host Connections – Create a DTCN Server Profile • Java – Open RDz Debug Configurations – Start the Remote Java Application pointing to the Java project and CICS • Run the transaction in CICS
Seamless debug: COBOL
Seamless debug: Java
Seamless debug: COBOL again
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Security
Batch and CICS Liberty • EJBROLE – Member class for Enterprise Java Beans authorization roles • GEJBROLE – Grouping class for Enterprise Java Beans authorization roles • JAVA – Contains profiles that are used by Java for z/OS applications to perform authorization checking for Java for z/OS resources
EJBROLE Examples • ADMINISTRATOR • ADMINSECURITYMANAGER • BBNBASE.deployer • BBNBASE.CosNamingCreate • COSNAMINGCREATE • OPERATOR • IZUDFLT.*.izuUsers (G) • isCallerInRole() • isUserInRole()
CICS JVMServer • Normal CICS RACF security – Transactions – Programs – Etc. • Java OSGi Security Manager – Forbid System.exit()
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Education
What do I need to learn? • Object Orientation – Inheritance – Encapsulation – Polymorphism • Java syntax & semantics • Libraries – Supplied with Java – Supplied by IBM – Open source • Development tools – Eclipse – RDz – Mapping tools – ... • Performance tools • Site & business specific knowledge
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Moderniza- tion Conversion Business Software Consultants
FOR MORE INFORMATION PLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Thank you for your attention

Java is a new language on the mainframe

  • 1.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Java is a new Language on the Mainframe Copenhagen, 8th January 2016 Michael Erichsen, Xact Consulting A/S, michael.erichsen@xact.dk
  • 2.
    Agenda • Why Javaon z? • Which kind of language is Java? • How is Java implemented on z? • How do I develop mixed language Java applications on z? • What is the security setup? • What do I need to learn?
  • 3.
    Second Slot afterLunch? This is surely the Graveyard Shift! • What do you think System.exit() will do? • What do you think it will do in CICS?
  • 4.
    Second Slot afterLunch? This is surely the Graveyard Shift! • Exactly the same as a COBOL STOP RUN in CICS!
  • 5.
    System.exit() in CICS 13.16.28STC00106 +DFHSJ0214 CICSTS51 019 13:16:28 CICSTS51 A class in a JVM Server has invoked System.exit(). CICS will shut down immediately. 13.16.28 STC00106 +DFHDU0201 CICSTS51 ABOUT TO TAKE SDUMP. DUMPCODE: ASJS , DUMPID: 1/0023 13.16.50 STC00106 +DFHTM1703 CICSTS51 CICS is being terminated by userid CICSUSER in transaction HT01 at netname SC0TCP29. 13.16.50 STC00106 +DFHMQ0410 I 01/05/2016 13:16:50 CICSTS51 CICS immediate shutdown detected. Adapter terminated. 13.16.52 STC00106 BPXP018I THREAD 1F8EBC0000000000, IN PROCESS 67174429, ENDED WITHOUT BEING UNDUBBED WITH COMPLETION CODE 0033E000, AND REASON CODE 00000000. … 13.17.03 STC00106 +DFHDU0303I CICSTS51 Transaction Dump Data set DFHDMPA closed. 13.17.03 STC00106 +DFHKE1799 CICSTS51 TERMINATION OF CICS IS COMPLETE. 13.17.12 STC00106 $HASP395 CICSTS51 ENDED
  • 6.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Why Java on z?
  • 7.
    Java on theBig Iron • Open the mainframe to a new generation of developers • Portability of applications • Wide choice of open and closed source packages • Typical use: Non-mixed, Java only – E.g. in WebSphere, batch, CICS, IMS, or DB2 Stored procedures
  • 8.
    COBOL and PL/Iare Native to the Mainframe
  • 9.
    Java is alsoNative It was just born later
  • 10.
    Old or New? •OO is just a way to do some categories of computing – Not something given to Moses on tablets • The first OO language, Simula, was formalized in 1962-1965 – Last version 1986 – Latest Java version 8: 2014 • COBOL was formalized in 1959-60 – Latest ISO standard: COBOL 2014 – Latest version 5.2: 2015 10
  • 11.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization What Kind of Language is Java?
  • 12.
    COBOL and other3GL* Words • The Compiler creates an object from a source *) 3GL: Third Generation Language, like PL/I and COBOL
  • 13.
    COBOL and other3GL Words • A pseudo-assembler listing is produced on the way
  • 14.
    COBOL and other3GL Words • The Binder (Linker) binds the object into a program object or load module .0.............................................................................. 0F000000000000000000000000000000000000000000000000000000000000000000000000000000 30000000000000000000000000000000000000000000000000010000000000000000000000000000 ------------------------------------------------------------------------------ ...............................................................-........HELLOCOB 000000000000000000000000000000000000000000000000000000000000000600000000CCDDDCDC 30000001000000000000000000000000000000000000000000000000000000000000000885336362 ------------------------------------------------------------------------------ .........................................@.......................@......C_CEESG0 000000000000000000000000000000000000000008000000000000000000100008000000C6CCCECF 310100020001000000000000000000000000000010000000000000000000030A0030000A3D355270 ------------------------------------------------------------------------------ ...03........................................................................... 000FF000000000000000000000000000000000000000000000000000000000000000000000000000 32003000000000000000000000000000000000000000000000000000000000000000000000000000 ------------------------------------------------------------------------------ ...........................ì.............@..............................C_CODE.. 000000000000000000000000000500000000000008000000000000000000100000000000C6CDCC00 300100030001000000000000008800000000000010000000000000000000030A003000063D364500 ------------------------------------------------------------------------------ ........................................................................HELLOCOB 000000000000000000000000000000000000000000000000000000000000100000000000CCDDDCDC 31020004000300000000000000000000000000001000000000000000000000020300000A85336362
  • 15.
    COBOL and other3GL Words • The loader loads the program object into storage • Allocates static storage • Fixes up relocatable addresses • Passes over control IEWPLMH ...Ì......¢............Ì...........ð...........m...h................... CCEDDDC40007000000B0000000000007000100000008000000000009000800000001000200000004 9567348000083000000000080100000800040200000C00080300000400080400001C000405000010 ------------------------------------------------------------------------------ }00..CEE.......-}00.°Öå. .0.qÕ0................ð...q...*...q.......u...¦....ì0C. 4FF10CCC000000064FF09ED041F29EF30F000000000000080009000500090002000A000700005FC1 700413550028006070010C0C10048F047F0000000000007C0068000C00080004007400300000803C ------------------------------------------------------------------------------ æÈxÈ..j@æÈxd...Óx©..ìææ.ìææ.×õAàxd..×õæ.xd..çææ.vF..xó..xÈ..ìæ..ìææ.ìææ.ìæAàìææ. C7A70398C7A8021EAB025CC05CC0BCC4A801BCC0A8014CC2AC00AC00A7015C015CC05CC05CC45CC0 04740A1004740A2E740780008004FF14740FFF04740B800856007E01740380008000800480148004 ------------------------------------------------------------------------------ C_WSA ................................................................ C6EEC444444444440000000000000000000000000000000000000000000000000000000000000000 3D621000000000000000000000000000000000000000000000000000000000000000000000000000 ------------------------------------------------------------------------------ ...è..........çá<<!ä!â.ñâ(.ä!â!<...................ì.......ë.........ì.......ë.. 00050000000000444444440444244444223232300000000000050000000532320000052320000532 0024040000416185CCF3F2092D03F2FC005E1E10000B00000088000023D39849024048889083D398 ------------------------------------------------------------------------------ ...............LDLDM....@........@.....@.......@................................ 000000000000000DCDCD000080000000080000180010000800100000000000000000000000000000 000000000000000343441000000000400000007000E0000000D00000000000000000000000000000
  • 16.
    Java Source • TheCompiler compiles source into bytecode • There is no linking/binding for Java – Each class is loaded separately on demand
  • 17.
    Java Bytecode • Javabytecode is the instruction set of the Java virtual machine • This is a symbolic representation Compiled from "Hello.java" public class dk.xact.michael.BatchHello.Hello { public dk.xact.michael.BatchHello.Hello(); Code: 0: aload_0 1: invokespecial #8 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #22 // String Hello from batch 5: invokevirtual #24 // Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return }
  • 18.
    Java Bytecode • Eachbytecode is composed by one (or two) bytes that represent the instruction –Along with zero or more bytes for passing parameters ca fe ba be-00 00 00 33-00 22 07 00-02 01 00 20 .......3 ."...... 64 6b 2f 78-61 63 74 2f-6d 69 63 68-61 65 6c 2f dk/xact/ michael/ 42 61 74 63-68 48 65 6c-6c 6f 2f 48-65 6c 6c 6f BatchHel lo/Hello 07 00 04 01-00 10 6a 61-76 61 2f 6c-61 6e 67 2f ......ja va/lang/ 4f 62 6a 65-63 74 01 00-06 3c 69 6e-69 74 3e 01 Object.. .<init>. 00 03 28 29-56 01 00 04-43 6f 64 65-0d 0a 00 03 ..()V... Code.... 00 09 0c 00-05 00 06 01-00 0f 4c 69-6e 65 4e 75 ........ ..LineNu 6d 62 65 72-54 61 62 6c-65 01 00 12-4c 6f 63 61 mberTabl e...Loca 6c 56 61 72-69 61 62 6c-65 54 61 62-6c 65 01 00 lVariabl eTable.. 04 74 68 69-73 01 00 22-4c 64 6b 2f-78 61 63 74 .this.." Ldk/xact 2f 6d 69 63-68 61 65 6c-2f 42 61 74-63 68 48 65 /michael /BatchHe 6c 6c 6f 2f-48 65 6c 6c-6f 3b 01 00-04 6d 61 69 llo/Hell o;...mai 6e 01 00 16-28 5b 4c 6a-61 76 61 2f-6c 61 6e 67 n...([Lj ava/lang 2f 53 74 72-69 6e 67 3b-29 56 09 00-11 00 13 07 /String; )V...... 00 12 01 00-10 6a 61 76-61 2f 6c 61-6e 67 2f 53 .....jav a/lang/S 79 73 74 65-6d 0c 00 14-00 15 01 00-03 6f 75 74 ystem... .....out 01 00 15 4c-6a 61 76 61-2f 69 6f 2f-50 72 69 6e ...Ljava /io/Prin 74 53 74 72-65 61 6d 3b-08 00 17 01-00 10 48 65 tStream; ......He 6c 6c 6f 20-66 72 6f 6d-20 62 61 74-63 68 0d 0a llo.from .batch.. 00 19 00 1b-07 00 1a 01-00 13 6a 61-76 61 2f 69 ........ ..java/i 6f 2f 50 72-69 6e 74 53-74 72 65 61-6d 0c 00 1c o/PrintS tream...
  • 19.
    Java at Runtime •The Java Classloader executes these steps for each class: – Load • Loading brings the bytecode into the JVM – Link • Verification ensures the class/interface is structurally correct • Preparation involves allocating memory needed by the class/interface • Resolution resolves symbolic references – Initialize • Initialization gives the proper initial values to the class variables
  • 20.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization How is Java implemented on z?
  • 21.
    The JVM isa Set of C++ Programs in zFS
  • 22.
    Java Native Interface(JNI) is the Bridge • JNI enables Java code running in a JVM to call and be called by native applications and libraries written in other languages • Functionality implemented in separate C or C++ files – Convert native arrays to/from Java arrays, native strings to/from Java strings, instantiate objects, throw exceptions, etc.
  • 23.
    Sample COBOL JNIProgram PROGRAM-ID. "DBBATCOB" RECURSIVE. REPOSITORY. Class DbBatchJava is "DbBatchJava" Class jstring is "jstring". WORKING-STORAGE SECTION. 01 parmString OBJECT REFERENCE jstring. LINKAGE SECTION. COPY JNI. PROCEDURE DIVISION. Set address of JNIEnv to JNIEnvPtr Set address of JNINativeInterface to JNIEnv CALL "NewStringPlatform” USING BY VALUE JNIEnvPtr ADDRESS OF input-string ADDRESS OF parmString 0 RETURNING RC. INVOKE DbBatchJava "sayHello” USING BY VALUE parmString RETURNING RC.
  • 24.
    Sample called JavaProgram public class DbBatchJava { public static int sayHello(String inputString) { System.out.println("DB Batch Java received " + inputString); return 4711; } }
  • 25.
    JDBC • JDBC (JavaData Base Connection) • Lower part implemented as C++ program objects • Upper part implemented as Java classes calling through JNI • Note that the jar files in the figure are really symbolic links to the program objects in the /IBM folder
  • 26.
    Which Runtimes? • Batch –BPX – C:OZ – JZOS – BCD • CICS – JVMServer • JCICS • OSGi • JDBC Type 2 (Local) • SQLJ (Static) – Liberty • PHP • Mobile • Servlets • JSP • SAML • JDBC Type 4 (Over TCP/IP) • DB2 – Stored procedures • IMS – JMP – JDBC • MQ – WMQ API – jms • WAS – ”Classic” – Liberty • zLinux All of them!
  • 27.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Challenges
  • 28.
    Theory and Practice •Processor been optimized for the JVM • JVM has been optimized for the processor • You should be at the highest level of both – Z13 boxes – Java 8 • In theory performance comparable between Java and 3GL
  • 29.
    Theory and Practice •In theory, there is no difference between theory and practice • But, in practice, there is
  • 30.
    Theory and Practice •Theory – You understand everything – Nothing works • Practice – Everything works – Nobody knows why • Here we unite theory and practice – Nothing works – Nobody understands why
  • 31.
    Mainframe Issues • Virtualizationconflicts • JVM load and initalization CPU usage • Garbage Collection Policies • Heap size tunings
  • 32.
    Virtualization Conflicts • Mainframehas excelled in virtual storage and virtual machines since the 1960’es – Based on a set of civilized traffic rules in a multi-tenant system • Java has its own Virtual Machine – Raised as a spoiled only child with no manners – Grabs all the storage it can immediately • Has been handled on z in different ways over time • JVM on top of Virtual Storage on top of z/OS perhaps on top of z/VM on top of PR/SM...?
  • 33.
    JVM Load andInitialization • Can take a lot of MIPS – You should minimize loads – You should reuse JVM’s
  • 34.
    Shared Class Cache •A shared class area for one or more JVM’s improves startup time – Lots of classes are already preloaded • Switch on shared classes with the -Xshareclasses command-line option – Virtual memory footprint reduction when using more than one JVM – Loading classes from a populated cache is faster than loading classes from disk – Improved startup – Classes are already in memory and partially verified – Benefits applications that regularly start new JVM instances doing similar tasks – Cost to populate an empty cache with a single JVM is minimal • Both relevant for CICS and batch
  • 35.
    CICS OSGi middlewarebundles • JVMProfile option OSGI_BUNDLES • Middleware bundles installed and activated in the OSGi framework when JVM is initialized • OSGI_BUNDLES=/u/example/pathToBundleDirectory/B1.jar, /u/example/pathToBundleDirectory/B2.jar
  • 36.
    Storage Differences • Storageis static in COBOL, HLASM, PL/I etc. • Storage is dynamic in Java • You should not call from Java to COBOL with an area that has not yet been allocated by Java – Storage violations – Null pointer exceptions
  • 37.
    COBOL Storage Allocation •WORKING-STORAGE normally allocated from LE heap storage – If you declare it, it is being allocated • LOCAL-STORAGE allocated from LE stack storage • External variables allocated from LE heap storage • LE stack storage is automatically created by LE and is used for routine linkage and automatic storage • LE heap storage is dynamically allocated at a routine's first request for storage that has a lifetime not related to the execution of the current routine
  • 38.
    Java Storage Allocationfrom LE Heap • The Java heap that garbage collection manages is allocated during JVM startup as a contiguous area of memory – Its size is that of the maximum Java heap size parameter – Allocate for the maximum heap size to ensure that one contiguous area will be available should heap expansion occur • Explicit calls to malloc() by the JVM, or by any native JNI (Java Native Interface) code that is running under that Java process – This includes application JNI code, and vendor-supplied native libraries; for example, JDBC drivers
  • 39.
    Garbage Collection • Javanormally does not do explicit allocation and deallocation • Deallocation done as Garbage Collection (GC) – All active objects marked and copied away – All unused deleted by compacting storage – Done in different pools to handle short and long lived objects separately
  • 40.
    Garbage Collection Issues •Pause time • Pause predictability • CPU usage • Memory footprint – Virtual footprint – GC interaction with paging and swapping • The unimaginable memory leaks – Unintended object retention
  • 41.
    IBM JVM GarbageCollection Policies • -Xgcpolicy:optthruput – For “batch” type apps • -Xgcpolicy:optavgpause – For apps with responsiveness criteria • -Xgcpolicy:gencon – Highly transactional workloads • -Xgcpolicy:subpools – Large systems with allocation contention
  • 42.
    Heap size tuning •Java heap size tuning is an art – Small heaps get filled up quickly • GC runs often – Large heaps hold a lot of objects • Each GC takes a long time (”Stop the World”) – Need tools, measurements, statistics and tuning • Java heaps lives on top of Language Environment heaps and z/OS virtual storage – LE heaps can be measured and tuned – Paging and swapping can be the result of overallocating heaps
  • 43.
    Or you canjust buy more Real Storage...
  • 44.
    Health Center • Anagent is included in the IBM JVM in recent versions, so you don’t have to install anything • A server is part of IBM Support Assistant Team Server – If you have the authority you can alternatively install it and run it on your own workstation • A client can run in a browser or in Eclipse
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Development
  • 53.
    Plain Java Development •All Java tools can be used • Rational Developer for z has support for special API’s like JCICS and for OSGi • The IBM JVM is 100% compatible with Sun/Oracle from the development side – Differences only in JVM implementation and in toolbox
  • 54.
    Addressing Modes • COBOLruns in 31 bit mode • Java can run in 31 or 64 bit mode • Calling between 31 and 64 bit programs can yield interesting results
  • 55.
    Java in Batch •BPX – Unix batch launcher • Co:Z – Executes the Unix program or shell in the same address space, which simplifies job accounting and allows for the use of resources such as DD statements by the Unix program • JZOS – Java batch launcher • BCD – Managed environment for Java – Allows interoperability with COBOL and PL/I
  • 56.
    BPXBATCH and BPXBATSL •USS batch launcher facilities – Can launch a JVM in a batch job • BPXBATCH Limitations – No flexible configuration of the USS environment for each job – No condition codes passed – Separate address space – No use of DD statements – Stderr and stdout not written before the step has finished • BPXBATSL supports DD statements • C:OZ is an improved solution, supplied as Freeware from Dovetailed Technologies
  • 57.
    JZOS • Java batchlauncher – Written in Java by Dovetailed Technologies and acquired by IBM • Call the JZOS batch launcher load module from JCL to create a JVM under UNIX System Services • DD statements – Java main class – Java version that is needed for this job – Classpath – Libpath – Additional JVM arguments, also from a PDSE member – JVM Encoding
  • 58.
    JZOS Advantages • Launcherand JVM run in the same address space • Makes job accounting easier • Allows the use of DD statements • System.out.println() and System.err.println() redirected to SYSOUT and SYSERR • Easier to integrate in a scheduling environment
  • 59.
    z/OS Batch Runtime(BCD) • Java-focused, platform-neutral programming model • Managed environment for Java – Allows interoperability with COBOL and PL/I – Supports DB2 hybrid applications • Initialization – Set up the job step under a Resource Recovery Services (RRS) managed global transaction – Call the primary COBOL or Java application after initialization of the environment
  • 60.
    z/OS Batch Runtime(BCD) • Mixed COBOL/PL/I and Java batch application with a shared DB2 connection – Coexistence of SQL, JDBC and SQLJ – Updates to DB2 are committed in the same unit of work • Consistent with IBM WebSphere-based batch • Must run in 31 bit mode, because COBOL and PL/I are 31 bit • JZOS launches the Java program com.ibm.zos.batch.container.BCDBatchContainer that invokes your Java, COBOL and PL/I programs
  • 61.
    Seamless Debug inCICS • COBOL & PL/I – Connect to DTCN in Host Connections – Create a DTCN Server Profile • Java – Open RDz Debug Configurations – Start the Remote Java Application pointing to the Java project and CICS • Run the transaction in CICS
  • 62.
  • 63.
  • 64.
  • 65.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Security
  • 66.
    Batch and CICSLiberty • EJBROLE – Member class for Enterprise Java Beans authorization roles • GEJBROLE – Grouping class for Enterprise Java Beans authorization roles • JAVA – Contains profiles that are used by Java for z/OS applications to perform authorization checking for Java for z/OS resources
  • 67.
    EJBROLE Examples • ADMINISTRATOR •ADMINSECURITYMANAGER • BBNBASE.deployer • BBNBASE.CosNamingCreate • COSNAMINGCREATE • OPERATOR • IZUDFLT.*.izuUsers (G) • isCallerInRole() • isUserInRole()
  • 68.
    CICS JVMServer • NormalCICS RACF security – Transactions – Programs – Etc. • Java OSGi Security Manager – Forbid System.exit()
  • 69.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Education
  • 70.
    What do Ineed to learn? • Object Orientation – Inheritance – Encapsulation – Polymorphism • Java syntax & semantics • Libraries – Supplied with Java – Supplied by IBM – Open source • Development tools – Eclipse – RDz – Mapping tools – ... • Performance tools • Site & business specific knowledge
  • 71.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Moderniza- tion Conversion Business Software Consultants
  • 72.
    FOR MORE INFORMATIONPLEASE CONTACT Xact Consulting A/S Arnold Nielsens Boulevard 68A DK-2650 Hvidovre +45 7023 0100 info@xact.dk www.xact.dk Enterprise Modernization Thank you for your attention

Editor's Notes

  • #11 Components are inherent for both paradigms